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

Extract inline vars from the status handler #93

Merged
merged 1 commit into from
Nov 11, 2022
Merged

Conversation

mccutchen
Copy link
Owner

This is getting a bit into micro-optimization territory, but in the course of working on a bit of cleanup I realized there might be something to gain from making the /status endpoint a bit more efficient by initializing all the data it needs once instead of on every request.

Results, from a set of highly unscientific vegeta benchmark runs on my laptop (3x per version):

before

$ echo "GET http://localhost:8080/status/200" | vegeta attack -rate 0 -max-workers 100 -duration 30s | vegeta report
Requests      [total, rate, throughput]         599239, 19973.51, 19971.04
Duration      [total, attack, wait]             30.005s, 30.002s, 3.711ms
Latencies     [min, mean, 50, 90, 95, 99, max]  100.397µs, 3.434ms, 2.52ms, 7.487ms, 9.388ms, 14.141ms, 35.997ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:599239  
Error Set:

$ echo "GET http://localhost:8080/status/200" | vegeta attack -rate 0 -max-workers 100 -duration 30s | vegeta report
Requests      [total, rate, throughput]         583561, 19451.76, 19449.88
Duration      [total, attack, wait]             30.003s, 30s, 2.905ms
Latencies     [min, mean, 50, 90, 95, 99, max]  90.632µs, 3.596ms, 2.634ms, 7.81ms, 9.657ms, 14.375ms, 71.383ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:583561  
Error Set:

$ echo "GET http://localhost:8080/status/200" | vegeta attack -rate 0 -max-workers 100 -duration 30s | vegeta report
Requests      [total, rate, throughput]         583978, 19466.01, 19463.01
Duration      [total, attack, wait]             30.005s, 30s, 4.622ms
Latencies     [min, mean, 50, 90, 95, 99, max]  99.886µs, 3.578ms, 2.633ms, 7.769ms, 9.727ms, 14.462ms, 46.364ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:583978  
Error Set:

after

$ echo "GET http://localhost:8080/status/200" | vegeta attack -rate 0 -max-workers 100 -duration 30s | vegeta report
Requests      [total, rate, throughput]         674351, 22478.36, 22476.29
Duration      [total, attack, wait]             30.003s, 30s, 2.765ms
Latencies     [min, mean, 50, 90, 95, 99, max]  88.928µs, 2.487ms, 1.823ms, 5.248ms, 6.888ms, 10.986ms, 57.678ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:674351  
Error Set:

$ echo "GET http://localhost:8080/status/200" | vegeta attack -rate 0 -max-workers 100 -duration 30s | vegeta report
Requests      [total, rate, throughput]         664761, 22158.67, 22156.44
Duration      [total, attack, wait]             30.003s, 30s, 3.018ms
Latencies     [min, mean, 50, 90, 95, 99, max]  84.192µs, 2.576ms, 1.904ms, 5.464ms, 7.031ms, 10.955ms, 46.036ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:664761  
Error Set:

$ echo "GET http://localhost:8080/status/200" | vegeta attack -rate 0 -max-workers 100 -duration 30s | vegeta report
Requests      [total, rate, throughput]         668110, 22267.73, 22267.02
Duration      [total, attack, wait]             30.004s, 30.004s, 962.405µs
Latencies     [min, mean, 50, 90, 95, 99, max]  82.35µs, 2.533ms, 1.844ms, 5.384ms, 7.007ms, 11.363ms, 47.509ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:668110  
Error Set:

That's a decent uptick in request rate and throughput and a decent drop in latency percentiles.

@mccutchen mccutchen merged commit bd122ea into main Nov 11, 2022
@mccutchen mccutchen deleted the status-cleanup branch November 11, 2022 01:29
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

Successfully merging this pull request may close these issues.

1 participant