The Battle for America’s Army 3
From the original Xaede archive. This is historical writing, preserved in a new reading edition. Technical advice, tools and project status reflect the time of publication.
This blog details my personal experiences with keeping the various systems that run the Unreal Engine 3 game title America’s Army 3 (AA3) running during and after the initial launch on June 17th (please refer to my previous blog post for a detailed description of the various back-end systems I designed and lead a team of developers to implement).
These systems include the following:
Authentication – the system to persist player account information, player profiles, character information (a “soldier” in AA3) and retrieve statistical summaries.
Attribute Tracking System (ATS) – the database-persisted rule-based character progression management engine.
Statistics Tracking System (STS) – a system for collecting in-game events, applying distributed massively parallel processing (MPP) statistical summarization, and persisting the results to a central database repository.
Master Browser System (MBS) – a system for tracking the state of online players and servers while providing an interface to allow a player to find a server adhering to user-specified criteria to play on.
Dynamic Content Delivery System (DCDS) – a system to delivering game assets to the game engine during play based upon game state and play events. It also provides the network for downloading the game via the Deploy Client application.
The various server components of AA3 use a specialized session-server system code-named Titan designed to both persist player and game related data across the cluster of servers as well as act as a cache for common Oracle queries. One of the first problems we discovered after launch is that the load radically escalated on Titan to around 3,000 transactions per second as the game was downloaded and gamers began to login and play. As a point of comparison, a typical Apache web server installation on Linux will degrade in performance rapidly past the threshold of a few hundred transactions per second.
Given that Titan uses a PostgreSQL database for local data storage, the in-memory caching system for Titan objects was not able to relieve enough stress on the database to prevent Titan from rapidly degrading in performance. In order to correct this, I first performed a hand-tuning pass on the PostgreSQL database configuration file to allow it to take advantage of the 8 GB of RAM on the Linux box it was running on. I then made a pass on the SQL that Titan was using to communicate with PostgreSQL, and enhanced the database schema to only create the indexes required to support the various where clauses. I then restarted Titan and PostgreSQL with the updates and continued monitoring.
Using information gathered from utilities such as “top” and “vmstat” as well as Titan’s real-time status-reporting system, I was able to determine that the performance had not increased to the point where Titan was able to execute low-latency transactions, so I decided to take advantage of the generous amount of RAM on the Titan system. I created a filesystem on Linux that was mounted against the systems’ memory – a ramdisk. I then moved the PostgreSQL database files onto the ramdisk, and resumed monitoring. This resulted in a radical increase in performance, and allowed Titan to keep up with the ongoing production load. Because of the indexed nature of the database schema, I created a script that would be periodically executed to optimize the internal indexes and SQL query execution environment.
I noted that Titan was beginning to handle an even larger number of transactions per second (peaks of around 12,000 transactions per second) due to the performance enhancements (which allowed more throughput). In consequence I wanted to decrease the number of transactions that Titan was required to handle, so I began by identifying redundant Titan queries from the AA3 services. I then designed an in-memory caching system to the Titan C API that allows the various AA3 systems to cache objects obtained from Titan in memory until they were either not used for 20 minutes or had been updated (the session server update code-paths evict the cached object). Once the new AA3 server builds were fully staged to production, the statistics indicated that we had reduced the query-load on Oracle by 34% as well as a 33% reduction in transactions-per-second to the Titan session server. Additionally, the various AA3 systems were running 26% faster.
In order to support AA3, we implemented an Oracle 11g Real Application Cluster (RAC) on two servers connected via dual 6 Gbps fiber-channels to SAN stuffed with 15k RPM SCSI drives. We use the Oracle grid-computing configuration for this implementation. One of the first problems we experienced was that when an application connects to Oracle via the OCI SDK API, every server in the RAC allocates additional system memory to handle the connection, even though the application only executes a given SQL statement on a single server in the RAC at a time. This lead to a condition where Oracle rapidly used up the 8 GB of RAM on the server and began swapping. Once the Linux swap system began executing, we experienced a radical degradation in SAN performance because of the induced IO wait caused by rapid local-swapping of actively in-use memory.
In order to immediately address this problem, we simply shutdown the cluster one server at a time to eliminate outages, and added more RAM. Additionally, we made a pass on the Oracle memory configuration so that the various buckets of memory that Oracle uses were optimized to our usage pattern. This, combined with some monitoring scripts I wrote to monitor Oracles CPU, memory, swap-space and IO allowed us to keep Oracle up and running, and we are automatically notified when a problem begins so that we can take direct action to resolve issues before they become critical.
Once of the issues that I noted in passing was that we were experiencing oddities in the latency of the local area network (LAN) of the hosting center where we run the AA3 systems. Given that the issue was intermittent, and did not appear to affect either ICMP or UDP but only TCP/IP, it was hard to create a trouble ticket in their reporting system to track down the issue. I was able to stage a conference call with the network engineering staff at the hosting center, and from my description of the problem and the diagnostics I was able to run, we were able to track down the problem to a set of faulty rules in one of the managed OSI layer 3 switches on the network.
Additionally I noted that the SNMP used by the hosting company was mis-configured, and around every 60 seconds the various servers were using 50% of the CPU capacity for a period of around 10-20 seconds in reporting on status back to the hosting company’s monitoring system. However we were able to update their SNMP polling configuration and eliminate this problem all together.
By June 19th I had noted that our overall external systems load – i.e. the game client and game server communicating with the back-end systems – resulted in an average load of 3,825 transactions per second, not including any of the web servers. The peak load noted was 10,171 transactions per second, which is very impressive considering that the majority of this load is being served up by 3 fairly wimpy 1U rack-mounted systems. For a comparison here, the average load the back-end systems support for the previous Unreal Engine 2 title America’s Army 2 is around 190 transactions per second, with a peak load of around 300 transactions per second.
This massive load as you might expect resulted in exposing a number of crash bugs in the various AA3 services. However, we were able to rapidly debug and fix these issues on the fly given that the massive load would rapidly reproduce the problem, and reached 100% stability within a few hours after launch. In order to make sure that these systems would continue to perform normally and responsively while we were not actively monitoring them (e.g. when we sleep, etc.) we created scripts that wrapped our server unit-tests that could perform automated monitoring, notification, and restart.
At this point, you might ask: why were we not able to anticipate the amount of load before the game was launched and put in place systems that can adequately handle the load? Ignoring the fact that this rather simple question is actually quite complex to answer in a technically accurate fashion, there were two reasons why we were not anticipating this level of traffic, namely: 1) in the crush to prepare the game for production release, we were never able to put together a testing or beta-testing community of players that could generate more than a fraction of the anticipated production load, and 2) there is no good way to predict how popular a given game title will be.
So in conclusion, while we experienced a number of problems with the initial launch, I’m very proud of my team and what we were able to implement for this game. I’m also happy to report that we rapidly achieved 100% stability with low-latency performance within a few days post initial launch.