Skip to the content.

Reuse Port

Since Linux 3.9.

TCP

Improved in Linux 4.6.

The socket option SO_REUSEPORT allows accept() load distribution in a multi-threaded server to be improved by using a distinct listener socket for each thread. This provides improved load distribution as compared to traditional techniques such using a single accept()ing thread that distributes connections, or having multiple threads that compete to accept() from the same socket.

socket SO_REUSEPORT

In kernel, hash algorithms are used:

socket SO_REUSEPORT using hash algorithms

UDP

Improved in Linux 4.5.

The socket option SO_REUSEPORT can provide better distribution of incoming datagrams to multiple processes (or threads) as compared to the traditional technique of having multiple processes compete to receive datagrams on the same socket.

Python Recipes

NGINX Configurations

server {
    listen 443 ssl reuseport;
}

References