One of the biggest problems indie game developers must solve when designing their game is deciding how the multiplayer is going to work. Do you have to run dedicated servers? Can you use peer-to-peer networking? Let’s talk about it.
This article focuses on the general infrastructure behind your game, rather than the exact details of how to get multiplayer networking working, as that will depend on your engine and how your game is programmed.
Consider Whether You Need to Run Servers At All
Some games can manage without dedicated servers. If you’re building a game that’s mostly player-to-player interaction, without a ranked competitive system, you may not need servers at all.
For example, Minecraft does this particularly well. You can play by yourself, on a local network, connect to servers hosted by other players, or host your own server. Of course, this does require a community backing and players interested in hosting their own servers in the first place, otherwise it’s too much of a hassle to ask of your users. A hybrid system has worked for Rust; the developers run a few official servers, and the community runs their own on top of them.
Besides having your community host servers, the simplest method of serverless architecture is the listen server model. With the help of an online subsystem like Steam, people can form their own lobbies, either by joining their friend’s game, or finding and joining globally open sessions from other players on Steam.
Usually, the person who created the lobby is the leader. They are selected as the server, and everyone connects to them. The lobby leader’s computer becomes an ad hoc server, hosting the session for everyone in the lobby. This gets rid of the need to run servers entirely.
If your game follows a more match-oriented gameplay, like a 5v5 shooter game, you mightwant a dedicated matchmaking server, designed solely to sort players into lobbies based on their stats (and not handle the actual gameplay). This would allow you to make the process of finding games automatic, and also implement your own matchmaking rules. You’ll need a server like this anyway, even if you don’t use a listen server model to run the games.
Drawbacks of the Listen Server Model
The listen server model is fantastic, and great for indie games that want to build multiplayer without having to pay for dedicated servers. But it’s got two major drawbacks—cheating and lag.
The first is obvious. If you have 5v5 matches, even if you randomly select the server host, any given player stands a 10% chance of being chosen as the server. If they’re the server, they have full control over the entire game, which makes the listen server model entirely unfeasible for a competitive game. Imagine Counter Strike, but every few matches you have someone in god mode on the enemy team, noclipping and killing everyone. Not fun for you or your players.
This really can’t be mitigated, but the effects of it depend on the type of game being played. Maybe your game is an online board game that’s just played for the fun of it; there isn’t much use to cheating during a game like that. With a decent report system, you can handle the few instances that do pop up, especially if your game isn’t that big. This type of anomaly will be easy to detect, and it’s unlikely that someone would go to the effort of developing cheats unless your game is big enough to afford dedicated servers anyway.
The second drawback is a much bigger issue for smaller games. If the computer chosen as the listen server isn’t that powerful or has a poor internet connection, the experience can be laggy. This can be mitigated with an external matchmaking server that chooses the best listen server out of the lobby, based on PC specifications and internet speed. This can’t really be implemented with the stock Steam subsystem—the person who started hosting the lobby will always be the lobby leader in that case.
Either way, it’s not uncommon at all for small games to use the listen-server model, as it’s essentially free for the developer. And while it’s expected of bigger games to have dedicated servers, they don’t always—For Honor, a AAA title from Ubisoft, didn’t have dedicated servers at launch, much to their player’s dismay.
Dedicated Servers Really Aren’t That Scary
While spending a monthly fee as an indie developer to upkeep your game sounds taxing, it may not be as bad as you think. Say your game runs 5v5 matches. How many matches do you expect to be running at one time? If you’ve got 100 active players, that’s only 10 matches.
If you’re game’s not too intensive, it can likely run off of a single thread. A quad core server with hyperthreading could theoretically run 8 simultaneous game sessions. You’ll definitely want to do testing to verify how many sessions a given server can support, so you can get a feel for how much power you’ll need.
And if you’ve got 100 active players, you’re already doing something right, because you’ll have orders of magnitude, more people who have bought the game but aren’t playing it 24/7. For example, Rust has sold over 5 million copies, but only sees around 50,000 people active at any one time—100x more sales than daily active players.
So, with 5v5 matches, and 100 active players, you’ll need a server capable of supporting 10 matches. Maybe you find that a six core server with 64 GB of RAM can easily run all your matches. You can find a dedicated server with those specs for around $80 a month. If you have 100 active players on average, you’ve definitely sold at least a few thousand copies, so you’ll certainly have the money to spare on giving your players a good experience.
If you don’t have that many players, you can probably run everything off a much small server, which brings your costs down significantly. If your game really takes off to the point where you start seeing your margins decrease, you can always look into alternative monetization options; cosmetics (like weapon and player skins) are a common choice; they give dedicated players something to spend money on, which gives you consistent monthly revenue to help offset the cost of the servers.
The Cheapest Option—Rent a Dedicated Box or Two
With virtual servers, memory comes at a premium. If you compare the prices of AWS or Google Cloud Platform to the price of renting a dedicated box from a smaller company, you’ll find you’re being charged way more for the same amount of memory on AWS. This is a problem, especially for games, as memory is often the limiting factor for a server being able to run more sessions.
A “dedicated box” simply means you’re renting the actual hardware itself. You rent a whole rack out of a datacenter, which means you don’t have to deal with virtualization overhead either.
This sounds more expensive, but often, it’s actually much cheaper. If you don’t need top-of-the-line servers, you can rent older hardware for huge discounts. After all, old hardware used to be top of the line; when huge VPS providers like AWS upgrade to newer servers, they often sell off some of their older hardware. (You can actually buy them yourself off Ebay, more on that below.) Really, an older server may only be 10% or so less performant than a new server, but when it’s half the price, it’s a great deal.
The Scalable Solution—AWS GameLift
While AWS is more expensive, it does come with some great benefits. AWS GameLift is a service that makes running game servers on AWS’s EC2 compute platform much easier.
GameLift is basically a fancy version of EC2 autoscaling. It will automatically spin up new instances when demand gets high, or terminate instances once they’re not needed, such as overnight when people aren’t playing. It’s practically the perfect use case for autoscaling; from the GameLift console, you can define the type of instance you want to use to scale with, and how many game sessions that server can handle.
This helps offset costs significantly when, compared to dedicated servers, and when combined with EC2 Spot Instances, can make running on AWS a viable option for a fairly popular game. The cost per hour is higher (AWS is expensive), but you spend far less time actually running servers, as your architecture will scale to meet demand exactly.
GameLift even includes a basic matchmaking system, which gets rid of the need to run a seperate matchmaking server. Players join a queue, and the GameLift matchmaking sorts them into sessions based on rules you define. If a new server is needed, one will be spun up.
For small games that don’t need more than one server, AWS GameLift is a bit overkill, but if you’d still like to be on the AWS platform, you can reserve EC2 instances with a one year contract for about 40% cheaper than On-Demand. However, this still doesn’t get anywhere close to the bang-for-your-buck that a cheap dedicated server will get you at other companies, so only spring for a reserved instance if you really love AWS.
If You Like Noise—Buy, Don’t Rent
There’s a reason old dedicated servers are so cheap: Data centers sell their old hardware on Ebay all the time, often for massive discounts. In the server world, the hardware itself is a trivial cost. The main money sink is the massive power bill associated with running the server, and the cooling required to chill the thing to a reasonable operating temperature.
If you were to go out and rent a dedicated server from SYS, you’d be paying about $84 a month for a 6 core Haswell (2014) Xeon with 64 GB of RAM and a few TB of storage space. This is already an extremely good deal for a server of that size. Compared to AWS’s r5.2xlarge with 8 cores and 64 GB of RAM (the RAM is what’s important here), you’d be paying over $250 per month even with a year long contract, not to mention the extra $50-$100 or so for a comparable EBS volume.
So with the SYS server being such a good deal, how much do you think it would cost to buy a comparable one of Ebay? The SYS server costs over $1,000 per year, so around $500-$700 or so might be a good estimate, especially considering the Xeon processor alone sold for over $600 retail, not to mention the cost of the RAM, drives, and assorted components.
Nope. Here’s a listing off Ebay for a rack with the same specs for $70 with free shipping:
You might be hopping at the opportunity to buy this up, but there are a few things to consider first.
First of all, you don’t want to put this thing in your bedroom. Servers are loud. They’re meant to go in a datacenter, and computers don’t have ears. You might be able to get away with putting it in your basement, but don’t expect to leave this in your bedroom closet, especially a 1U server, which have tiny 40mm fans that have to spin a billion times per second just to cool the thing.
And while the hardware is cheap, the power isn’t. A server like this will draw 100-200 watts while idling, and can peak over 500 watts, with some core-heavy servers being able to draw a whole kilowatt of power when fully loaded. If you’re not experiencing insane load though, you likely won’t pay too much for power, but expect your bill to go up by $10-15 per server.
And lastly, there’s the question of whether or not you can even run the servers from your home. Most home internet plans are not well equipped to do so. Not only is it usually against the ToS, but you won’t have a static IP address, making networking very difficult. You will want to look into the business plans that your ISP offers if you’re seriously considering buying your own server.
If you do want to buy your own server, you should check out LabGopher, an aggregation service for finding used servers will allow you to browse Ebay listings more effectively.
Usually, you can find really great servers for less than $500 or so. The server in the comparison above is an exceptional deal, but isn’t entirely rare.
You don’t have to host them from home though. There are providers who specialize in hosting other people’s hardware, called colocation services, which will hook up your server in their data center, complete with power and networking. This is an extreme option and a fairly serious commitment, but it can make sense in certain situations.
Colocating a single 2U server will cost you a little over $100 per month. If that server is very powerful, that cost can be much lower than what you’d pay renting a dedicated server of the same caliber. Keep in mind, though, that many colocation services will charge based on power usage, so you’ll want to do your research first before colocating.
Backend Service Options—Google Firebase, RethinkDB
This last option is for a special-use case. If your game only really needs a simple backend, you might be interested in a rea-ltime database. Real-time databases update instantly, and push updates to subscribed users over websockets. They’re commonly used to build apps like Google Docs, where the real- time communication of information is key. This option works particularly well for mobile games, where ultra-low latency, fast action, and complicated processing aren’t really required.
Firebase is a managed service from Google. It started as just a real-time database, but has since evolved to be a whole platform for the backend of mobile apps. There’s a free tier, a $25 tier which should be enough for most smaller apps, and a pay-as-you-go plan that charges based on usage.
RethinkDB is an open-source database built with real time in mind. You’ll have to run it on your own server, but the processing power RethinkDB, plus a cheap dedicated server, should prove to be more than enough backend for most things, unless your application experiences a lot of traffic.