Sharing static global data among processes in a Gunicorn / Flask app Sharing static global data among processes in a Gunicorn / Flask app flask flask

Sharing static global data among processes in a Gunicorn / Flask app


Memory mapped files will allow you to share pages between processes.

https://docs.python.org/2/library/mmap.html

Note that memory consumption statistics are usually misleading and unhelpful. It is usually better to consider the output of vmstat and see if you are swapping a lot.


Assuming your priority is to keep the data as a Python data structure instead of moving it to a database such as Redis, then you'll have to change things so that you can use a single process for your server.

Gunicorn can work with gevent to create a server that can support multiple clients within a single worker process using coroutines, that could be a good option for your needs.