Don't know how many of you are still using Thrift - it's still going strong here because it works so much better than RMI.
Just a small tip, I recently came across a TThreadedPoolServer. The idea is that a thread pool gets used to serve requests from the clients - so each client has its own thread. In my opinion, this is not ideal, but this is how it's working at the moment.
There is a danger though: make sure you set the maximum number of threads in the pool! Otherwise it just keeps on adding threads to the pool - returning them I don't know when. The app was sitting at 400+ threads just now.
It's easy to do:
TServerTransport serverTransport = new TServerSocket(port); | |
TThreadPoolServer.Args a = new TThreadPoolServer.Args(serverTransport).processor(processor); | |
a.maxWorkerThreads(5); | |
TThreadPoolServer server = new TThreadPoolServer(a); | |
return server; |
You can of course set a minimum etc. as well. I'm not sure when the threads are "freed" and returned to the pool - I'll investigate this later today.