Game clients—whether on mobile devices, tablets,
PCs, or consoles—send HTTP requests to your
servers for data, such as logins, sessions, friends,
leaderboards, and trophies. Clients don't maintain
long-lived server connections, which makes it easy to
scale horizontally by adding HTTP server instances.
Clients can recover from network issues by simply
retrying the HTTP request.
When properly designed, a REST API can scale to
hundreds of thousands of concurrent players. RESTful
servers are simple to deploy on AWS. And they
benefit from the wide variety of HTTP development,
debugging, and analysis tools available on AWS.
Nevertheless, some modes of gameplay—like real-
time online multiplayer games, chat, and game
invites—benefit from a stateful two-way socket that
can receive server-initiated messages. If your game
doesn't have these features, you can implement all
your functionality using a REST API. We'll discuss
stateful servers later in this guide. First, let's focus on
our REST layer.
Deploying a REST layer to Amazon EC2 typically
consists of an HTTP server, such as Nginx or Apache,
plus a language-specific application server. The
following table lists some of the popular packages
game developers use to build REST APIs:
This is just a sampling—you can build a REST API in
any web-friendly programming language. Amazon
EC2 gives you complete root access to the instance,
so you can deploy any of these packages. There are
some restrictions on supported packages for AWS
Elastic Beanstalk. For details, see the AWS Elastic
Beanstalk FAQs.
RESTful servers benefit from medium-sized instances
because more can be deployed horizontally at the
same price point. General purpose medium-sized
instances (for example, M5) or compute-optimized
instances (for example, C5) are a good match for
RESTful servers.
To make use of horizontal scalability,
implement most of your game's
features using an HTTP/JSON API,
which typically follows the REST
architectural pattern.
4
Language Package
Node.js Express, Restif y, Sails
Python Eve, Flask, Bottle
Java Spring, Jersey
Go Gorilla Mux, Gin
PHP Slim, Silex
Ruby Rails, Sinatra, Grape
Games as
REST APIs
2.0