motiv-labs / janus

An API Gateway written in Go
https://hellofresh.gitbooks.io/janus
MIT License
2.78k stars 318 forks source link

Skip upstream election logic if there is only one possible host #389

Closed s4nji closed 5 years ago

s4nji commented 5 years ago

Simply return an upstream host if there is only one possible host.

A quick simple proxying benchmark with only one upstream host using round-robin and 50 concurrent requests shows a ±10% speedup (4500rps » 5000 rps) and eliminates a small number of responses with status code 500 presumably due to mutexes used on round robin-election strategy.

codecov[bot] commented 5 years ago

Codecov Report

Merging #389 into master will decrease coverage by 0.06%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #389      +/-   ##
==========================================
- Coverage   40.32%   40.25%   -0.07%     
==========================================
  Files          75       75              
  Lines        2624     2628       +4     
==========================================
  Hits         1058     1058              
- Misses       1506     1508       +2     
- Partials       60       62       +2
Impacted Files Coverage Δ
pkg/proxy/balancer/rr.go 85.71% <0%> (-14.29%) :arrow_down:
pkg/proxy/balancer/weight.go 85% <0%> (-9.45%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c5972df...b4c55a5. Read the comment docs.