Load balancing with node.js using http-proxy

前端 未结 1 986
予麋鹿
予麋鹿 2020-12-16 01:57

I\'m trying to code a loadbalancing with node.js and http-proxy. I want a loadBalancer which share incoming request treatment between 2 servers.

var http = r         


        
相关标签:
1条回答
  • 2020-12-16 02:21

    That should be doing a round robin as you requested, however it's a very naive round robin. What you may be seeing is that your favicon.ico requests are putting a higher than normal share of requests on a single server. For instance.

    Server 1: Actual Requests
    Server 2: favicon.ico
    Server 1: Another Request
    Server 2: favicon.ico
    Server 1: Final Request
    Server 2: favicon.ico
    

    So depending on how you're logging, it will appear that server 1 is getting all of the requests, when technically each server is getting the same number of requests. Also keep in mind that your assets will be included in the round robin as well if you're serving them from node. So each image or file request will also be handed off to a different node instance.

    0 讨论(0)
提交回复
热议问题