High Availability of Game Application
Games was always an interesting part of everyone’s life. With the advent of technology, games had become handy & could be played anytime, anywhere only with the access to electronic devices. Online games play a vivacious role in the games era of the current age.
One of the largest online sports company had their application hosted in an on-premise server. This client was intended for the migration of .Net online gaming application from On-premise server to AWS with high availability & scalability. The application was deployed in a single on-prem server that included all components like database, cache, sessions, images & the application code which overloaded the server that reduced the efficiency of the server.
- The Business team wanted to expand the game to various parts of the world. This included the decrease in latency of application, based on the expansion of user-base in various parts of the world.
- The development team was skeptical about the increase in traffic should not degrade the performance of application.
- During the gaming hours the application needs to be highly scalable to handle the traffic.
- Decouple all the major components of the gaming application for high availability. The components to be decoupled from the current server are as follows:Database, Cache & Sessions, Static Images
- Improve performance & user interaction with the game by reducing latency using CDN.
- Autoscale the application to handle the game traffic.
- The architecture design should be in a fashion that has ‘the speed as the need of the game’. This design pattern requires the architecture to be highly available & scalable.
- The testing & production environment should be isolated from each other. The application code should be tested in the testing environment & after quality tests it should be deployed to the production environment.
- For an application to be highly available, the web server should be stateless. This requires decoupling the components of the server.
- Decoupling of the components on the web server. This includes the following:
Hosting static images on AWS S3
- The gaming application had profile pictures of the users & static images of games on the site. These images were stored & served from the server. This increases the overhead of the webserver to serve the static contents every time the page is loaded.
- AWS S3 is an object storage service with high availability & durability. AWS S3 also facilitates as an image hosting service that offers an efficient method to host static images.
- The static images stored on the application server was migrated to S3 to reduce the overhead on the webserver to handle the requests on the images.
Isolation of database server with AWS RDS
- The initial architecture of the application had the MySQL database server also in the same webserver. This again increased the overhead of the server to handle the database requests too.
- AWS RDS is the managed relational database service from AWS that takes care of the database maintenance.
- The MySQL database was decoupled from the server & deployed with the MySQL RDS. This increases the security factor of the database as it was placed in the private subnet with access only from the webserver.
Isolation of caching with Amazon ElastiCache
- The gaming application had the scores & the logon sessions of the users cached on the Redis cache locally. This hinders the high availability of webserver since the cache is maintained locally.
- Amazon ElastiCache is the managed in-memory cache service that helps for faster retrieval of data. ElastiCache supports two open-source in-memory engines – Redis & Memcached.
- The caching of user logon sessions & the score boards were maintained at the in-memory cache of ElastiCache cluster. This increased the efficiency of the application when the user requests land at random webservers after autoscaling. This is a significant change to be concentrated when designing the scalability of the game application.
Improve content delivery with Amazon CloudFront
- The gaming application was gaining the fame across various geographical locations & the performance was worsening due to increase in latency of serving the images across various parts of the world. To improve the performance & availability of the application, contents should be delivered across the geographically distributed target audience.
- Amazon CloudFront is a highly available & scalable Content Delivery Network service by AWS. The CloudFront caches the static contents on the edge locations that help to deliver the contents with less latency across various geographical locations.
- The user images were stored in S3. Each GET request to the S3 bucket increased the cost & latency of serving the content from S3. CloudFront was integrated with S3 to serve the images with less latency across the various edge locations. This reduced the cost of delivering the content from S3 & increased the efficiency in delivering the contents.
High Scalability with AWS AutoScaling
- The gaming application attracts more users during the days of league tournaments. This increased the traffic hit on the game application. The server was bombarded with requests dropping the performance of application.
- AutoScaling is a feature of Amazon EC2 which helps us for horizontal scaling of servers based on various factors like increase in network traffic, CPU utilization, etc.
- The application server was configured with the AutoScaling group to increase or decrease the number of Amazon EC2 instances based on the spike or fall of traffic. This maintains the performance of the application by scaling up & scaling down based on traffic. The trigger to autoscale was provided by the CloudWatch metrics that monitors the server based on the CPU utilization.
- The application server was decoupled into multiple individual components with no single point of failure.
- Performance of the application was improved significantly with CDN & AutoScaling.
- High availability & scalability was maintained for the application.
- Cost of the infrastructure was maintained by AutoScaling triggers from CloudWatch based on increase or decrease in the traffic.