3 ms·
This is spot on. My one and only gripe is with this part: > So how do you keep this kind of monster running? First, you make sure you never allow it to use too
by ary 7y ago
This is spot on. My one and only gripe is with this part:
> So how do you keep this kind of monster running? First, you make sure you never allow it to use too much of the CPU, because empirically, it'll mean that you're getting distracted too much and are timing out some requests while chasing down others. You set your system to "elastically scale up" at some pitiful utilization level, like 25-30% of the entire machine.
Letting a Python web service, written in your framework of choice, perform CPU-bound work is just bad design. A Python web service should essentially be router for data, controlling authentication/authorization, I/O formatting, and not much else. CPU intensive tasks should be submitted to a worker queue and handled out of process. Since this is Python we don't have the luxury of using threads to perform CPU-bound work (because of the Global Interpreter Lock).
- ghostwriter 7y ago> Since this is Python we don't have the luxury of using threads to perform CPU-bound work (because of the Global Interpreter Lock). You can have it with threads if the CPU-bound work is done inside a C extension - https://docs.python.org/3/c-api/init.html#releasing-the-gil-from-extension-code https://docs.python.org/3/c-api/init.html#releasing-the-gil-...