TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Worker queue with multi-dimensional rate limiting

2 pointsby mgliwkaover 6 years ago
I want to distribute tasks to worker nodes using a queue. The work depends on external resources.<p>The access to those needs to be rate limited across multiple dimensions (i.e. customer id, city, phone provider, there may be only 1 per customer id &#x2F; second, 1000&#x2F;city second and 20 &#x2F; phone provider&#x2F;second). The rate limit needs to apply to all worker nodes. My worker nodes share the same network.<p>How can I achieve that while maintaining a reasonable throughput? Any experience?<p>My naive attempt would be to use one leaky bucket per dimension implemented in Redis and check those prior accessing the resource. If there&#x27;s no token in all the necessary buckets available, I would put the request back at the end of the queue.<p>Are there better ways to implement this?

2 comments

hguhghuffover 6 years ago
I’d do it in Postgres and use sql columns for all your qualifiers.<p>Refer SKIP LOCKED
brudgersover 6 years ago
What <i>business</i> problem are you trying to solve?