Counter-Strike 2

Counter-Strike 2

Not enough ratings
Generating stable performance for dedicated servers under Linux
By Piksu ☁
This guide shows how to make your dedicated server performing more efficient and stable when running under Linux distributions.
   
Award
Favorite
Favorited
Unfavorite
Detecting what kind of lag server is having
When your server is on high-demand and feeling laggy you should inspect net_graph 1.
Net_graph can easily provide the most basic diagnostic information about what kind of lag you are experiencing.

Network lag can be seen as high ping or/and choke. You should aim to have ping lower 80ms for casual and under 50ms for competitive playing. Choke value describes how much networking packets are lost on way to the server and should always be at 0%. Network lag can be seen to players as teleporting, bad hit registers and been shot to behind a wall.

Underperforming CPU on the server can be seen as bad SV and Var values. Net_graph shows standard deviation for last 50 rendered ticks as "server variable (SV)". This value tells us how many microseconds server needs to render 50 ticks. For 128-tick server this value should be lower than 1s/128ticks/s (7.8ms) and for 64-tick server lower than 1s/64ticks/s (15,6ms). If these values are higher than mentioned your server isn't really running 128 or 64 ticks per second. For example, 25ms on SV means that your server is running only 40 ticks per second. High SV can be the product of a badly optimized map, too many interactions on the server to calculate efficiently or too weak CPU for the required workload. High SV causes jittering and generally unstable experience.

Var value on net_graph describes servers wait time between CPU cycles. If your CPU is busy calculating something else this shows Var. You should aim to have under 1ms Var on any modern processor. High var causes pretty much same effects as high SV.

How to fix mentioned lag causes
To fix high ping and choke you need to advanced knowledge on networking. Your ping is always related to the physical distance to the client and how many hops there are between routers. Your server should be connected to Tier-1 carrier to provide equally good connections to every ISP your clients are using. Using lower tier carriers will cause many additional hops to some ISP clients and therefore increase ping. High choke is produced by underperforming connection to the server. High choke can't usually be fixed on servers end of the connection if networking equipment is configured properly. Most useful tools to diagnose connection to the server are mtr, traceroute and iperf3. I don't cover using these tools in this tutorial so it's up to you google how to use these.

To understand what's causing high SV on your server you need to check if only the current map is causing or is it always abnormal. High entity amount on a map will cause SV to increase, example spamming weapons on pile will cause a lot of required calculations to the server which will increase the SV. If your SV is high on every map you need to examine your CPU usage.

Scrds can only use one thread so you need check if the CPU usage exceeds 100%. Most Linux distros come preinstalled with "top" command. This will list active processes and show information about them. You are interested in "%cpu" that tells how much process is actively using CPU cycles on one thread. If you have 4-core CPU your max "%cpu" is 400% but since Srcds is single threader process it can only utilize one thread so you need to keep it under 100 "%cpu" to maintain good SV. If this is the case you need to upgrade your processor to one with better single thread performance. You need over 4,5Ghz to maintain solid experience for 30 players running 128 tick. One option is to reduce servers load by decreasing tickrate.

If your Var is abnormal you need to prioritize your Srcds process to higher. This is rarely the case since newest Linux-kernels can do this pretty good automatically, so proceed with a cautious mind. To increase Scrds priority you need to edit its niceness value. You can experiment without changing it permanently with "renice" command. The exact needed command with parameters is "renice -n -12 -p *PID*" PID is your process ID which you can find on "top" on the most left column. If you are happy with the results I recommend to change permanently niceness value of the user running the server. This can be done by editing "/etc/security/limits.conf" file and adding a new line to end of the file "*USERNAME* hard priority -20" change USERNAME to correspond right user running the Scrds.
2 Comments
M 17 Feb, 2019 @ 11:55pm 
enpä tiiä en ymmärtäny tästäkää midii
PaKasso 25 Jan, 2019 @ 9:19am 
mitä vittua