4 ms·
Using CGI is silly and slow, for all but the simplest, stateless servers. If one wishes to avoid the overhead of learning a new framework, at least FastCGI shou
by utopcell 9y ago
Using CGI is silly and slow, for all but the simplest, stateless servers. If one wishes to avoid the overhead of learning a new framework, at least FastCGI should be considered.
A relevant (but dated) discussion about web frameworks in C++ can be found in [1].
I am personally a big fan of CROW [2] and have used it many times in the past.
[1] https://softwareengineering.stackexchange.com/questions/53624/can-c-be-used-as-a-server-side-web-development-language https://softwareengineering.stackexchange.com/questions/5362...
[2] https://github.com/ipkn/crow/blob/master/README.md https://github.com/ipkn/crow/blob/master/README.md
- faragon 9y ago+1, FastCGI is the way to go for web services in C/C++: not only because cause of avoiding to spawn a process for each request, but because of having web services state in memory. Also, for avoiding heap fragmentation in long lived processes I recommend avoiding the STL library, and avoid using C++ strings, too.
- chubot 9y agoCGI isn't slow -- starting interpreters is slow. Starting Python or Ruby can easily be 1000x more expensive than starting a process in C, which takes MICROSECONDS, not hundreds of milliseconds. See this 7 year old message by Richard Hipp (of sqlite): https://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg02065.html https://www.mail-archive.com/fossil-users@lists.fossil-scm.o... https://news.ycombinator.com/item?id=3036124 https://news.ycombinator.com/item?id=3036124 This server takes over a quarter million requests per day, 10GB of traffic/day, and it does so using less than 3% of of the CPU on a virtual machine that is a 1/20th slice of a real server.
- goldenkey 9y agoPeople just throw around qualifier attacks these days without thinking about the reality of modern processing power and what is really overoptimization. Just because CGI is slow-er- does not make it slow. So many hours are wasted on overoptimization, myself guilty of it - simply because of OCD type tendencies. I hope when I am finally on my deathbed I am not picky about the color of the sheets...