Asynchronous Threading to Improve Spring Boot Application Performance

Scenario

DN Tech
Geek Culture

--

Let’s say you have a Spring application to request user information. There are 200 users who send requests to the web server. Each request is forwarded to the backend service to retrieve user information. When the first thread reaches the Tomcat thread in the web server, it calls the backend method and waits for it to return the result. Then it forwards the result to the server and returns to the user. Other requests have to wait for the first request to finish before being processed. If each request takes 3 seconds, 600 seconds is consumed.

Asynchronous Threading

In Tomcat servlet 3.0, there are two threads in the web server — Tomcat thread and Callback thread.

Asynchronous Threading

The Tomcat thread in the current model makes it possible to forwards requests independently to the backend server. The presence of Callback thread allows each result from the the request to be handled asynchronously. Taking the same example, when the first request comes to the Tomcat thread, a child thread is created to invoke the business method in the backend server. The Tomcat thread can then be…

--

--

Responses (5)