#keep-alive
Posts
-
Digging into nginx's Source 8: Reading an HTTP Request — From a Connection to ngx_http_request_t
We follow, through the source, how one accepted socket becomes an ngx_http_request_t inside nginx — why the request struct is not created until data arrives, the switch-based state machines that parse the request line and headers, where client_header_buffer_size and large_client_header_buffers are used, the order in which the Host header picks a server block, and keep-alive and pipelining, all checked with debug logs, gdb and nc.
-
Digging into Apache httpd's Source 8: MPMs — How prefork, worker and event Share Out Connections
Follows in the source what the single line LoadModule mpm_event_module in httpd.conf actually changes. How an MPM can be swapped as one module (the mpm hook and ap_mpm_query), prefork that only uses processes, worker that splits the job between a listener thread and a queue, event that takes keep-alive connections off the threads and hands them to epoll, the parent's once-a-second loop that grows and shrinks the children, the shared-memory scoreboard, and where StartServers, MaxRequestWorkers and ThreadsPerChild end up in the code — all checked with ps, mod_status and gdb.
-
Digging into Apache httpd's Source 9: Connections and Reading a Request — From a Socket to a request_rec
Follows one socket handed over by the MPM as it becomes a conn_rec, and then a request_rec once the request line and headers are read — all in the httpd source. Why the core always stands last in the hooks, where the keep-alive loop lives depending on the MPM, how trunk moved request-line reading into a filter, and the two steps that pick a virtual host from the Host header, each checked with an example.
-
Digging into Tomcat's Source 5: The Connector and the NIO Endpoint — Which Threads Take a Connection
We follow in the source how one line of server.xml, <Connector port="8080">, becomes three objects — Connector, Http11NioProtocol and NioEndpoint — and how the Acceptor, the Poller and the worker threads share the work of a single connection inside them. With jstack and a raw-socket client we check how a keep-alive connection lets go of its thread between requests, how Tomcat's thread pool (TaskQueue) behaves differently from the JDK's, and where maxConnections, acceptCount and maxThreads take effect. We also compare with 11.0.x and see that the NIO2 connector is gone from the main branch.
-
Digging into Tomcat's Source 6: Reading an HTTP/1.1 Request — From Bytes to a coyote Request
We follow, through the real source, how bytes read from a socket are split into a request line and headers inside the service() loop of Http11Processor and become a coyote Request. By sending raw requests we also see MessageBytes, which delays making Strings, the maxHttpHeaderSize and maxHeaderCount limits, how a bad request turns into an HTML 400 page, and where keep-alive and chunked responses are decided.