How to Tune Linux Network Stack for High-Frequency Game Server Packets

A game server running Linux can perform well with a few users but may begin to drop packets as the number of users increases. If a burst of 500 or more players occurs then it can generate thousands of UDP packets in a short period of time. The Linux network stack may not be able to handle these packets as fast as they are being sent, in which case some packets might be dropped.

This may make it difficult for players to move around, make them rubberband and cause them to miss taking actions, have connection problems, and experience unstable gameplay. It’s often just the internet connection that’s the issue. It may be necessary to tune the limits of network buffers and sockets in the Linux kernel.

This is a simple guide to linux network tuning for Game Servers with some simple sysctl settings. These changes will make a server better suited to deal with high frequency game traffic.

Why Linux Drops Packets During Player Bursts

The game servers typically use UDP to communicate with low overhead but if there is a sudden change in player activity, the packet rate may exceed the rate at which the game server can handle them. If receive buffers or network queues are filled up, incoming packets may be dropped resulting in rubber-banding or delayed actions or loss of updates.

Multiple causes can be involved, such as small socket buffers, limiting receive buffer (krb) sizes, too many packets, memory saturation, limited network interface receive buffer queues, application settings and excessive server load. Take note of packet loss, CPU usage and network stats during peak loads before giving sysctl a try. Determine the loss of packets and correct the particular “bottleneck”. In some cases kernel tuning might be necessary and in many cases it might not be sufficient to solve application, hardware or network problems.

Check Your Current Network Settings

The Linux operating system has commands called “sysctl” which can be used to get and set kernel parameters.

  • Start by checking the current receive buffer limits:
  • sysctl net.core.rmem_default
  • sysctl net.core.rmem_max
  • You can also check the send buffer values:
  • sysctl net.core.wmem_default
  • sysctl net.core.wmem_max

The values affect the amount of memory to be allocated for network socket buffers by the kernel.

It’s helpful to save the current network settings prior to changing them when configuring network tuning for game servers on Linux. This will allow you to easily compare the old and new configuration.

You can save them with:

Increase UDP Socket Buffer Limits

One common adjustment is increasing the maximum receive buffer.

For example:

  • sudo sysctl -w net.core.rmem_max=16777216
  • You can also increase the default receive buffer:
  • sudo sysctl -w net.core.rmem_default=262144

These settings give applications more room to receive incoming network data.

For UDP-heavy game servers, larger buffers can reduce the chance of packets being discarded when traffic arrives in short bursts. However, bigger buffers do not automatically mean better performance. Extremely high values can increase memory usage without providing a useful benefit.

The correct values depend on your server hardware, operating system, game software, and traffic pattern.

Adjust the Network Device Backlog

Another useful setting is the network device backlog:

sudo sysctl -w net.core.netdev_max_backlog=5000

This determines the number of packets which can be queued up in the network interface’s input queue when packets arrive at the network interface faster than the kernel can process them.

During short stretches of light traffic, a larger backlog can be beneficial. This will be helpful in situations where many players are sending packets simultaneously.

But, raising this value will not solve the problem of an oversubscribed server. When the CPU is already busy handling packets, it may be better to just increase the queue size – the issue might occur later.

Check for Dropped Packets

After making changes, monitor the server during a real player burst.

You can check network interface statistics with:

ip -s link

Look for increasing packet drops or errors on the active network interface.

You can also use:

ss -u -a

to inspect UDP sockets.

System monitoring tools such as top, htop, and vmstat can help you determine whether the CPU, memory, or other resources are becoming a bottleneck.

This is an important part of linux network tuning for game servers because network problems are sometimes caused by another resource reaching its limit.

Make the Changes Persistent

sysctl -w will modify the running system, but not sure they will persist across reboots. Once you’ve tried out your changes, edit /etc/sysctl.conf and insert the changes that you want to make permanent.

Update the setting value (don’t add a duplicate setting) if a setting already exists. Here are some examples of values which can be tested for your workload:

net.core.rmem_max=16777216
net.core.rmem_default=262144
net.core.wmem_max=16777216
net.core.wmem_default=262144
net.core.netdev_max_backlog=5000

Save the file, then apply its settings by running:

sudo sysctl -p

When possible, use one change at a time. This will make it easier to determine which setting will make an actual difference with your performance.

Do Not Ignore CPU and Network Hardware

However, kernel tuning is just one of the tools to improve game server performance.

It’s possible for a powerful network server to still drop packets if the server’s CPU is unable to process them quickly enough. The more players there are, the more CPU it will consume as the server will need to handle movement, physics, game logic, plugins and network traffic.

Also, there can be issues with network interface errors, poor drivers, virtualization limits or an overloaded host.

You can get a dedicated server host cheap option that is reliable if you are looking to move a high player count game server to a new server and want more control over the resources of the server like CPU, RAM, storage, and network.

Test Before and After Tuning

Always don’t take the higher value for granted. Make moderate changes, and do a test while playing normal and intense player bursts on the server.

Compare:

  • Packet drops
  • Network errors
  • CPU usage
  • RAM usage
  • UDP socket activity
  • Server tick performance
  • Player latency
  • Disconnects and rubber-banding

When you are still getting a lot of packets dropped after tuning, check the network interface, CPU load, game server configuration and the game server hosting environment.

FAQs About Linux Network Tuning for Game Servers

Q: What does net.core.rmem_max control?

Ans – The net.core.rmem_max value is the maximum size of the receive buffer used by a network socket. If more data is coming in than can be handled, the higher it is, the more space it will have to queue it up for the applications.

Q: What does net.core.netdev_max_backlog do?

Ans – This is used to set the number of packets that may remain in the kernel input queue if the network interface receives more packets than the kernel can handle. This will only help with occasional overloads and not help with persistent overloading.

Q: Should these settings be changed on every game server?

Ans – Not necessarily. All servers are different in terms of their hardware, traffic, OS versions and game requirements. Try out the existing setup, and tweak the results slowly.

Q:How can I check whether packets are being dropped?

Ans – View network interface statistics with ip -s link and for any interface, watch for drops or errors to increase. You can also use the command “ss -u -a” to look at the UDP sockets and use tools like “top”, “htop” and “vmstat” to monitor system resource consumption.

Q:What should I do if packet drops continue after tuning?

Ans – Look at CPU usage, memory pressure, network interface errors, drivers, limits of virtualization, game server settings and the quality of hosting. When the server is continually full, you might require more powerful gear or an even better networking condition.

Wrapping Up

When a lot of packets are received in a short time frame, the Linux network settings may be important when a game server is used. Raising socket buffers and the backlog of the network device can provide the kernel with more space to manage the traffic burst. But for the game server, Linux network tuning shouldn’t be thought of as a cure-all, but as a method of optimizing the network. Take a measurement of the server initially, make small changes and track the outcomes.

When implementing kernel tuning, it is also advisable to consider the appropriate dedicated server hosting for the gaming application to ensure that it has the necessary CPU and network resources. There are ways to do this to make the system more stable during busy times if care is taken in testing and in choosing hardware to support the system. The number of 500+ concurrent players is dependent on the game, server configuration and workload.