Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs.
A study of some of the current available types of game servers for our games
Some time ago, I started developing a new cars arena multiplayer game (MOBA indie style),and I found a lot of libraries to do the networking with Unity 3D Engine, I chose Google Play Game Services to start with... But, what would happen if the game get traction? Will I need to test it in real time with a huge amount of users?
Well, last year I wrote this article about MMO servers in 2013. Since then, we have new options and right now we are going to explore some of them to do multiplayer games, scalable and easy to build and maintain.
As indies we should know a lot of tools, now servers are another tool in our toolset, we can mount a server for big data storage and use external server for real time. Let's explore the kind of servers you can choose nowadays: web servers and socket servers.
HTTP (Web) Servers
This first kind of servers is perfect if you don't need realtime action, to just read/write data in a NoSQL DataBase, in fact, you can make a social game with it: HTML5 games or those Flash games like The Settlers Online, Facebook games like FarmVille 2, and so on. You also can make the same game with a multi-platform engine or different clients with the same API.
The same goes for MOBAs, the game can be made in a multiplatform engine using this server to store persistent data and a small part of the game server logic.
Now, choose between a lot of different server options:
JavaScript server:
node.js, etc. : JavaScript for code , JSON for data that can be stored in a mongo DB or HBase,Cassandra, Couchbase,etc. you choose. This type of server is good if you need a design with a big scalability, to handle hundred of thousands of users at the same time.
Apache Server
(a server set like lamp),PHP for scripts and MySQL,MongoDB,MariaDB,etc. for data. It is not good to handle millions of users but it will work well for a smaller number of users.
angular.js is a javascript framework for web apps you can use.
There are other versions of Apache if you can choose the faster, maybe better for your project: nginx, Lighthttpd, Cherokee,etc. Hadoop as filesystem.
Java Server
- Glassfish:
Java. Good for engineering, not cheap though.
Others
- External cloud server (third party): API using JSON or XML : fast development, not cheap
- your choice: search and you will find more options
Web server logic
Once you have your server online, you need the server side logic, and another layer to communicate with the client in the game using http/s ports you have to decide the plain text data format : XML, plain text, JSON, serialized data with your own format,etc, and try to connect to it and download data (POST or GET method).
It is recommended to encode your data to travel from point to point over the Internet, you can use your own function with base64 and md5, sha1 for hashing and veryfing data integrity.
Example: The Settlers Online encryption for urls and sent/received data chunks , they use different servers in subdomains for each purpose, chat, multimedia, data, etc. A good idea if you have to deliver a big amount of data per user (images, sounds, texts,...) is to use a CDN and this also allow parallel downloads using threads like browsers do, increasing the overall broadcast speed and it uses the nearest physically server to the client (less physical distance = less latency / hops).
As start point you can go with a single test, like, get a data set from your data model, and then do more complicated things gradually, like checking what friends are connected and retrieve their last positions,messages, and other information to be used in the current scene...
Engines to use with your web server
The engines I used to do the tests
ShiVa 2(example)
Unity 4.6 ( example )
Unreal4.
You also can use a Simple WebSocket server,
XML API for ShiVa, libwebsocket for Unreal.
If you choose an external server from a big company as a service, these are the prices, for example: Parse, Google App Engine,Amazon,MS Azure, etc. ,to summarize check this table from Mongolab ...if the game reaches 500k-1M users, it is going to need a High Replication Data Service for the server/cluster (like the one in those examples) or your server is going to get disconnected.
Pros:
- if you use your own server it's really cheap, until the number of concurrent users reach the limits
- Easy and fast to code
- There is a lot of documentation, other examples and everything you want to dosomeone did it before
- The scalability for this system can be easy, also you can move the server to another place with no big consequences
- You don't need extra libraries for each platform, just open a http socket, send/receive a call from your server logic and you are done
- Configure security for this server can be done with server rules, basic security stuff, and external services like cloudflare (avoid ddos attacks)
Cons:
- Design the scalability strategy must be done at the beginning, so we wont need change the architecture
- A server with high capacity can be expensive
- It requires to write all the logic in both sides
- Servers can go down even with protection, and if our game depend on it you can figure out what are the consequences.