Multiple servers with their own core

Hey, I host Garry’s Mod servers that are busy 18+ hours a day and have decided to move to a VDS from NFO.

With this change, I need to set each server to a certain core it runs on. You may say why don’t I just let the OS handle it? Well, at peak points the server CPU is at 55% - 80%, and I run a couple of servers at this peak 18+ hours a day. When a CPU is maxed out, the server hops over to the second core and starts using it which throws back mini lag spikes I don’t like.

I successfully started up the server, and set the core using taskset. But the problem is, as soon as the server crashes or I restart/update it then its PID changes and I have to re-enter the taskset command. I’m not here 24/7, so I can’t be doing this all the time when one of my servers crashes.

What I need is a way to start up my servers and automatically assign it to core 0, core 1, and so on without entering the command. Just run a .sh script, and boom the server starts up and is assigned to its core. The VDS is a 4 core, with Debian 7 as its OS. There are 4 total servers on the machine. Two of the servers are 25+ players busy 18+ hours a day, the other two are 8 player slot servers.

I have searched on Google, of course, before making this post to annoy you people. But all I found was how to set it with the current PID and when it’s already running. I found two posts on this forum that seem useful:

For the second post, I created the re-spawning script and put it in the server directory. For the first post, I tried doing

taskset -c 0 /home/steam/servers/server_test/

…but it spat out “No such file or directory.”

I am completely stuck and I don’t know what to do now. Obviously there are server owners out there that do this, but how exactly? How would I have the server automatically assigned to core 1 on start up by running a .sh script or something? And when it crashes, it re-assigns itself and such?


[editline]4th May 2014[/editline]

I am dumb, but I figured it out.

I was supposed to CD to the directory of the .sh script, and then do

taskset -c 0 ./

On the first post I provided, it says it will always remain on core 0 even if the server crashes. I have to wait and see if this is true or not…

I highly discourage you to provide a static core to the server which it always runs on. The reason the linux kernel does core hops is because the core the server currently runs on generates heat, and when the core becomes too hot, it simply swaps SRCDS to one that’s colder.

Are you sure it balances it’s load based on temperature? I was fairly sure it depended on the usage per core, not temperature.

It depends on both the usage and temperature. Windows does this too.

Yes, you’re right about that.

But it swaps way to often. In net_graph 4, all you see is mini lag spikes when server 1 is 24 players, server 2 is 29. Both servers experience mini lag spikes as they are continuously hopping.

When I assign each server to a core, it runs flawlessly. And the cores I own on the machine have enough time to heat down during night for about 4 hours until player counts go up again.

The core increase in heat in a matter of seconds.

Well, there’s nothing I can do about that.

I am going to wait and see if the new method I used will still have the server remain on its cores when it crashes.

I’ll post back if it doesn’t work.

Could it be an O/S issue? I run 4 busy servers on the same box with 8 cores without these kinds of issues.
I’m sure game providers don’t fiddle with cores and customers don’t get random lags like that.

I’ve been told by multiple providers that they let the OS handle everything and do not give people their own dedicated core. Some providers may pin you to a core, but if the server’s load is quite high and some other server gets assigned to your core, you’re screwed.

The problem with these random lag spikes may be because the VDS it runs on is a 4 core, and since servers are above 50% cpu for a long time. There are barely no resources left on the machine.

Probably if I upgrade to a 6 core it may stop without having to set taskset, but for now taskset solves the solution and minimizes lag spikes to 0 and saves me money.

When I expand in servers in a month or so, I plan to change to a 6 core hosting 5 busy servers. I’ll test again and see if these lag spikes still occur without taskset set.

Solution works, thanks for the help.