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

txHandler: applications rate limiter #5734

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
698221f
txHandler: sliding windows rate limiter
algorandskiy Sep 11, 2023
b780eb2
Add remote IP addr to app idx filtering
algorandskiy Sep 11, 2023
4227408
More tests + linter fixes
algorandskiy Sep 12, 2023
d912853
remove some code duplication
algorandskiy Sep 12, 2023
a142581
Shards per app
algorandskiy Sep 12, 2023
ad931f6
make interval atomic
algorandskiy Sep 12, 2023
21722be
move rate limiter configuration into local config + test
algorandskiy Sep 13, 2023
43ea42e
Fix max size checks for buckets
algorandskiy Sep 14, 2023
39ec627
Add salt to prevent censoring with reduced key size to 8 bytes
algorandskiy Sep 14, 2023
785a229
go benchmarks
algorandskiy Sep 14, 2023
e05d839
Implement LRU eviction
algorandskiy Sep 15, 2023
17127ac
Fix cache size less than number of buckets
algorandskiy Sep 18, 2023
c7e7d0b
Add app limter drop counter
algorandskiy Sep 20, 2023
c30298b
CR fixes
algorandskiy Sep 20, 2023
f5fabd5
Use admission rate instead attempted rate
algorandskiy Sep 20, 2023
7b7d4f6
Revert "Use admission rate instead attempted rate"
algorandskiy Sep 20, 2023
8902be4
Reimplement cache admission
algorandskiy Sep 20, 2023
e5c98d5
CR fixes: config rename, buckets restructure
algorandskiy Sep 22, 2023
70a6ba4
CR: use part of ipv6 address
algorandskiy Sep 22, 2023
a53c07a
start app rate limiting only of congested
algorandskiy Sep 22, 2023
612156a
use rawmsg.Received timestamp for testability and cut some ns of math
algorandskiy Sep 25, 2023
61e0264
use sync.Pool for keys and buckets
algorandskiy Sep 26, 2023
1a00cf4
set TxBacklogAppTxPerSecondRate=100
algorandskiy Sep 26, 2023
3459298
CR fixes
algorandskiy Sep 27, 2023
1e9b73d
perf: upgrade go-deadlock
algorandskiy Sep 27, 2023
d83565b
CR: do not use rawmsg.Received for limiting
algorandskiy Sep 29, 2023
ab25e9b
Merge remote-tracking branch 'upstream/master' into pavel/txhandler-a…
algorandskiy Oct 31, 2023
7d32f6e
config: migrate to v32
algorandskiy Oct 31, 2023
a66abbf
CR: enable app limiter separately with EnableAppTxBacklogRateLimiting
algorandskiy Nov 3, 2023
4ede214
wip: txgroupToKeysDups
algorandskiy Nov 7, 2023
5fc75b6
CR: dedup appids and zeros
algorandskiy Nov 8, 2023
8c4c28b
marginally optimize txnToDigest a bit
algorandskiy Nov 8, 2023
eb977e2
CR: config renaming/comment fix
algorandskiy Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ var StateProofTopVoters int
// in a block must not exceed MaxTxnBytesPerBlock.
var MaxTxnBytesPerBlock int

// MaxAppTxnForeignApps is the max number of foreign apps per txn across all consensus versions
var MaxAppTxnForeignApps int

