Cause
Many of the online views on high server selection, there are many controversies, such as C and Java comparison, Epoll and libevent comparison, arguing. Including Gleasy's own middleware, and often criticized and questioned, received the most is about the use of language, Gleasy middleware Most of the use of the Java language, based on the MINA2 framework, and our internal through a lot of stress testing and validation also proved to be extremely high performance. There are a lot of introductions to this blog in other articles.
But is it possible to take a hundred-foot head and go further? For example, the use of C language and C-language development library, what is the situation?
As a result, the Gleasy architecture group has done a series of experiments to verify the performance of some of the current mainstream High-performance network server development libraries.
Experimental data
Experimental 1:epoll (multiple worker threads, multiple threads sharing 1 Epoll,snapshot) C language
Experiment 2:libevent n+1 Thread (one event-loop per thread) C language
Experiment 3:mina2 (Java language)
The experimental results are shown in the following annex: Download test file: Http:/file.111cn.net/upload/2014/3/a.doc
Conclusions
CPU Footprint Comparison Chart:
TPS Comparison Chart:
Explanation of the two images:
1. From the TPS (the request data processed per second), there is no essential difference between the three, the MINA2 framework based on the Java language is absolutely not lost in the C language Epoll and Libevent on TPS. And the performance of these three guys is very cow, from the figure can be seen, when the concurrent connection in 1000 or so, TPS can reach 300,000!
2. The epoll has an advantage over either TPS or CPU occupancy rates. This is expected, after all, libevent or MINA2, in Linux, the final use is also epoll mechanism, so as long as not to avoid low-level errors, native Epoll in performance and CPU consumption will inevitably prevail.
3. Libevent and MINA2 have done a lot of encapsulation work on epoll basis, such as EVENT,MINA2 of libevent buffer codec, which inevitably result in extra CPU overhead. The Java-language based MINA2 has a significantly higher CPU overhead than the C-language alternative. There are even nearly twice times the difference.
4. We are in the development of complex server applications, some basic work must be done, such as buffer, such as codec, the work we do ourselves, or to libevent or mina2 to do, always have to do, is not avoidable, and we ourselves to achieve, Its efficiency is unknown. So we will choose to use a higher level of closure, on the one hand reduce the workload, on the other hand, to avoid unrelated errors occur. From this point of view, in the selection of technology, the combination of choice, business simple but the performance of extreme requirements of the scene, you can directly use the C language and epoll, business complexity High engineering needs, you can choose the Java language and MINA2. Or the old saying that the millennium unchanged, never the best technology, only the most appropriate technology. Others say is always the experience of others, their own hands to try to prove that the most authentic!
Original: http://rdc.gleasy.com/