You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My flask app runs on gunicorn that has 1 worker and 8 threads. At startup the application reads a few million lines of JSON to load into an in-memory database. To do this, I spawn a gevent that does the read. I yield several times (I use gevent.sleep(0.1) with the monkey patch) and in the data-read thread but the kube pod still misses answering liveness and readyness probes enough times to get killed by kubernetes.
I tried using 2 (and more) workers. That solved my probe issue since a worker was always available for them. But every worker also now launches the read event, and I have multiple gevents trying to do the same thing.
Can I "pin" a gevent to a worker? Like only worker #0 does this event? Should I use gthreads/thread pools instead? I'm not terribly familiar with gunicorn so I'm sorry if this is a silly question.
In C++ I'd just launch a thread to do the cpu intensive task and let the scheduler handle the thread preemption, but I'm not sure what I should do here
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
My flask app runs on gunicorn that has 1 worker and 8 threads. At startup the application reads a few million lines of JSON to load into an in-memory database. To do this, I spawn a gevent that does the read. I yield several times (I use gevent.sleep(0.1) with the monkey patch) and in the data-read thread but the kube pod still misses answering liveness and readyness probes enough times to get killed by kubernetes.
I tried using 2 (and more) workers. That solved my probe issue since a worker was always available for them. But every worker also now launches the read event, and I have multiple gevents trying to do the same thing.
Can I "pin" a gevent to a worker? Like only worker #0 does this event? Should I use gthreads/thread pools instead? I'm not terribly familiar with gunicorn so I'm sorry if this is a silly question.
In C++ I'd just launch a thread to do the cpu intensive task and let the scheduler handle the thread preemption, but I'm not sure what I should do here
Beta Was this translation helpful? Give feedback.
All reactions