func checkSetMax(value int, curMax *int) {
if value > *curMax {
*curMax = value
Expand Down Expand Up @@ -681,6 +684,8 @@ func checkSetAllocBounds(p ConsensusParams) {
checkSetMax(p.MaxAppKeyLen, &MaxAppBytesKeyLen)
checkSetMax(int(p.StateProofTopVoters), &StateProofTopVoters)
checkSetMax(p.MaxTxnBytesPerBlock, &MaxTxnBytesPerBlock)

checkSetMax(p.MaxAppTxnForeignApps, &MaxAppTxnForeignApps)
}

// SaveConfigurableConsensus saves the configurable protocols file to the provided data directory.
Expand Down
18 changes: 16 additions & 2 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Local struct {
// Version tracks the current version of the defaults so we can migrate old -> new
// This is specifically important whenever we decide to change the default value
// for an existing parameter. This field tag must be updated any time we add a new version.
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27" version[28]:"28" version[29]:"29" version[30]:"30" version[31]:"31"`
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27" version[28]:"28" version[29]:"29" version[30]:"30" version[31]:"31" version[32]:"32"`

// Archival nodes retain a full copy of the block history. Non-Archival nodes will delete old blocks and only retain what's need to properly validate blockchain messages (the precise number of recent blocks depends on the consensus parameters. Currently the last 1321 blocks are required). This means that non-Archival nodes require significantly less storage than Archival nodes. Relays (nodes with a valid NetAddress) are always Archival, regardless of this setting. This may change in the future. If setting this to true for the first time, the existing ledger may need to be deleted to get the historical values stored as the setting only effects current blocks forward. To do this, shutdown the node and delete all .sqlite files within the data/testnet-version directory, except the crash.sqlite file. Restart the node and wait for the node to sync.
Archival bool `version[0]:"false"`
Expand Down Expand Up @@ -231,7 +231,21 @@ type Local struct {
// TxBacklogReservedCapacityPerPeer determines how much dedicated serving capacity the TxBacklog gives each peer
TxBacklogReservedCapacityPerPeer int `version[27]:"20"`

// EnableTxBacklogRateLimiting controls if a rate limiter and congestion manager shouild be attached to the tx backlog enqueue process
// TxBacklogAppTxRateLimiterMaxSize denotes a max size for the tx rate limiter
// calculated as "a thousand apps on a network of thousand of peers"
TxBacklogAppTxRateLimiterMaxSize int `version[32]:"1048576"`
gmalouf marked this conversation as resolved.
Show resolved Hide resolved

// TxBacklogAppTxPerSecondRate determines a target app per second rate for the app tx rate limiter
TxBacklogAppTxPerSecondRate int `version[32]:"100"`

// TxBacklogRateLimitingCongestionRatio determines the backlog filling threshold percentage at which the app limiter kicks in
// or the tx backlog rate limiter kicks off.
TxBacklogRateLimitingCongestionPct int `version[32]:"50"`

// EnableTxBacklogAppRateLimiting controls if an app rate limiter should be attached to the tx backlog enqueue process
EnableTxBacklogAppRateLimiting bool `version[32]:"true"`

// EnableTxBacklogRateLimiting controls if a rate limiter and congestion manager should be attached to the tx backlog enqueue process
// if enabled, the over-all TXBacklog Size will be larger by MAX_PEERS*TxBacklogReservedCapacityPerPeer
EnableTxBacklogRateLimiting bool `version[27]:"false" version[30]:"true"`

Expand Down
6 changes: 5 additions & 1 deletion config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package config

var defaultLocal = Local{
Version: 31,
Version: 32,
AccountUpdatesStatsInterval: 5000000000,
AccountsRebuildSynchronousMode: 1,
AgreementIncomingBundlesQueueLength: 15,
Expand Down Expand Up @@ -81,6 +81,7 @@ var defaultLocal = Local{
EnableRequestLogger: false,
EnableRuntimeMetrics: false,
EnableTopAccountsReporting: false,
EnableTxBacklogAppRateLimiting: true,
EnableTxBacklogRateLimiting: true,
EnableTxnEvalTracer: false,
EnableUsageLog: false,
Expand Down Expand Up @@ -141,6 +142,9 @@ var defaultLocal = Local{
TrackerDBDir: "",
TransactionSyncDataExchangeRate: 0,
TransactionSyncSignificantMessageThreshold: 0,
TxBacklogAppTxPerSecondRate: 100,
TxBacklogAppTxRateLimiterMaxSize: 1048576,
TxBacklogRateLimitingCongestionPct: 50,
TxBacklogReservedCapacityPerPeer: 20,
TxBacklogServiceRateWindowSeconds: 10,
TxBacklogSize: 26000,
Expand Down
Loading