-
Thread per connection : NIO, Linux NPTL and epoll (28 messages)
- Posted by: Rahul Bhargava
- Posted on: June 18 2004 16:34 EDT
I have been benchmarking Java NIO with various JDKs on Linux. Server is
running on a 2 CPU 1.7 GHz, 1GB RAM, Ultra160 SCSI 36GB disk
With Linux kernel 2.6.5 (Gentoo) I had NPTL turned on and support for
epoll compiled in. The server application was designed to support
multiple disptach models :
1. Reactor with Iterative Disptach with multiple selector threads. Essentially
the accepted connections were load-balanced between varying number of
selector threads. The benchmark then applied a step function to experimentally
determine the optimal # of threads and connection per selector ratio.
2. Also a simple concurrent blocking disptach model was supported. This is
essentially a reader thread per connection model.
Client application opens concurrent persistent connections to the server
and starts blasting messages. Server just reads the messages and does
basic un-marshalling to ensure message is ok.
Results were interesting:
1. With NPTL on, Sun and Blackwidow JVM 1.4.2 scaled easily to 5000+ threads. Blocking
model was consistently 25-35% faster than using NIO selectors. Lot of techniques suggested
by EmberIO folks were employed - using multiple selectors, doing multiple (2) reads if the first
read returned EAGAIN equivalent in Java. Yet we couldn't beat the plain thread per connection model
with Linux NPTL.
2. To work around not so performant/scalable poll() implementation on Linux's we tried using
epoll with Blackwidow JVM on a 2.6.5 kernel. While epoll improved the over scalability, the
performance still remained 25% below the vanilla thread per connection model. With epoll
we needed lot fewer threads to get to the best performance mark that we could get out of NIO.
Here are some numbers:
(cc = Concurrent Persistent Connections, bs = Is blocking server mode on Flag,
st = Number of server threads, ct = Connections handled per thread,
thruput = thruput of the server )
cc, bs,st,ct, thruput
1700,N,2,850,1379
1700,N,4,425,1214
1700,N,8,212,1240
1700,N,16,106,1140
1700,N,32,53,1260
1700,N,64,26,1115
1700,N,128,13,886
1700,N,256,6,618
1700,N,512,3,184
1700,Y,1700,1,1737
As you can see the last line indicates vanilla blocking server (thread per connection)
produced the best thruput even with 1700 threads active in the JVM.
With epoll, the best run was with 2 threads each handling around 850 connections in
their selector set. But the thruput is below the blocking server thruput by 25%!
Results shows that the cost of NIO selectors coupled with OS polling mechanism (in
this case efficient epoll VS selector/poll) has a significant overhead compared to
the cost of context switching 1700 threads on an NPTL Linux kernel.
Without NPTL of course it's a different story. The blocking server just melts at 400 concurrent
connections! We have run the test upto 10K connections and the blocking server outperformed
NIO driven selector based server by same margin. Moral of the story - NIO arrives at the scene
a little too late - with adequate RAM and better threading models (NPTL), performance gains
of NIO don't show up.
Sun's JVM doesn't support epoll() so we couldn't use epoll with it. Normal poll() based
selector from Sun didn't perform as well. We needed to reduce the number of connections
per thread to a small number (~ 6-10) to get comprabale numbers to epoll based selector.
That meant running lot more selector threads kind of defeats the purpose of multiplexed IO.
The benchmarks also dispell the myth created by Matt Welsh et al (SEDA) that a single
threaded reactor can keep up with the network. On a 100Mbps ethernet that was true: network
got saturated prior to server CPUs but with > 1Gbps network, we needed multiple selectors
to saturate the network. One single selector's performance was abysmal (5-6x slower than
concurrent connections)
For application that want to have fewer number of threads for debuggability etc, NIO may be
the way to go. The 25-35% performance hit may be acceptable to many apps. Fewer threads
also means easier debugging, it's a pain to attach a profiler or a debugger to a server hosting
1000+ threads :-) . Bottom line with better MT support in kernels (Linux already with NPTL), one
needs to re-consider the thread per connection model
Rahul Bhargava
CTO, Rascal SystemsThreaded Messages (28)
- History by Ores Oret on July 12 2010 11:18 EDT
- nice talk about EJB by bezmor jon on February 23 2011 17:08 EST
- Perfect! by saka maka on June 29 2012 09:37 EDT
- jas and java by marcio sial on July 26 2012 19:49 EDT
- About Site by jonh best on June 20 2011 01:29 EDT
- My son is going to be aspect .... by Sheraz Butt on May 30 2012 10:30 EDT
- We love linux by zbeng jeng on June 02 2012 05:39 EDT
- good articale by jack hog on June 05 2012 12:28 EDT
- New Version by Austin Fegleys on June 21 2012 13:56 EDT
- Linux the best by Eduardo Souza on June 21 2012 18:19 EDT
- linux by colin stead on July 03 2012 16:23 EDT
- linux by colin stead on July 03 2012 04:27 EDT
- linux by colin stead on July 03 2012 16:23 EDT
- Bangalore escort by Ankur Sharma on July 10 2012 01:37 EDT
- crush four by Ankur Sharma on July 16 2012 11:04 EDT
- Hire Car Delhi by prathamesh shimpi on August 09 2012 02:38 EDT
- great by Gina Lim on August 28 2012 18:42 EDT
- Fantastic !!! by asdf asdf on September 16 2012 22:01 EDT
- Linux is a great tool by Emil G on September 22 2012 07:12 EDT
- Thread per connection : NIO, Linux NPTL and epoll by Sheraz Butt on October 13 2012 03:08 EDT
- Thread per connection : NIO, Linux NPTL and epoll by ajeh wungan on February 21 2013 03:26 EST
- Kios Kaos by Muhamad Fajar Kurnia on March 21 2013 13:38 EDT
- Kios Kaos by Muhamad Fajar Kurnia on March 21 2013 13:41 EDT
- Kios Kaos by Muhamad Fajar Kurnia on March 21 2013 13:44 EDT
- Thread per connection : NIO, Linux NPTL and epoll by Adiska Putria on May 25 2013 13:47 EDT
- Thread per connection : NIO, Linux NPTL and epoll by Adiska Putria on May 25 2013 13:51 EDT
- Thread per connection : NIO, Linux NPTL and epoll by Adiska Putria on May 25 2013 13:53 EDT
- good post by ceofounder me on May 31 2013 04:21 EDT
- go by hdon tabra on June 18 2013 07:33 EDT
-
History[ Go to top ]
- Posted by: Ores Oret
- Posted on: July 12 2010 11:18 EDT
- in response to Rahul Bhargava
History
Before the 2.6 version of the Linux kernel, processes were the schedulable entities, and there was no real support for threads. However, it did support a system call — clone — which creates a copy of the calling process where the copy shares the address space of the caller. The LinuxThreads project used this system call to provide kernel-level thread support (most of the previous pthread implementations in Linux worked entirely in userland). Unfortunately, it had a number of issues with true POSIX compliance, particularly in the areas of signal handling, scheduling, and inter-process synchronization primitives.
To improve upon LinuxThreads, it was clear that some kernel support and a re-written threads library would be required. Two competing projects were started to address the requirement: NGPT (Next Generation POSIX Threads) worked on by a team which included developers from IBM, and NPTL by developers at Red Hat. NGPT was abandoned in mid-2003, at about the same time when NPTL was released.
NPTL was first released in Red Hat Linux 9. Old-style Linux POSIX threading is known for having trouble with threads that refuse to yield to the system occasionally, because it does not take the opportunity to preempt them when it arises, something that Windows was known to do better at the time. Red Hat claimed that NPTL fixed this problem in an article on the Java website about Java on Red Hat Linux 9.[3]
NPTL has been part of Red Hat Enterprise Linux since version 3, and in the Linux kernel since version 2.6. It is now a fully integrated part of the GNU C Library.
There exists a tracing tool for NPTL, called POSIX Thread Trace Tool (PTT). And an Open POSIX Test Suite (OPTS) was written for testing the NPTL library against the POSIX standard.
-
nice talk about EJB[ Go to top ]
- Posted by: bezmor jon
- Posted on: February 23 2011 17:08 EST
- in response to Rahul Bhargava
EJB servers are required to support the UserTransaction interface for use by EJB beans with the BEAN value in the @TransactionManagement annotation (this is called bean-managed transactions or BMT). The UserTransaction interface is exposed to EJB components through either the EJBContext interface using the getUserTransaction method, or directly via injection using the general @Resource annotation. Thus, an EJB application does not interface with the Transaction Manager directly for transaction demarcation; instead, the EJB bean relies on the EJB server to provide support for all of its transaction work as defined in the Enterprise JavaBeans Specification. (The underlying interaction between the EJB Server and the TM is transparent to the application; the burden of implementing transaction management is on the EJB container and server provider.
-
Perfect![ Go to top ]
- Posted by: saka maka
- Posted on: June 29 2012 09:37 EDT
- in response to bezmor jon
Completely agree with this guy! Portable Dishwasher
-
jas and java[ Go to top ]
- Posted by: marcio sial
- Posted on: July 26 2012 19:49 EDT
- in response to bezmor jon
You said everything I wanted to say. I leave here my website jogos, realize my job as CEO of the corporation Bravanet
-
About Site[ Go to top ]
- Posted by: jonh best
- Posted on: June 20 2011 01:29 EDT
- in response to Rahul Bhargava
This Site Really helpful site
i really enjoyed a lot's while reading post's on your site
Thnak's John
-
My son is going to be aspect ....[ Go to top ]
- Posted by: Sheraz Butt
- Posted on: May 30 2012 10:30 EDT
- in response to Rahul Bhargava
My son is going to be aspect of an excellent research overseas system in Oxford. He will be learning the Western and international financial systems as well as the govt framework of the biggest nations. He desired to do some planning before he remaining next drop and I had observed from a companion that the Collection of The legislature has classes available. Are these classes available to anyone? Are they online? trendsandgadgets.net
-
We love linux[ Go to top ]
- Posted by: zbeng jeng
- Posted on: June 02 2012 05:39 EDT
- in response to Rahul Bhargava
Thanks for this informative article. You can also visit my sexo site.
-
good articale[ Go to top ]
- Posted by: jack hog
- Posted on: June 05 2012 12:28 EDT
- in response to Rahul Bhargava
I am happy when reading your blog with updated information!
thanks alot and hope that you will post more site that are related to this site
<a href="http://thebesthairregrowthproducts.com/">hair regrowth</a> -
New Version[ Go to top ]
- Posted by: Austin Fegleys
- Posted on: June 21 2012 13:56 EDT
- in response to Rahul Bhargava
Expecting for the newest version. Hope with more features if there is one. custom home builder | home remodeling
-
Linux the best[ Go to top ]
- Posted by: Eduardo Souza
- Posted on: June 21 2012 18:19 EDT
- in response to Rahul Bhargava
Thanks for this information. Linux is really powerfull os.
-
linux[ Go to top ]
- Posted by: colin stead
- Posted on: July 03 2012 16:23 EDT
- in response to Eduardo Souza
I totally agree. Been around forever too <a href="http://www.teethwhiteningkits2you.co.uk/Crest-Whitening-Strips/c6/index.html">crest whitening strips</a>
-
linux[ Go to top ]
- Posted by: colin stead
- Posted on: July 03 2012 16:27 EDT
- in response to colin stead
And it's easy
<a href="http://www.teethwhiteningkits2you.co.uk/Crest-Whitening-Strips/c6/index.html" title="crest whitening strips">crest whitening strips</a>
-
Bangalore escort[ Go to top ]
- Posted by: Ankur Sharma
- Posted on: July 10 2012 01:37 EDT
- in response to Rahul Bhargava
am in the middle of working on a school report on this topic and your post has helped me with the information I needed to complete it. Thanks.Bangalore escort
-
crush four[ Go to top ]
- Posted by: Ankur Sharma
- Posted on: July 16 2012 11:04 EDT
- in response to Rahul Bhargava
Prolimehost is a leading provider of Web hosting solutions and services, like Cheap Dedicated Servers, Cpanel Dedicated Servers, low cost dedicated server,Windows and linux Dedicated Servers, best email game and virtual dedicated server. crush four
-
Hire Car Delhi[ Go to top ]
- Posted by: prathamesh shimpi
- Posted on: August 09 2012 02:38 EDT
- in response to Rahul Bhargava
I agree with you. This post is truly inspiring. I like your post and everything you share with us is current and very informative, I want to bookmark the page so I can return here from you that you have done a fantastic job
Car Hire Delhi || Delhi Taxi || Delhi Cabs || Hire Car Delhi || Car On Rent Delhi || Car Rental Delhi || Taxi Service Delhi || Cabs In Delhi
-
great[ Go to top ]
- Posted by: Gina Lim
- Posted on: August 28 2012 18:42 EDT
- in response to Rahul Bhargava
this is very informative "Reactor with Iterative Disptach with multiple selector threads. Essentially
the accepted connections were load-balanced between varying number of
selector threads. The benchmark then applied a step function to experimentally
determine the optimal # of threads and connection per selector ratio"..thanks for sharing -
Fantastic !!![ Go to top ]
- Posted by: asdf asdf
- Posted on: September 16 2012 22:01 EDT
- in response to Rahul Bhargava
hanks for taking the time to post such valuable information.
Quality content is what always gets the visitors coming. And
I am waiting for this. See you next week http://www.moncleroutletsit.com -
Linux is a great tool[ Go to top ]
- Posted by: Emil G
- Posted on: September 22 2012 07:12 EDT
- in response to Rahul Bhargava
I look forward to more such articles. I looked here often. to read :)
<a href="http://poza-bankowe.pl" target="_blank">Po?yczki pod zastaw nieruchomo?ci</a> | <a href="http://poza-bankowe.pl/pod-zastaw-mieszkania" target="_blank">Pod zastaw mieszkania</a> | <a href="http://poza-bankowe.pl/pod-zastaw-domu" target="_blank">Pod zastaw domu</a> | <a href="http://poza-bankowe.pl/pod-zastaw-dzia?ki" target="_blank">Pod zastaw Dzia?ki</a>
-
Thread per connection : NIO, Linux NPTL and epoll[ Go to top ]
- Posted by: Sheraz Butt
- Posted on: October 13 2012 03:08 EDT
- in response to Rahul Bhargava
Design a custom dress shirts that fits you exactly the way you want. Superb custom mens dress shirt fabrics, fine stitching quality that brings perfect custom made ... CustomizedDressShirts.com
-
Thread per connection : NIO, Linux NPTL and epoll[ Go to top ]
- Posted by: ajeh wungan
- Posted on: February 21 2013 03:26 EST
- in response to Rahul Bhargava
I need to read more on this topic…I admiring time and effort you put in your blog, because it is obviously one great place where I can find lot of useful info
user guide manual pdf download | interior home design ideas My problem has been resolved.I do agree with all of the ideas you have introduced for your post. They're really convincing and will definitely work
-
Kios Kaos[ Go to top ]
- Posted by: Muhamad Fajar Kurnia
- Posted on: March 21 2013 13:38 EDT
- in response to Rahul Bhargava
a nice article to our knowledge in the sophisticated technology like this now, If you want to buy motivation t-shirts please visit <a href="http://www.kioskaos.net/blog/kaos-motivasi" title="Kaos Motivasi">Kaos Motivasi</a>
-
Kios Kaos[ Go to top ]
- Posted by: Muhamad Fajar Kurnia
- Posted on: March 21 2013 13:41 EDT
- in response to Rahul Bhargava
a nice article to our knowledge in the sophisticated technology like this now, If you want to buy motivation t-shirts please visit www.kioskaos.net/blog/kaos-motivasi
-
Kios Kaos[ Go to top ]
- Posted by: Muhamad Fajar Kurnia
- Posted on: March 21 2013 13:44 EDT
- in response to Muhamad Fajar Kurnia
Please visit Kaos Motivasi
-
Thread per connection : NIO, Linux NPTL and epoll[ Go to top ]
- Posted by: Adiska Putria
- Posted on: May 25 2013 13:47 EDT
- in response to Rahul Bhargava
It was great to land on this blog post and to read such amazing stuff. Your blog is full of authentic and highly-researched information that is worth reading.
Source: body massage and body scrub for further information. -
Thread per connection : NIO, Linux NPTL and epoll[ Go to top ]
- Posted by: Adiska Putria
- Posted on: May 25 2013 13:51 EDT
- in response to Rahul Bhargava
A great workout schedule is hard to beat, your fitness is your best asset. Is there any tips you could recommend for high elevation training?
Source: mengatasi kulit kering and mengatasi kulit kering for enother information. -
Thread per connection : NIO, Linux NPTL and epoll[ Go to top ]
- Posted by: Adiska Putria
- Posted on: May 25 2013 13:53 EDT
- in response to Rahul Bhargava
With exercise bike like this, I can feel the respiratory system that is better than before exercise. Therefore I think there is no harm if we change the unhealthy lifestyle that we've run with a healthy lifestyle.
Source: perawatan kulit and perawatan kulit cantik for further information. -
good post[ Go to top ]
- Posted by: ceofounder me
- Posted on: May 31 2013 04:21 EDT
- in response to Rahul Bhargava
obat dari herbal sakit maag obat dari herbal untuk nyeri sendi jual madu untuk diabetes habbasyifa murah jual habbatussasuda cap kurma ajwa obat herbal untuk sakit diabetes ekstrak sambiloto kapsul jual obat herbal dimana toko herbal yang murah tempat toko herbal jakarta toko obat herbal terlengkap herbal penurun panas dingin jual daun sirsak obat kanker kunyit obat maag alami teh kulit manggis alami ramuan dari herbal kolesterol tempat beli keladi tikus untuk apa madu randu lokasi jual madu asli tempat sari kurma jazira sari kurma sahara asli habbatussauda murni minyak zaitun beli dimana tempat madu anak syamil sari kurma al jazira premium asli obat herbal untuk kanker payudara alami teh daun sirsak mujarab teh jati daun china asli teh jati belanda alami arti syamil dates honey pelangsing herbal asli sari kurma tamr terbaik
-
go[ Go to top ]
- Posted by: hdon tabra
- Posted on: June 18 2013 07:33 EDT
- in response to Rahul Bhargava
best place to invest money yeah go cos we want u now invest money...fav song