#leaky bucket

1 messages · Page 1 of 1 (latest)

long jolt
#

might be cool if you supported a leaky bucket system

long jolt
#

The leaky bucket is an algorithm based on an analogy of how a bucket with a constant leak will overflow if either the average rate at which water is poured in exceeds the rate at which the bucket leaks or if more water than the capacity of the bucket is poured in all at once. It can be used to determine whether some sequence of discrete events c...

wraith shoal
#

oh, like a queue with a size?
iirc nginx works like that.
sounds great, ill implement it when I find a use for it.

#

I made this netlimiter for my chat-app, based on how discord works with rate limits.
POST /channels/CHANNEL_ID/messages allows 5 requests per 5 seconds

#

i think i can use a leaky bucket alg for my web-lit (luvit) web-apps, if it is not already implemented under the hood

#

is nodejs express has leaky-bucket implementation under the hood? web-lit uses the same deps, so if express has it - weblit should too.

wraith shoal
long jolt
wraith shoal
#

are you create a bucket for every player?

long jolt
#

yeah

#

an example would be, allow the player to change/update a setting

#

idk lets say it's something like a large json net message that does some expensive server code

#

only allow 1 request every second with a bucket of 5

#

basically removes any risk of spam prevention and makes it feel a lot more organic for the user when they want to quickly apply settings to test something

wraith shoal
long jolt
#

could be both

wraith shoal
#

what constants did you used for global net spam protection?

long jolt
#

lemme get the code, i didn't make it tho

#

a good friend of mine did

#

iirc this uses a leakybucket

#

leaky bucket is great for preventing exploits in public addons, there's plenty of wiremod entities that are vurnable to just hard spamming their actions which can cause stuff ranging from lag to source engine issues

wraith shoal
#

oh okey - it does not use net message length

#

it just counts requests

long jolt
#

yeah, lenght is rarely the issue

#

the main issue is addons doing expensive stuff on net.Receive

#

and then spam taking advantage of it

wraith shoal
long jolt
#

entirely depends on what an addon does with the data

wraith shoal
#

isnt the advantage of a leaking bucket in the ability to be based on length?

long jolt
#

yeah, but many small ones can cause major damage

wraith shoal
#

I think that the previous algorithm is not worse than the leaking bucket when it comes to the usual counting number of calls.

long jolt
#

a while ago i found a net message that can crash servers with ~100 requests in a tick which was simply just a net.WriteBool

#

yeah, it depends

#

leakybucket feels very organic usually so its best for stuff players directly interact with

#

but that's subjective