can anyone explain to me in detail how the rate limit works? I Am using node red to create 9000 workitems as fast as possible and run into this error, i could just raise any number related to that but would rather understand how this system works exactly.
But reading it, I feel it deserves more details, I will add those tomorrow.
Just know api_rate is for website assets and the openapi interface. Once a connection is open using gRPC/websocket, it is the socket_rate ones that are used.
We use Express as a web server, and for all requests, we start by checking if you hit the rate limit. We do this by IP. Not ideal, but better than nothing. Every time you make a request, you use a point. If you use more than 1000 points (api_rate_limit_points) within one second (api_rate_limit_duration), the request is discarded with an HTTP code 429.
All client SDKs create a connection to OpenCore and keep it alive. For every connection, we also create two rate limiters, so this one is “per person”/per connection. Again, for every command you send, you use one point, and if you use more than 1000 points (socket_rate_limit_points) within a second (socket_rate_limit_duration), you will receive an error for the command. If you keep sending messages despite the errors and you reach 1600 points (socket_rate_limit_points_disconnect), the connection gets disconnected. For the other limiter, you receive a point for every error you receive; if you get more than 30 errors (socket_error_rate_limit_points) within a second (socket_error_rate_limit_duration), the connection gets disconnected.
it’s not using a sliding window, so you cannot do 500, wait up to 1 sec and then do 500 again,
also, this is why we have push workitems, to push multiple at the time .. why not batch it using that ?
Ahh… The protocol supports doing multiples, so pushworkitems is not calling pushworkitem multiple times. It’s a command for doing multiple in one go. This is faster because we do not have a round trip for each item, and it only counts for one point in the rate limiter since you only executed one command.
this is the same for InsertMany, UpdateMany and InsertOrUpdateMany