Does using multiple processes for a python app use memory sharing? #1243
-
I know that for uwsgi, according to docs:
Does NGINX Unit do something similar? If I set |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
In short yes. Lets look at a Unit process tree comprising unit and 5 python application processes...
You'll notice we create a "prototype" process, we do that for each application (regardless of language), from there we fork the prescribed number of "application" processes. You can see that the application processes are children of the prototype process. Prototype processes were added in e207415 Applications processes may come and go but the prototype process will live for the duration of the application. |
Beta Was this translation helpful? Give feedback.
Thanks for the link to the video. That made me dig a little deeper.
My answer here may change slightly what you take away from my original answer.
Now gc.freeze is some Python API and obviously when we do the fork(2) we are still in C, but that is all moot anyway...
The prototype processes only load the required Unit language module, e.g for python
$(modulesdir}/python.unit.so
, which in turn loads the required libraries for that language. e.g the python prototype process loads these (the PHP language module loads a lot more things...)