4 ms·
Replace Rails and similar server-side frameworks with CGI scripts, and you're done. Every request is a new process with its own memory space. Yes, performance
by DougWebb 6y ago
Replace Rails and similar server-side frameworks with CGI scripts, and you're done. Every request is a new process with its own memory space.
Yes, performance is an issue with that old approach. Around the turn of the century I was responsible for a Perl web application that ran as a CGI script, and to speed it up I wrote my own Perl httpd server that had my web application code pre-loaded. Then for each request I forked a new process, which carried over all of the pre-loaded code and already-running perl.exe, so there was very little startup time (compared to a normal CGI script startup.) I was careful to take full advantage of the operating system's Copy-on-write memory semantics, so that the only memory that had to be allocated for the new process was Perl's runtime stack. All of the memory containing the application code was shared across processes because it never got written to.
This web application is still running today, though I left the company in 2010. Back then, it was handling about six million requests per day, about 75% of which was during US daytime working hours. So, around 160 requests/second, spread across five or six servers that were getting old in 2010.
The modern frameworks have taken the same concept a step further, and replaced the process fork with a thread pool. That's faster, but it allows memory leaking in a way process forking does not. You have to go out of your way to share memory between processes, but with threads it's easy to do accidentally.
- hu3 6y agoWorkerman [1] uses a similar approach to put PHP pretty high on TechEmpower [2]. Specially now with PHP8's JIT. [1] https://github.com/walkor/Workerman https://github.com/walkor/Workerman [2] https://www.techempower.com/benchmarks https://www.techempower.com/benchmarks