×ðÁú¿­Ê±¹ÙÍøµÇ¼

Nginx¸ºÔØƽºâ¶àÖÖÕ½ÂÔÉèÖã¬ÓÅ»¯ÍøÕ¾ÐÔÄÜ

nginx¸ºÔØƽºâ¶àÖÖÕ½ÂÔÉèÖã¬ÓÅ»¯ÍøÕ¾ÐÔÄÜ

¸ÅÊö£º

Ëæ×Å»¥ÁªÍøµÄѸÃÍÉú³¤£¬ÍøÕ¾µÄ»á¼ûÁ¿Ò²Ô½À´Ô½´ó¡£ÎªÁËÖª×ãÓû§µÄÐèÇó£¬Ìá¸ßÍøÕ¾µÄ¿ÉÓÃÐÔºÍÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔʹÓøºÔØƽºâÀ´·Öµ£Ð§ÀÍÆ÷µÄ¸ºÔØѹÁ¦¡£NginxÊÇÒ»¸ö¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷£¬ËüÌṩÁ˶àÖÖ¸ºÔØƽºâÕ½ÂÔ¹©ÎÒÃÇÑ¡Ôñ£¬±¾ÎĽ«ÏÈÈÝNginx¸ºÔØƽºâµÄ¼¸ÖÖÕ½ÂÔÉèÖ㬲¢¸½´ø´úÂëʾÀý¡£

ÂÖѯ£¨Round Robin£©Õ½ÂÔ£º

ÂÖѯÊÇ×î³£¼ûµÄ¸ºÔØƽºâÕ½ÂÔÖ®Ò»£¬Ò²ÊÇNginxµÄĬÈÏÕ½ÂÔ¡£Ëü½«ÇëÇóƽºâµØ·Ö·¢µ½ºó¶ËµÄ¶à¸öЧÀÍÆ÷ÉÏ£¬Ã¿¸öÇëÇó°´Ë³ÐòÒÀ´Î·Ö·¢µ½²î±ðµÄЧÀÍÆ÷ÉÏ¡£µ±ÓÐЧÀÍÆ÷å´»úʱ£¬Nginx»á×Ô¶¯½«Æäɨ³ýÔÚ¸ºÔØƽºâµÄ¹æÄ£Íâ¡£ÂÖѯսÂÔµÄNginxÉèÖÃÈçÏ£º

http {
    upstream backend {
        server 192.168.1.1;
        server 192.168.1.2;
        server 192.168.1.3;
    }
    
    server {
        listen       80;
        server_name  example.com;
        
        location / {
            proxy_pass http://backend;
        }
    }
}

µÇ¼ºó¸´ÖÆ

×îÉÙÅþÁ¬£¨Least Connections£©Õ½ÂÔ£º

×îÉÙÅþÁ¬Õ½ÂԻὫÇëÇó·¢Ë͵½Ä¿½ñÅþÁ¬Êý×îÉÙµÄЧÀÍÆ÷ÉÏ£¬ÒÔʵÏÖ¸ºÔØƽºâ¡£ÕâÑù¿ÉÒÔÈ·±£Ã¿¸öЧÀÍÆ÷ÉϵÄÅþÁ¬ÊýÏà¶Ôƽºâ£¬×èֹij¸öЧÀÍÆ÷±»Ì«¹ýѹÁ¦¡£NginxÌṩÁËÒ»¸öÄ£¿éleast_connÀ´ÊµÏÖ×îÉÙÅþÁ¬Õ½ÂÔ¡£ÉèÖÃÒªÁìÈçÏ£º

http {
    upstream backend {
        least_conn;
        server 192.168.1.1;
        server 192.168.1.2;
        server 192.168.1.3;
    }
    
    server {
        listen       80;
        server_name  example.com;
        
        location / {
            proxy_pass http://backend;
        }
    }
}

µÇ¼ºó¸´ÖÆ

IP¹þÏ££¨IP Hash£©Õ½ÂÔ£º

IP¹þÏ£Õ½ÂÔ»áƾ֤¿Í»§¶ËµÄIPµØµã½«ÇëÇó·Ö·¢µ½ºó¶ËЧÀÍÆ÷ÉÏ¡£ÕâÑù¿ÉÒÔÈ·±£Í³Ò»¸ö¿Í»§¶ËµÄÇëÇ󶼻ᱻ·¢Ë͵½Í³Ò»¸öºó¶ËЧÀÍÆ÷ÉÏ£¬Ìá¸ß»º´æµÄЧ¹û¡£NginxÌṩÁËÒ»¸öÄ£¿éip_hashÀ´ÊµÏÖIP¹þÏ£Õ½ÂÔ¡£ÉèÖÃÒªÁìÈçÏ£º

http {
    upstream backend {
        ip_hash;
        server 192.168.1.1;
        server 192.168.1.2;
        server 192.168.1.3;
    }
    
    server {
        listen       80;
        server_name  example.com;
        
        location / {
            proxy_pass http://backend;
        }
    }
}

µÇ¼ºó¸´ÖÆ

¼ÓȨÂÖѯ£¨Weighted Round Robin£©Õ½ÂÔ£º

¼ÓȨÂÖѯսÂÔÔÊÐí¸ø²î±ðµÄЧÀÍÆ÷ÉèÖòî±ðµÄȨÖØ£¬Ð§ÀÍÆ÷µÄȨÖØÔ½¸ß£¬±»Ñ¡ÖеĸÅÂʾÍÔ½´ó¡£ÕâÑù¿ÉÒÔÓÐÓõطÖÅÉЧÀÍÆ÷µÄ¸ºÔØѹÁ¦¡£NginxµÄÉèÖÃÒªÁìÈçÏ£º

http {
    upstream backend {
        server 192.168.1.1 weight=3;
        server 192.168.1.2 weight=2;
        server 192.168.1.3 weight=1;
    }
    
    server {
        listen       80;
        server_name  example.com;
        
        location / {
            proxy_pass http://backend;
        }
    }
}

µÇ¼ºó¸´ÖÆ

×ܽ᣺

ͨ¹ýºÏÀíÑ¡ÔñºÍÉèÖøºÔØƽºâÕ½ÂÔ£¬ÎÒÃÇ¿ÉÒÔÓÅ»¯ÍøÕ¾µÄÐÔÄÜ£¬Ìá¸ßÓû§µÄ»á¼ûÌåÑé¡£Nginx×÷Ϊһ¸ö¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷£¬ÌṩÁ˶àÖÖ¸ºÔØƽºâÕ½ÂÔ¹©ÎÒÃÇÑ¡Ôñ¡£±¾ÎÄÏÈÈÝÁËÂÖѯ¡¢×îÉÙÅþÁ¬¡¢IP¹þÏ£ºÍ¼ÓȨÂÖѯÕ⼸ÖÖ³£ÓõÄÕ½ÂÔ£¬²¢ÌṩÁËÏìÓ¦µÄNginxÉèÖÃʾÀý¡£Ï£Íû±¾ÎÄÄܶԸ÷ÈËѧϰºÍÊÂÇéÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇNginx¸ºÔØƽºâ¶àÖÖÕ½ÂÔÉèÖã¬ÓÅ»¯ÍøÕ¾ÐÔÄܵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