Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

choose fair peer busy and idle #9

Closed
haonhien opened this issue Apr 7, 2012 · 1 comment
Closed

choose fair peer busy and idle #9

haonhien opened this issue Apr 7, 2012 · 1 comment

Comments

@haonhien
Copy link

haonhien commented Apr 7, 2012

2 ways to choose a best peer, but I'm having some problems as my peer connection was full due to slow response time, so I have some idea, is to choose the best peer-based on two factors:

  • response time of peer, if the peer does have the fastest response time, then select the best peer.
  • The number of error messages returned (400,404,500). If any peer returns an error message at least choose the best peer.

Plase. help me.
If possible, please guide me how to write ideas on.

@gnosek
Copy link
Owner

gnosek commented Apr 8, 2012

Peer scoring is done in ngx_http_upstream_fair_sched_score():

https://github.com/gnosek/nginx-upstream-fair/blob/master/ngx_http_upstream_fair_module.c#L688

Write your logic there, though you'll probably need to adapt ngx_http_upstream_get_fair_peer() and ngx_http_upstream_free_fair_peer() to collect relevant statistics. You'll probably want an exponential weighted moving average to store the response time with low overhead and something similar that gives less weight to old data for the error counter so that a backend having issues in the past isn't penalised too much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants