How do gaming servers work?

All multiplayer games have servers. Even though they all share the same principle(working as a bridge between clients, for communication), they have lots of differences too.


Here I wanted to ask: How a game server works?
Mostly importantly, how the following things work and what purpose they serve:

-What is server tick rate?Why servers have those?(Because at least in my project, the server answers as soon as it can, but many games have servers answring, at best, once every 16ms[tick rate of 60hz])

-What should be handled on the server side, and what should not? What are the pros and cons of a system that handles most things on client side over another that handles on server?

-Do communication between server and client need to use safe protocols?(In my case, WSS, or "websocket secure", but lets discuss a general case)Or a standard protocol is enough as long as there's no information about login and/or accounts being sent?

-How strong machines need to be to handle servers?(As long as the server isn't running within the game itself, but in a separate, much lighter, software)What about connection speed? Is it more important to have better ping or higher speed?

Feel free to expose your view on other ideas related to game servers.
-What is server tick rate?Why servers have those?(Because at least in my project, the server answers as soon as it can, but many games have servers answring, at best, once every 16ms[tick rate of 60hz])

Broadly, this is the rate at which the server updates the game-state and attempts to inform clients about it.

There are two reasons why this is capped. Firstly, it's because a game server might handle connections to many players (remember that a "server", i.e. the physical computer hosting a game, might run dedicated servers for multiple instances of a game, or even multiple games) and because due to internet latency, games do a lot of "dead reckoning" to try and smooth over the interruptions/un-even-ness of the server's info.

A lot of multiplayer gaming is smoke-and-mirrors. If you were to watch a video of two clients side-by-side in many games, you'd be surprised at what is (and isn't) synchronised.

Usually the tick rate is set as high as it can be (to give the best experience), while also being as low as it can be (to avoid being wasteful). This is interesting in Battle Royale games like Fortnite, because I believe that game's "effective" tick rate actually increases as players die (some aspects of the game "tighten up" as there are few players for the server to deal with).

-What should be handled on the server side, and what should not? What are the pros and cons of a system that handles most things on client side over another that handles on server?

This is an age-old question in multiplayer gaming with no firm answer. What should be handled in what area must (1) prevent cheating and (2) try to conceal the realities of networking from the player/to facilitate the game.

An example you might find interesting is how the original Planetside worked. Planetside had a very strong bias towards "client-side" hit detection, where the client would inform the server about more than, for example, would be the case in Counterstrike 1.6 (a game which existed around the same time). This led to problems, though.

In Planetside 1, say I had a good connection. I would run into an area, see another player, take a pot-shot and dart behind a wall. Then, suddenly, I die. Why? The reason is because the other player has a bad connection. When I take cover on my screen, they still see me on theirs, running a hiccup-y second or so behind my view. They shoot me, and hit me, and inform the server they've hit me... So I die.

Now, this felt bad. Even at the time, there was no question this felt terrible. However, Planetside was running ~200 player battles in 2003, so we just kinda accepted it, because those battles were so epic.

-Do communication between server and client need to use safe protocols?(In my case, WSS, or "websocket secure", but lets discuss a general case)Or a standard protocol is enough as long as there's no information about login and/or accounts being sent?

Sadly I don't know this; I'm not an expert on network security.

-How strong machines need to be to handle servers?(As long as the server isn't running within the game itself, but in a separate, much lighter, software)What about connection speed? Is it more important to have better ping or higher speed?

Servers can be quite primitive machines to run a single dedicated instance. I remember back-in-the-day (like in the days of Unreal Tournament 2004) it was the norm to use an older computer. Dedicated server clients are pretty light.

In terms of internet connection, bandwidth is less important because multiplayer games generally consume very little, even for a server (especially by the internet standards of today). The main things are latency/ping, and consistency of your connection. If your connection is highly variable, this creates a bad experience for users. As for latency, you can't really control that, as it's based on distance (also the number of "hops" your packets make to get between the client and the server; generally more hops = more latency though that's a bit of a simplification).

The last thing I'll say is that I know I'm talking about Planetside and Counterstrike 1.6, but bear in mind that while many aspects of gaming have moved on since the 2000s, the aspects of networking for gaming for broadband users haven't, really. Fibre might get you slightly lower latency but ultimately it's quite similar now to how it was in 2005, as long as you're on broadband.

The analogy here is that while my internet connection here has tons more bandwidth than it did in 2005, it's like a road filled with cars. Bandwidth might give you a wider road, with more lanes, allowing more cars to travel - but an individual car still only gets to its destination in the same time (same speed, same distance).

Anyway, I hope this is helpful.
1) server tick is needed for synchronisation and to prevent players with fast machines to gain advantages.
Some people have slower connections or slower machines and if the server answers as fast as possible there is less bandwidth and less processing available for those who are disadvantaged in their hardware.
With a tick, no one gets more than one answer per tick.

2) the entire game processing (positions, what does which player do, etc) should be handled server-side, with only display and control routines working on the local computer
Everything else would result in sync-errors, for example if one player is already gone by the time a second player tries to interact with the first. Or questions on who opened the loot box first and so on....
To prevent that the server needs to tell the client where every player is.

