ztellman/aleph — pull request #42 by dajac (2011-11-10 15:00:06+00:00)
Title: fix to avoid spawning one thread per (client-)connection

Hello Zach,

I use the http client of Aleph to fetch web pages. During a bunch of tests with a thousand of concurrent connections, I was very surprised to see that the number of threads increased very quickly. For example, with thousand concurrent connections, the number of threads hited almost a thousand! That's not the behavior I expected with Netty's asynchronous IOs.

After a small investigation, I noticed that netty/create-client create a NioClientSocketChannelFactory for every connections, therefore every connection use its own thread (pool of threads) and we loose the power of Netty.

I just patched Aleph to reuse the same NioClientSocketChannelFactory for every connections. Like this, with the same benchmark, number of threads is stable at about 30.

David