Is it appropriate to use Grizzly w/ Tomcat for my webapp?
I would like to know if I should use Grizzly with Tomcat (client already has Tomcat, otherwise I'd switch to GlassFish!) for the project I am doing. What I have is a normal webapp -- jsps, Actions, database, etc.
What I'd like to do is put an XML cache server just behind the web server. This XML cache server will:
1. Look to see if the info is already in the cache.
2. If it is, return it, without having to query the database.
3. If not, the petition is passed on as normal, queries the database, then adds the info to the cache.
4. It then opens up a socket to another machine with the same setup -- web server, XML cache server -- and sends the info so that machine now has the info in its cache as well.
I think I need to use NIO, since doing it without out NIO would mean a socket/thread for each petition. So I made a servlet which creates a simple NIOServer (which contains an object SelectorThread with its own Selector and Thread) and another SelectorThread to be used by each NIOClient.
Upon receiving an HTTP request, I save the info sent to me in the request, make a new NIOClient, passing it the client SelectorThread, and send the info to another server.
It works but using JMeter, when I get up around 2,000 concurrent requests it poops the bed -- memory problems, blocked ports, etc.
Sooooo my question is, could I possibly plug in Grizzly to my Tomcat instead of Coyote, and use its ARP, as Jean-Francois Arcand explains in his blog? He says it'sa appropriate "when a business process is calling out to another one over a slow protocol". In my case I'll eventually serializing these XMLs, so even though they are small it will be a bottleneck.
Would I gain anything by using Grizzly? Anyone ever done something like this before?
Many many thanks!
But with NIO it seems to be working ok. I have a servlet with a static Server (with its SelectorThread) and also another static SelectorThread for the Client. Each time there is a petition I create a new Client and pass it my Client Selector Thread.