I have a Flask app, served by Nginx and Gunicorn with 3 workers. My Flask app is a API microservice designed for doing NLP stuff and I am using the spaCy library for it.
My problem is that they are taking huge number of RAM as loading the spaCy pipeline spacy.load('en')
is very memory-intensive and since I have 3 gunicorn workers, each will take about 400MB of RAM.
My question is, is there a way to load the pipeline once and share it across all my gunicorn workers?
preload_app
of gunicorn. see https://mcmap.net/q/49124/-sharing-memory-in-gunicorn – Lucianolucias