I have worked in the construction of a public API that will have a lot of concurrent accesses and one of the aspects that I thought is to use Asynchronous I/O to consider the scalability aspect.
Initially I thought in use Nginx as a HTTP Server (event-driven) because he work in async way, differently of Tomcat. The API will be constructed in Java and for that I thought in use the following components :
- Tomcat 7 - HTTP/Web Server + Java Container
- Netty.io or HttpCore?
- Resteasy (REST layer, w/ HttpServlet30Dispatcher servlet)
- MongoDB (w/ Async Java Driver)
I have seen many discussions about Servlet 3.0 because the new version has support to asynchronous requests (using NIO). Based in my problem and in the model above, I have some questions:
- Is necessary to use Netty.io once that I have plans to use Servlet 3.0 that supports Asynchronous Requests too?
- Use an event-driven webserver (ex: Jetty) is different to use a process based webserver like Tomcat 7 (that supports to Servlet 3.0) that isn't an event-driven webserver?
- I saw in many sites that Netty.io works in a way where a thread can accept many requests, instead of the classic way of one thread peer request. In the practice, how it works?
- Asynchronous request handing (Servlet 3.0) and Non-Blocking IO (NIO) are different concepts? In which way?
- I never see a REST API using NIO, is it a good approach? Which potential problems can I will have?