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

[DVT-604] add adaptive rate limiting feature #60

Merged
merged 7 commits into from
Apr 4, 2023

Conversation

rebelArtists
Copy link
Contributor

@rebelArtists rebelArtists commented Apr 3, 2023

Description

adds dynamic rate limiting in the AIMD fashion. more specifically, we periodically query the rpc tx_pool status to gauge whether we should increase or back off our loadtest request rate.

Jira / Linear Tickets

https://polygon.atlassian.net/browse/DVT-604

Testing

successfully builds and running against dev geth locally via following cmd:
`polycli loadtest --verbosity 700 --chain-id 1337 --concurrency 1 --requests 2000 --adaptive-rate-limit=true --steady-state-tx-pool-size 100 --adaptive-rate-limit-start 5 --adaptive-rate-limit-increment 10 --adaptive-cycle-duration-seconds 20 --mode t http://127.0.0.1:8545

log sample results:

1:54PM DBG Starting main loadtest loop currentNonce=6476
1:54PM TRC Request mode=t nonce=6476 request=0 routine=0
...
1:55PM TRC Request mode=t nonce=6576 request=100 routine=0
1:55PM TRC Increased rate limit Current Tx Pool Size=20 New Rate Limit (RPS)=15 Steady State Tx Pool Size=100
1:55PM TRC Request mode=t nonce=6577 request=101 routine=0
...
1:55PM TRC Request mode=t nonce=6874 request=398 routine=0
1:55PM TRC Increased rate limit Current Tx Pool Size=59 New Rate Limit (RPS)=25 Steady State Tx Pool Size=100
1:55PM TRC Request mode=t nonce=6875 request=399 routine=0
...
1:55PM TRC Request mode=t nonce=7374 request=898 routine=0
1:55PM TRC Increased rate limit Current Tx Pool Size=99 New Rate Limit (RPS)=35 Steady State Tx Pool Size=100
1:55PM TRC Request mode=t nonce=7375 request=899 routine=0
...
1:56PM TRC Request mode=t nonce=8074 request=1598 routine=0
1:56PM TRC Backed off rate limit Current Tx Pool Size=138 New rate limit=17.5 Steady State Tx Pool Size=100
1:56PM TRC Request mode=t nonce=8075 request=1599 routine=0
...
1:56PM TRC Request mode=t nonce=8424 request=1948 routine=0
1:56PM TRC Increased rate limit Current Tx Pool Size=69 New Rate Limit (RPS)=27.5 Steady State Tx Pool Size=100
1:56PM TRC Request mode=t nonce=8425 request=1949 routine=0
...
1:56PM INF rough test summary (ignores errors) final rate limit=27.5 firstBlockTime=2023-04-04T13:54:54-05:00 lastBlockTime=2023-04-04T13:56:42-05:00 testDuration=108 tps=18.51851851851852 transactionCount=2000

@rebelArtists rebelArtists changed the title [WIP] loadtest adaptive rate limiting add adaptive rate limiting feature Apr 4, 2023
@rebelArtists rebelArtists changed the title add adaptive rate limiting feature [DVT-604] add adaptive rate limiting feature Apr 4, 2023
@rebelArtists rebelArtists marked this pull request as ready for review April 4, 2023 19:08

rl := rate.NewLimiter(rate.Limit(*ltp.RateLimit), 1)
if *ltp.RateLimit <= 0.0 {
if *ltp.AdaptiveRateLimit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor

@gatsbyz gatsbyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks gucci

Copy link
Member

@praetoriansentry praetoriansentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - happy to try this out today. Some minor changes might be worth while as noted.

cmd/loadtest/loadtest.go Outdated Show resolved Hide resolved
cmd/loadtest/loadtest.go Outdated Show resolved Hide resolved
cmd/loadtest/loadtest.go Show resolved Hide resolved
@rebelArtists rebelArtists merged commit 903cdf5 into main Apr 4, 2023
@gatsbyz gatsbyz deleted the dan/aimd_rate_limiting branch June 30, 2023 14:22
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.

3 participants