Question

Q.1 I know that when we are talking about synchronous HTTP, for each request a Thread may be spawn and get blocked, so when number of simultaneous connections increase, we will encounter massive thread overhead.
Asynchronous mode will tolerate some overhead polling responses for something desired, but number of Threads drastically decrease.
I also know that Asynchronous HTTP will let us take actions even when response delivered is not the complete response (only a part of response is received) which is appropriate for real-time actions.
But what are other benefits of Async HTTP?

Q.2 I have a server which has only and only one client, but that client will send thousands of requests per second. I use blocking IO (Synchronous HTTP) with lightweight Threads (Quasar). Should I switch to Async? What is the benefit of doing that for me?

EDIT. More clarifications. I have an HTTP server with 3-4 thousand requests from the same client per second, and I have only one client. I solved the problem of thread overhead by using lightweight threads in conjunction with synchronous HTTP (say blocking IO) instead of using Async HTTP.
Now I don't know if removing thread overhead was all the job I had to do, or will I face some other problems later because of not using Async API? (And this is maybe because I don't know full benefits of Async API which means Q.1)
Regards

Was it helpful?

Solution

The benefit of asynchronicity in any context is that the user does not have to wait for the method call to complete. This has benefits most specifically in UI's, where not blocking on a method call results in the UI appearing to be more responsive to the user.

The answer to "should I switch to async?" is "will it improve the responsiveness of the application?" Only you can decide that, based on your observations of your specific application's behavior. In general, you would only use async (if at all) for methods that take a long time to complete, for some arbitrary definition of "long."

Licensed under: CC-BY-SA with attribution
scroll top