Last time on The Adventures of Bare Metal Web Development, I covered the basic concepts of building a website in C++. Using just a few lines of code in any language it is possible to output content to the web server to be passed along to the user.
In the response to the article, the point was raised that CGI (Common Gateway Interface) is slow. And yes, it is. The exercise was just an exploration of the possible, not the inherent performance issues with CGI. In the article I touched on various ways to improve performance, but I’d like to get even closer to the hardware.
As I discussed in my last article, Apache is an excellent general-purpose web server. Arguably its shiniest feature its extensive support for modification via modules. Using C, we can augment and extend its behavior in dramatic ways. Before FPM (FastCGI Process Manager), PHP used this approach to parse PHP files through its interpreter. If PHP were completely thread safe, this approach could still be used (and would likely be superior given mod_event’s performance).
While you could compile an Apache module in a shared hosting system (as long as you had compiler access), installing an Apache module requires root access (or at least access to the user that runs Apache, and on shared you won’t have that).