#nio
Posts
-
Digging into Kafka's Source 4: The Broker's Network Layer — Acceptors, Processors and Request Handlers
We follow, in SocketServer.scala, how the three kinds of threads in a broker's jstack — socket-acceptor, network-thread and request-handler — share the work of a single request. One Acceptor per listener; a Processor reads the bytes, puts the request on the request queue and mutes the connection; a request handler branches on KafkaApis.handle()'s match; and the response goes back to the Processor that read the request. With jstack, a raw-socket client and the request log we check how mute/unmute keeps one connection's requests in order by handling them one at a time, and where num.network.threads, num.io.threads and queued.max.requests take effect, and we compare it all with Tomcat's NIO connector.
-
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.