Feature: add gunicorn based deployment#39
Merged
danielplohmann merged 1 commit intodanielplohmann:mainfrom Sep 12, 2023
Merged
Conversation
Owner
|
Funny story, a very early version of MCRIT already used gunicorn as WSGI server. :) Your solution is elegant, I didn't know you could run gunicorn similarly directly from within Python! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a gunicorn based deployment of the falcon app for linux based servers specifically. This takes into assumption that if someone were to deploy mcrit on a production environment, it would probably be a large one that would require robustness from the server.
Case study
Our mcrit deployment is based on AWS linux servers. We needed a way to index many files quick (we're talking about 100k in a reasonable amount of time). With waitress' single-worker design, even scaling to 50 worker threads would eventually break. We noticed that over long periods of time, the server RAM usage just started to increase as if there's some memory leak. After further inspection, we got to the conclusion this is not a memory leak, but rather the server getting more requests than it can handle and queuing them up.
Using different optimizations (using a CPU oriented machine, etc...) we got to 4000 file submits / hour with drops to ~3000 after some time, and a large RAM usage that eventually kills the mcrit server (docker out-of-memory protection). Switching to gunicorn's worker model and using 8 worker processes with 10 threads in each we got to a steady 9000 submits/hour and a lower memory usage. It actually stabilized at around 22gb and didn't really creep up.
Additional info
This PR was made with docker-mcrit in mind. Since I don't want to also update it every time this project changes I made the changes here transparent to it, it just calls "mcrit server" and it should work as before.
Also, profiling mode for the server isn't really working. I added a requirement to the requirements to fix that.