Archive for the ‘Performance’ Category
Concurrency And Server-Side Networking APIs — Part 3
Thursday, October 30th, 2008Concurrency And Server-Side Networking APIs — Part 1
Sunday, October 26th, 2008Introduction:
This article explores how a Sun Hotspot JVM behaves when accepting incoming TCP/IP socket connections. The behavior of native server programs–written in C–are also explored to better understand how concurrency can be achieved. Then, a comparison of how these runtime environments implement server-side networking is explored. Finally, a brief introduction to how these concepts are used in the construction of J2EE Container architecture is given.
This article looks at the system calls involved in listening on sockets and accepting incoming connections. Also, how these system calls behave with a single threaded server, multi-threaded server, or multi-process server. Then, switch gears towards how the JVM behaves when multiple Java threads attempt to accept connections from the same server socket. Finally, I discuss the design considerations that need to be taken into account when implementing server-side software with Java.
The Linux 2.6.25 kernel was used to develop and test the programs presented here, but the results should hold true for Solaris and most other Unix variants. The Posix Thread library is used for all multithreading in natively compiled C programs. The GNU GCC compiler is used for compiling all C code. Java 1.5.0_15 is used for all Java examples. The TomCat web container inside of a JBoss v3.2 J2EE container is used to illustrate many threads accepting connections from the same listening end point.
I admit that I am getting away from my usual format where I keep the material on thinkmiddleware.com strictly at the JVM, Java language, and J2EE Container level (or higher). But, there is an important point regarding how the java.net library limits how java.net.ServerSocket objects behave, which I want to capture. To truly capture that point, we’re going a little further down the technology stack than normal.
This article is a rewrite of a brief document I put together during my Masters project in February, 2007.
This article does not present best practices for server-side design architecture. These examples are purely for illustration purposes to demonstrate the point this article is attempting to convey. See [1] & [2] for a thorough discussion of network programing Design Patterns and the Java language.
