当前位置:网站首页>A method of asynchronous response of application service through load balancing

A method of asynchronous response of application service through load balancing

2022-04-23 21:57:00 Three stone orders

use C++ Built web The service does not support multithreading and asynchrony , You can open multiple applications with different ports , Then configure nginx Realization .
1、 Implement running the application through command parameters ; Here we use mfc Application as an example , Debugging can be set through properties ;
 Insert picture description here
 Insert picture description here 2、 Batch applications that open multiple different ports ;

echo off
taskkill /f /im XRayDetector.exe
start XRayDetector.exe 9697
start XRayDetector.exe 9698
start XRayDetector.exe 9699
start XRayDetector.exe 9700

3、 To configure nginx; download nginx, Notepad open conf/nginx.conf, Set up api Path and proxy port ;

    upstream serverswitch {
    
        server localhost:9697;
        server localhost:9698;
        server localhost:9699;
        server localhost:9700;
    }

    server {
    
        listen       9696;
        server_name  localhost;
        location /api/xxx{
    
           proxy_pass http://serverswitch;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
    
            root   html;
        }
    }
	

4、 Save and run nginx.exe That is to say http://localhost:9696/api/xxx, This request is automatically assigned to the previously opened port number 9697、9698 On top of the application ;

版权声明
本文为[Three stone orders]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204200615437154.html