3) yes, you always need a secure and encrypted connection.
Because otherwise players will start to cheat by inserting bots into the connection or trying to gain other advantages - from automated goldfarmer bots that don't need to launch a client to control a pseudo-player from performing low risk grinding action to background programs that read the position of other players through walls to make them visible only for this player and so on.

4) servers need to be able to handle game processing, but they don't handle display details. That means they need a lot of CPU and RAM, but not much in the graphic department. They also need to store all data of the game, but HDD is cheap.

5) the difference between ping and speed depends on the game. action games with low data amounts need a high ping to prevent lag from stopping players - they don't need much data transfer if there is only a small map known to all computers where the player battle.
on the other hand games that have much details and do not require fast player reactions (like turn-based strategy or non-action RPGs) can handle lower ping but need to transfer a lot of data fast.
On gaming servers server tick rates are very important, because 1. to a small degree they prevent botnets from crashing them and 2. ensures slower and lower frequency computers aren't in a disadvantage compared to a faster machine.
On server side you should handle everything you don't want to be cheated by the client. The more you handle, the more powerful machine you're gonna need. Also depending on how much you handle you may also prevent pirates from reverse engineering and recreating your online lobbies. The less you handle, the less powerful machine you need. But the players can cheat more with it. For example on CSGO you can cheat your location. But what you can't cheat is your HP.As for how strong your machines need to be to handle servers, that is impossiblr to answer. Not sure how worked out you'll get them, so...
Between low ping and high connection, you always need low ping to be competitive. Then it depends on the lag correction algorithms who will they screw over. High speed connection only matters when transfering large amounts of data though. Sending basic packets back and forth usually is not too much bandwidth used, so speed is not that bad, but some games may require it.
Hm... So tickrate is necessary for clients sync. But, if my game runs at 60fps at best(MV games' case), is it necessary? Because then, most information will be sent and received at a 60 tick rate, which is average nowadays for servers.

3) yes, you always need a secure and encrypted connection.
Because otherwise players will start to cheat by inserting bots into the connection or trying to gain other advantages - from automated goldfarmer bots that don't need to launch a client to control a pseudo-player from performing low risk grinding action to background programs that read the position of other players through walls to make them visible only for this player and so on.

Well most of this applies to MMORPGs and ARPGs(such as PoE and D3). But in PVP, Top-down games, is it necessary? Take CS2D for example: most of the time you'll be able to see other players "through" walls anyway, and everyone will receive everyone else's position information. How can people abuse unsafe protocols here?

In Planetside 1, say I had a good connection. I would run into an area, see another player, take a pot-shot and dart behind a wall. Then, suddenly, I die. Why? The reason is because the other player has a bad connection. When I take cover on my screen, they still see me on theirs, running a hiccup-y second or so behind my view. They shoot me, and hit me, and inform the server they've hit me... So I die.

Now, this felt bad. Even at the time, there was no question this felt terrible. However, Planetside was running ~200 player battles in 2003, so we just kinda accepted it, because those battles were so epic.

I see the point. But what if it was the other way around? If the player had to detect if they were hit before sending to the server, someone with lag would never kill anyone else. Also, if it was all handled by the server, lagged players would once again have disadvantage.


This brings up the question: Is is bad to favor players with better conections? Because after a certain point(Lets say, under 50~100ms ping), what counts the most is skill. If you can't defeat someone because its connection is better than yours, you probably should try playing in another server or getting a better internet/PC, right? It's not the server's nor the game's fault.
Tick rate is necessary unless you have the game fixed at 60 fps due to monitor refresh rate. Yanfly's 60fps synch works for graphics, but the engine itself still runs at the monitor's refresh rate. Then they kinda fail the purpose, but then again, might be useful for dealing with botnet attacks for a bit.
A game server (also sometimes referred to as a host) is a server which is the authoritative source of events in a multiplayer video game. The servertransmits enough data about its internal state to allow its connected clients to maintain their own accurate version of the game world for display to players.
A game server (also sometimes referred to as a host) is a server which is the authoritative source of events in a multiplayer video game. The servertransmits enough data about its internal state to allow its connected clients to maintain their own accurate version of the game world for display to players.

Things are more complicated than that. Not all games have a server as the only source of events. In some games, clients control this to some degree. The downside to this is that cheating becomes easier, but as an upside ping becomes less important. Some games use a mix of server and clientsided events. Minecraft, for example handles boat movement on the client. This is why boat fly hacks exist in Minecraft, but it also means that moving in a boat feels more natural even if your ping isn't the best.

Then there's GMod where there are three classes of events: Server, Client, and Shared. It should be pretty clear what these three are. Shared events are sometimes predicted to reduce the impact of latency. This is especially important for movement and realtime actions. Turning off client-side prediction results in rather choppy movement.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-gaming-servers-work.106319/