3 ms·
Because then you’d need a (inefficient) fork/execing webserver, or some convoluted (error-prone) way of multiplexing multiple connections over one stream. The
by ninkendo 9y ago
Because then you’d need a (inefficient) fork/execing webserver, or some convoluted (error-prone) way of multiplexing multiple connections over one stream. The OS file descriptor model already handles this for you with listen() and accept().
CGI only works if you’re willing to take the hit of launching an entire process (good luck using any interpreted language, and even go needs some runtime initialization at startup) for every single web request.
- nivertech 9y agoLambda/FaaS is more like FastCGI https://en.wikipedia.org/wiki/FastCGI https://en.wikipedia.org/wiki/FastCGI
- ninkendo 9y agoReplying way late here, but FastCGI doesn't work by printing to stdout, it talks to a domain socket or an open TCP port. The grandparent post was asking "why can't lambda just use stdout?" The magic of TCP or domain sockets is that calling accept() gives you a unique file descriptor that corresponds with a single client. Just using stdout doesn't work that way, unless your entire process was launched to handle one request, hence CGI being very inefficient.