3 ms·
One of the nice things about CGI was that by starting a new process per request it provided isolation between requests. Python's startup overhead obviously make
by laurencerowe 4y ago
One of the nice things about CGI was that by starting a new process per request it provided isolation between requests. Python's startup overhead obviously makes CGI untenable, but I find the new Web Assembly runtimes interesting because they are able to provide extremely fast startup by reseting state: https://bytecodealliance.org/articles/wasmtime-10-performance https://bytecodealliance.org/articles/wasmtime-10-performanc...
- nine_k 4y agoPHP was built around this idea for decades %) Theoretically one could produce ready-to-run, guaranteed clean Python request handlers very quickly. Run all the startup and imports stuff in a Python process, then freeze it. Fork a copy of it on a new request (with COW it's definitely fast), and terminate it normally after that. This would require some care, e.g. to not open sockets before the fork, so that handlers won't share it. I bet it has been tried, but I'm too lazy to actually search for that.
- laurencerowe 4y agoForking can be quite slow (milliseconds), though there are techniques to speed it up: https://www.cs.purdue.edu/homes/pfonseca/papers/eurosys21-odf.pdf https://www.cs.purdue.edu/homes/pfonseca/papers/eurosys21-od... I believe wasmtime can be faster as it doesn’t need to create as many new OS resources and just resets some memory maps. Only really meaningful for simple request handlers taking a few milliseconds.
- grubby 4y agoboiler up