Replies: 5 comments 1 reply
-
We use redis as the caching layer for being able to share it across |
Beta Was this translation helpful? Give feedback.
-
Use an external store. Gunicorn workers are designed to share nothing. |
Beta Was this translation helpful? Give feedback.
-
In the field of machine learning, it is necessary to share a few hundred megabytes of objects, and then provide prediction functions through the interface, is there any good solution? |
Beta Was this translation helpful? Give feedback.
-
Again, Gunicorn workers are designed to share nothing. The only way to share things is to use OS methods of memory sharing. Gunicorn uses A common pattern for any web service that has heavy work is to submit that work to a queue and handle it with a separate service. You can have some lower memory machines serving web requests and higher memory machines performing the prediction work. Consider whether you really need to run multiple prediction processes on the same machine. If you do, and you really care about de-duplicating their memory consumption, look into ways to share memory between those processes. Sharing Python objects is not easy. The |
Beta Was this translation helpful? Give feedback.
-
Consider also whether maybe Python is not the best language for your memory-and-cpu-intensive work. |
Beta Was this translation helpful? Give feedback.
-
How do you share a variable across multiple workers? Different pid
Beta Was this translation helpful? Give feedback.
All reactions