[ prog / sol / mona ]

prog


What's the internet's __worst__ kept secret?

8 2019-12-31 08:33 *

Perhaps you meant that httpd should just serve static files. That would be sane default advice.

I understand your point but httpd is supposed to serve resources, which as far as I know were never defined as merely static files. Let's forget for a while the abomination of the use of a web browser as a universal virtual machine to run anything (there, I'm sure we share the same point of view). There's nothing wrong with dynamically generated content: statistics, lists of recently updated contents etc.

As I understand it, CGI works thusly:

HTTP_client -HTTP_request-> HTTP_server -CGI_request-> CGI_server -program_request-> program -program_result-> CGI_server -CGI_result-> HTTP_server -HTTP_result> HTTP_client.

What I was trying to argue is that transforming the HTTP requests into a CGI request might be an unnecessary step and is now frequently replaced with :

HTTP_client -HTTP_request-> HTTP_server -HTTP_request(forwarded) -> "Application Server" -program_request-> program -program_result-> "Application Server" -HTTP_result-> HTTP_server -HTTP_result (forwarded, eventually reformated) -> HTTP_client.

Do you really need to translate HTTP requests into CGI requests? Is it a necessary step? Requests forwarded from the HTTP server ought to be clean and consistent enough and you really don't have to implement the whole HTTP specs into your application server.

What follows might need a trigger warning because that's absolutely against the elementary separation of concepts and I have a feeling that you're not going to appreciate it much. You can even use the web server itself to serve dynamic content. Lua is trivial to embed in a C server and when you're looking at raw performance, this way of building things has proven to be very efficient. Chinese programmers are into this. We didn't have a lot of code coming from them on github before that. Take a look at the OpenResty project for instance: https://openresty.org/en/ You have the fast non blocking event loop of nginx and the ability to generate dynamic content with the speed of LuaJIT. Why not building web applications this way, if you have to deal with huge loads? That's the solution Alibaba, the giant chinese marketplace came up with.

Under really high load you can come up with even more radical approaches like embedding a primitive web server into your content application: (and here's another chinese project that I found "inspiring")

https://github.com/ellzey/libevhtp
sample application: https://github.com/buaazp/zimg

22


VIP:

do not edit these