New way of writing socket servers in #Linux kernel 3.9 (and in#Python too)

V

vasudevram

This may be of interest to readers of this newsgroup:

Original article:

http://lnkd.in/taAFNt

Content (without links):

A new way of writing socket servers has been introduced with the Linux kernel 3.9.

It involves the ability to bind multiple listening sockets to the same porton the same host, by unrelated processes or threads. The socket option is called SO_REUSEPORT.

Article about SO_REUSEPORT.

The above article includes a demo of how to use the feature in Python, using the example of a simple echo server and netcat.

Another article about SO_REUSEPORT on LWN.net by Michael Kerrisk.

Hacker News thread about SO_REUSEPORT.

About Michael Kerrisk. He has worked at DEC (Digital Equipment Corporation)and Google in the past.

Coincidentally, I happened to have come across Michael Kerrisk's Unix and Linux work some months earlier and had emailed him with a few questions about it, which he was kind enough to answer.

Kerrisk is the author of the book The Linux Programming Interface, which seems like an interesting and useful book.



From the web site for the The Linux Programming Interface book:

[ The Linux Programming Interface (published in October 2010, No Starch Press, ISBN 978-1-59327-220-3) is a detailed guide and reference for Linux andUNIX system programming.

With 1552 pages, 115 diagrams, 88 tables, nearly 200 example programs, and over 200 exercises, TLPI is the most comprehensive description of Linux andUNIX system programming available. The author, Michael Kerrisk, is the maintainer of the Linux man-pages project, which documents the Linux kernel and glibc APIs. He has long been active in the documentation, testing, and design review of Linux kernel-userspace interfaces. ]

And if you want to write command-line programs in Linux using C (an area closely related to the topic of the TLPI book), you may wish to check out my article on the subject, written for IBM developerWorks:

Developing a Linux command-line utility.

I have not yet tried out the SO_REUSEPORT option, because I need to get Linux kernel 3.9 first, but it seems like a useful technique for increasing performance of socket servers. Note that there are various other issues involved, so you may not get increased performance just by using this option in your code. As always with performance tuning, you have to profile your code, identify hotspots, and then only work on improving certain parts of it that seem to be the bottlenecks. And in this case, even before all that, you may need to evaluate whether this socket option is relevant to your application at all. So, caveat lector :)


- Vasudev Ram - Dancing Bison Enterprises
 
M

Michael Torrie

#Linux, #Python? This this hash tag stuff is getting out of hand, don't
you think?
 
B

Benjamin Kaplan

#Linux, #Python? This this hash tag stuff is getting out of hand, don't
you think?

Didn't you hear? In an effort to redefine itself for the modern
Internet, Usenet is adding support for hash tags and limiting posts to
140 characters because kids these days just don't want to read
anything longer.
 
M

Michael Torrie

Didn't you hear? In an effort to redefine itself for the modern
Internet, Usenet is adding support for hash tags and limiting posts to
140 characters because kids these days just don't want to read
anything longer.

Sweet. And here I thought it was irc channels.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top