I need to implement some rate-limiting on my activities.
Ideally, I don’t want to gimp my entire workflow (using setMaxWorkerActivitiesPerSecond() for example)
because I only want to limit the activities that have outgoing HTTP requests.
My ideal solution would be that defining the maximum concurrent activities per activity class, but I can’t seem to find anything like this. What should be done in this case?
I assume the easiest way to achieve what I need is to have a separate task queue for the activities and assign the rate limit for that task queue, but since different APIs have different rate limits that would mean I need to make new task queues per API which is not a path I will willingly go down as this will need some more development and I need a quick solution.
Each workflow has its own worker, which registers its own activities (so the shared activities are defined twice, in two different workers)
What I’ve tried is moving all the activities that I need to ratelimit into their own Worker, on a completely new task queue. This new worker does not register Workflow implementations, only activity implementations. This led to the workflow being unable to start the activity as “it is not registered with any worker”.
I also tried registering the workflow type in the new workers, but it seems this overrides the activities registered with the other worker. What am I missing here?
Ah, apologies. I’ve tried that and the errors are gone, however for testing I set the max to 0.1 which according to the docs specifies that we want 1 run every 10 seconds and ran 3 workflows, and the activities on the task queue seemed to be operating at normal speed.
The 0.1 was just for me to check if the rate limiter actually works before I deploy it to production. My actual limits will be 4 limits (depending on the target project) that will range from 120 to 600.
Well, I suppose worst case scenario is the same behaviour anyway. After migrating to AWS from GCP it seems that our workflows are running faster, which resulted in my project getting rate limited quite often by our other internal assets. This must work as there is no other way for me to rate-limit my outgoing http requests.
I tried to do the same by providing a task queue for workflow and another task queue for the activity i wanted to rate limit. I ensured i gave the right task queue in workflow options and activity options.
However i observed that the rate limits are not honoured.
Is the rate limit on the task queue or the task queue partition? Because i was able to see 3 tasks submitted even though i gave the max activities per task queue as 1 for the activity worker.
What is the rate limit algorithm? Didn’t seem to be sliding window but something like token bucket.