Hey guys!
This is my first post here and I’m trying to have a high-level discussion/question section about dedicated servers and using database with said servers.
I’m currently doing Unity Multiplayer (Mirror): Intermediate C# & Networking course - which is pretty nice - but I have some missing elements from it that I’d like to ask about in a general way.
Let’s look at different scenarios:
- RTS games (in my understanding they work like this):
-
Client in menu: displays every information a player has: name, level, gold, shop, etc… It gets these information from the server which gets these information from a database. So when the game loads the server quires all the data it needs and displays it on the client.
-
Question 1: let’s say you’re running a successful game and you have like 10.000 players daily. Every query just to display said information would pretty much eat up every resource the database has, right? If we account for the additional queries to change player’s data it would melt down the database server, no?
-
Solution 1: Have more databases and sync them regularly, but it would create bigger problems as far as I’m concerned, no?
-
Solution 2: Upgrade the database hardware to be able to handle more requests, which is pricy.
-
-
Client in game: basically the same as in the menu, but it displays units, resources the player has in the current match, etc… These data are being saved on the server that handles the match, because it wouldn’t make any sense to save every unit’s position, gold, building positions, etc… only if there is a replay feature in which case everything is being saved every second (?) If there is no replay feature the game data is only being saved after each match, to display how many units you produced, how many resources you gathered… right?
- Question 2: Is every match being handled by a dedicated server, if so how were they being deployed before containerization? Because nowadays you can just deploy containers with your servers any time a player wants to play a match, right? Did they use one server to handle multiple matches to be more efficient?
-
For instance let’s look at Clash Royale a mobile RTS / Tower defense game. How do they handle such massive player base? Obviously they are not an indie or even a small company, so they have many resources to burn, but I’m interested in how to handle such massive data flawlessly.
-
Simulation games (like Hay Day or FarmVille or Idle Heroes)
-
So they probably work very similarly to an RTS game, but the menu and game phase is merged together. So let’s say whenever the game starts the server quires your data from the database and loads it in so it doesn’t have to make a query every time you want to do something. Let’s say you’d like to build a house that costs X gold, since the server has your gold it checks if you can build it and if you can it deducts the gold from your balance and saves the new balance to the database and the built house data.
-
Question 3: So with this thinking if you make any small change, like building, spending gold, moving building, etc… you’re calling the database. So it’s leads back to my first question, but in this case it’s even more noticeable. How do you handle so many requests?
-
Solution 1: Save data less frequently, but this would ruin the whole point of saving everything into a database, because you’d lose data if the server quits life, right?
-
Solution 2: Save less data into a database, but it has the same problem previously mentioned.
-
-
-
Question 4: How do these servers work? I mean one server obviously handles more client in this case I’m pretty sure. Do they use a load balancer server which gets every request and relays it to other servers? If so how don’t these load balancer server burn up, since they get every request?
So hopefully I could communicate my high-level questions, because I think they are pretty interesting and I think a lot of people are as interested as I am, but have just a basic understanding like me about these topics. I’m really hoping we can open up a discussion about these areas.
I’m waiting for YOUR interaction!