1

When clients makes certain requests, our service sends aggregation queries to Mongo. Some of these aggregations take longer than others.

Usually this is fine, but occasionally multiple heavy aggregations will be requested at the same time. In the worst case, this causes Mongo to become unresponsive, and other requests (such as inserting new documents) fail with a timeout.

Is there any way I can limit the number of aggregations that Mongo will perform in parallel?

Ideally if 8 aggregations are running and a new aggregation request is made, Mongo would queue the new aggregation until one of the others has completed.

1 Answer 1

2

Answer is simple, NO. Not in mongodb. But you can always do it in your own application. Just create "lock" collection where applications mark they will to do aggregation. Ticket system for queuing.

1
  • Thanks. I was concerned that might be the only solution. We actually have three or four servers connected to the database, some of them headless (processing statistics on a schedule). I would either need to set the limits low for all servers (to guarantee the overall target limit), or have a gatekeeper that they must all go through when they want to make an aggregation! Anyway I may be able to find the middle ground (a low limit but only on those aggregations that are known to be heavy). Jun 30, 2017 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.