Where to put thread pools?

Marc-André Laverdière marcandre.laverdiere at gmail.com
Mon Jun 6 00:57:53 EDT 2011


Hello everyone,

I'm having a bit of a doubt, and I think I've been using an overkill
amount of threads in my application.

So here is the code snippet for my channel factory intialization.

NUM_THREADS = config.getInt(SERVER_THREADS);
ThreadPoolExecutor WORKER_THREAD_POOL = new
MemoryAwareThreadPoolExecutor(NUM_THREADS, ...);
ThreadPoolExecutor basePool = new
MemoryAwareThreadPoolExecutor(Math.max(1, NUM_THREADS/10), ...);
channelFactory = new OioServerSocketChannelFactory(basePool,
WORKER_THREAD_POOL);

And here is what the pipeline factory creates:
...
pipeline.addLast(HANDLER_EXECUTOR_NAME, new ExecutionHandler(executor));
...

Please note that this is the same executor than the one that we used above.
Before I jump to conclusions, let me ask the list:
1) Is there any way that we can set an upper bound in the number of
threads created across all thread pools?
2) What is the optimal architecture? Here are the 2 ideas I have
2.1 Base Thread pool 2* # of cores, worker pool the same size, and a
MATPE of size NUM_THREADS used in an ExecutionHandler
2.2 Base Thread pool 2* #of cores, MATPE of size NUM_THREADS as the
worker pool, and NO ExecutionHandler later.

Regards,

-- 
Marc-André LAVERDIÈRE
"Perseverance must finish its work so that you may be mature and complete,
not lacking anything." -James 1:4
http://asimplediscipleslife.blogspot.com/
mlaverd.theunixplace.com



More information about the netty-users mailing list