Reputation: 4761
We were considering cloudant for our next (nodejs based) project as the backend and even the standard plan offers only 5 queries per second. How can I limit the queries to the database so that the queries per second always stays below 5 ?
Upvotes: 0
Views: 212
Reputation: 5637
That is up to you. I wrote a blog post that shows how you can use a rate-limited queue to prevent an app accessing an API service too quickly. Essentially it uses an in-memory queue that is only consumed at a preset rate.
This becomes much harder to control if you have a distributed system (say three application servers).
Another technique is to detect Cloudant's "429" response code and retry the query. The Cloudant Node.js library has a "retry plugin" that will do this for you.
Upvotes: 1