mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-27 23:11:39 +01:00
fa9748cc99
4536: Limit concurrent search requests r=ManyTheFish a=irevoire # Pull Request ## Related issue Fixes https://github.com/meilisearch/meilisearch/issues/4489 ## What does this PR do? - Adds a « search queue » that limits the number of search requests we can process at the same time and stores search requests to be processed - Process only one search request per core/thread (we use available_parallelism) - When the search queue is full, new search requests replace old ones **randomly**. The reason is that: - If we serve the oldest one first, like Typesense, we give the worst performances to everyone - If we serve the latest one, it gets too easy to DoS us (you just need to fill the queue with as many search requests as we can process simultaneously to ensure no other request will ever be processed) - By picking the search request randomly, we give a chance to recent search requests to be processed while ensuring that we can't be owned unless they fill our queue entirely and we start returning errors 5xx - Adds an experimental parameter to control the size of the queue - Adds a bunch of tests to ensure the search queue works correctly - Ensure the loop consuming the search queue is running in the health route and crashes if it’s not the case Co-authored-by: Tamo <tamo@meilisearch.com>