Skip to main content

Posts

Showing posts from June, 2020

HTTP/2 Java Server using Embedded Jetty - Part 2

In the last post we saw how to spin a http/2 server using embedded jetty. In this post we will see, how to use asynchronous servlet (as well as AIO a.k.a non-blocking IO) and why that is important? Asynchronous Servlets ≠ Asynchronous IO [1] The concept of Asynchronous Servlets is often confused with Asynchronous IO or the use of NIO. However, Asynchronous Servlets are not primarily motivated by asynchronous IO, since: HTTP Requests are mostly small and arrive in a single packet. Servlets rarely block on requests. Many responses are small and fit within the server buffers, so servlets often do not block writing responses. Asynchronous Servlets Use-case The main use-case for asynchronous servlets is waiting for non-IO events or resources. Many web applications need to wait at some stage during the processing of a HTTP request, for example: waiting for a resource to be available before processing the request (e.g., thread, JDBC Connection) waiting for an applica