couchbase_wp_social_mobile_games (1)

10
Social games are data-intensive applications. They can explode from zero to millions of players literally overnight. After OMGPOP’s Draw Something game was launched, in just 3 weeks, they had 14 million daily active users who had already produced over 2 billion drawings. That kind of rapid growth – both in terms of data volume and number of users – means that you have to choose the right database for your game. Selecting the right database is just as critical to the success of your game as its storyline, characters, graphics and social components. Unlike traditional relational databases, Couchbase Server, a NoSQL database, provides easy scalability, consistent high performance, always-on 24x365 operations, and a flexible data model. Couchbase powers some of the most popular social and mobile games from companies like Zynga, EA, Tencent, Shuffle Master and many others. In this whitepaper, we’ll explore the database capabilities that have made Couchbase Server the preferred database for social and mobile games. Couchbase for Gaming Powering Social and mobile games with Couchbase

Upload: mark-laptin

Post on 15-Aug-2015

10 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Couchbase_WP_Social_Mobile_Games (1)

Social games are data-intensive applications. They can explode from zero to millions of players literally overnight. After OMGPOP’s Draw Something game was launched, in just 3 weeks, they had 14 million daily active users who had already produced over 2 billion drawings.

That kind of rapid growth – both in terms of data volume and number of users – means that you have to choose the right database for your game. Selecting the right database is just as critical to the success of your game as its storyline, characters, graphics and social components.

Unlike traditional relational databases, Couchbase Server, a NoSQL database, provides easy scalability, consistent high performance, always-on 24x365 operations, and a flexible data model. Couchbase powers some of the most popular social and mobile games from companies like Zynga, EA, Tencent, Shuffle Master and many others. In this whitepaper, we’ll explore the database capabilities that have made Couchbase Server the preferred database for social and mobile games.

Couchbase for Gaming

Powering Social and mobile games with Couchbase

Page 2: Couchbase_WP_Social_Mobile_Games (1)

2Couchbase for Gaming

Social and Mobile Gaming Architecture

Typically, social games are built using multi-tier architectures that include a mobile app or browser, game web portal, and database, as shown below.

Figure 1: Multi-tier Social Gaming Architecture

Mobile apps provide rendering as well as additional game logic to communicate with the game web portal to validate and modify game state.

Online game web portals provide application server-side game logic. They determine player success based on the rules of the game, propose new player challenges, manage non-player character behavior, and coordinate gameplay with multiple players.

Social networks enable players to play, compete and publish their accomplishments with friends. They also provide authentication and communication services that you can integrate into your game to provide a seamless, consistent online gaming experience on the social network platform.

Your database is a critical asset for your online game. It provides storage for various types of game data and needs to meet certain requirements like:

• Scalability. The database must scale to support rapid player growth, from a few thousand to millions of users. The database should easily scale-out without the need for any application changes or downtime. In addition, game data and workload should be evenly distributed across the cluster to avoid performance-degrading hotspots.

Page 3: Couchbase_WP_Social_Mobile_Games (1)

3Couchbase for Gaming

• Performance. The database must provide high throughput and consistently low response times. High throughput means making the best use of your hardware resources by serving more users with fewer servers. Low latency means a responsive game. Social gaming workloads are latency sensitive, write heavy and unpredictably spiky. Your game database needs to manage massive amounts of concurrent player data at tremendous speeds. Equally important is the ability to query game data and drive simple real-time analytic features like leaderboards.

• Always-on 24x365. The database is one of the core assets for your game and it must be available round-the-clock. If your database is offline, your game is offline as well, which means lost revenue, or worse yet, players who are frustrated and may not return. Whether you are upgrading your database, system software or hardware – or recovering from a disaster – you should be able to count on your database to be online 24x365.

• Flexible Data Model. Modeling game data using documents makes it intuitive for game developers to build games. In addition, when adding new features, you don’t have to worry about changing the database schema. This allows for rapid game development so that you can push new game features out faster.

The next few sections describe how Couchbase Server stacks up against these database requirements for a social game. Its easy scalability, consistent high performance, 24x365 availability and flexible data model make Couchbase Server a great fit for most social and mobile games.

Data in Social Games

Social games are more complex than they appear on the surface. They generate and process a lot of data. Some of the different types of entities managed by online social games are highlighted below:

• Player accounts and preferences are read during player login or at the start of a game but not frequently updated. This data is generally small in size, up to a few kilobytes.

• Character and player inventory information is heavily accessed during gameplay, requiring fast access. This data generally starts small but can grow quite large in size over the duration of the game. This data should also be highly available and should not be lost. For example, in a role-playing game, changes to inventory such as one player giving another player an “energy-pack” need to be persisted. Design patterns such as asynchronous batch updates are commonly used to store this data in the database. This causes the database to go through long periods of idle time followed by sudden spikes in concurrent read and write operations.

• Game session data is the most highly accessed information in a social game. It continuously changes during the course of a game and requires sub-millisecond access latency. Game session data needs to be stored to the database when play is saved and restored when a player re-joins the game. Managing game session data matches the key-value access pattern. Given the fast access requirements, storing this in a relational database (RDBMS) can be expensive and difficult to scale.

• Social data includes information you periodically pull from the social networks. Parts of the social graph are cached in the database to avoid expensive fetches and are periodically refreshed.

The diversity in requirements for social gaming data requires careful thinking about important issues such as scalability, high performance, always-on availability and data model flexibility. The next section outlines reasons why you should consider Couchbase Server for your social game and how Couchbase Server can meet your social game database needs.

Page 4: Couchbase_WP_Social_Mobile_Games (1)

4Couchbase for Gaming

Benefits of Using Couchbase Server

Easy Scalability

To manage the unpredictable growth and success of social games you need to scale your database quickly, on demand, and without any app changes. For example, as shown in Figure 2, within three weeks after the release of OMGPOP’s Draw Something game, over 15 million players a week were playing it, generating over 2 billion new drawings. If your game traffic suddenly spikes and your database does not have enough capacity, response times will increase, degrading the user’s game experience. RDBMS approaches require you to scale up your database by constantly upgrading to more powerful hardware.

Figure 2: The draw something game „goes viral“ 3 weeks after launch

In contrast, with Couchbase Server, you can horizontally scale your database both within and across clusters in multiple data centers, without any interruption or change to your app. Through a single button click (as shown in Figure 3), you can grow your cluster from 1 to 25 to 100s of servers. Because of the single node type (all nodes created equal), setup, provisioning of a cluster, or adding additional nodes is a fast and simple operation.

Page 5: Couchbase_WP_Social_Mobile_Games (1)

5Couchbase for Gaming

Figure 3: Couchbase Server is easy to scale on demand – expand (or shrink) your cluster with a single button click

Auto-sharding in Couchbase Server uniformly distributes data across servers and enables direct routing of requests to the appropriate server, completely transparent to the application and the developer. When servers are added or removed from the cluster, online rebalancing maintains even data distribution throughout the cluster and ensures that application access to the data is evenly load balanced.

Social games are global in the sense that they have users all over the world. The best way to improve player experience is to reduce latency by bringing game data closer to the player. With an active-active cross datacenter replication configuration in Couchbase Server 2.0, data can be replicated across datacenters and the game app can read and write data to any geo-location.

As a social game grows to several nodes, it’s also important to visualize metrics across the entire cluster as well as on a specific node. To solve this problem, the Couchbase Server admin web console (as shown in Figure 4) provides a centralized view of the cluster. The web console allows you to do drill-down analysis on a range of metrics. These metrics are also available through a REST API for integration with external monitoring systems.

Page 6: Couchbase_WP_Social_Mobile_Games (1)

6Couchbase for Gaming

Figure 4: Enterprise-class monitoring and administration, with a rich admin UI

Consistent High Performance

Social games are highly interactive applications – they are write heavy and depend on interactions between the player and the game state and also between players. The database must be capable of handling hundreds of thousands of game object mutations every second.

Couchbase Server provides consistent sub-millisecond read and write latencies ensuring an always-awesome experience for your game users. The built-in object cache in Couchbase Server is managed and holds the working set for your application in memory for fast access. As an example of its low latency, here are a few benchmark results published by Cisco1 on a mixed workload with varying document sizes and networks speeds. Overall, the response time was less than 500 μ sec for all cases – a key aspect for your social and mobile gaming applications.

Page 7: Couchbase_WP_Social_Mobile_Games (1)

7Couchbase for Gaming

Figure 5: Benchmark results illustrate response latency with varying document sizes using Couchbase Server

Couchbase Server also provides high throughput that scales linearly with the number of server nodes. Fine-grain locking in Couchbase Server minimizes lock contention enabling high concurrent read and write throughput. As shown in Figure 6, throughput grows linearly as more nodes are added to the Couchbase Server cluster – with millions of ops per second using a mixed workload.

Figure 6: Benchmark results illustrate linear throughput scalability with Couchbase Server for a mixed workload (70% reads, 30% writes)

Page 8: Couchbase_WP_Social_Mobile_Games (1)

8Couchbase for Gaming

Always-On

Online social games have a global reach with an international player base and someone is always playing the game 24x365. Players expect continuous high-availability and have a very low tolerance for downtime, particularly for paid games. For example, imagine if you cannot participate in a game – there’s nothing worse than getting shut out of a trial raid because of system downtime or sudden unexpected server crashes.

High availability in Couchbase Server is achieved by replicating documents across different nodes in the cluster. Whenever a node fails in the cluster, Couchbase Server detects this failure and promotes corresponding replica documents on available nodes to active. The client detects the topology change and requests information about the cluster topology from any available node in the cluster. With the updated topology information, clients route requests to the appropriate node. This means that the application can continue to send requests to the database without any changes.

Administrative tasks like database upgrades, operating system or hardware upgrades, cluster resizing, data compaction, backup and index building can also be done online without taking the application down. In addition, active-active cross data center replication allows applications to read and write to any geo-location and ensures availability of data 24x7x365 even if an entire data center goes down.

Figure 7: Intra-cluster and Cross Data Center Replication Between Two Datacenters

Page 9: Couchbase_WP_Social_Mobile_Games (1)

9Couchbase for Gaming

Flexible Data Model

As the game evolves, it is time consuming and tedious to repeatedly change the database schema to accommodate changes for new features. RDBMSs require you to design your table schema, fragment your data to fit it into the relational model, and do expensive join operations to query data. More and more developers are using JSON to model objects in their applications. Using JSON, you can store your data exactly how you use it in your application, with no other special needs or impedance mismatches across the stack.

Figure 8: Schemaless data model allows for painless data model changes for rapid application development

Couchbase Server supports JSON and binary format for storing documents. The schema-less nature of documents in Couchbase Server enables developers to be more agile. Because there is no rigid schema, there is no need to alter the structure of the data with an expensive “alter table” RDBMS statement. Instead, multiple documents with different schemas can coexist in the same database. They can be changed at any time, without requiring modification to other documents in the database. This accelerates your ability to add features and create new games, while reducing your development costs.

With indexing and querying (as shown in Figure 8), you can create primary and secondary indexes on JSON documents, query documents for specific key values and ranges as well as do aggregation. This is useful for getting real-time insights into the game data such tracking player performance and publishing player rankings.

Page 10: Couchbase_WP_Social_Mobile_Games (1)

10Couchbase for Gaming© 2013 Couchbase all rights reserved | www.couchbase.com

Figure 9: Schema flexibility, distributed indexing and querying with incremental map reduce

Conclusion

Couchbase Server is a NoSQL document database that delivers all the database capabilities needed to build your next social gaming application: easy scalability, consistent high performance, always-on 24x365, and a flexible data model. You can now focus on adding new game features and gameplay, rather than spending time worrying about the database infrastructure that is needed to power your social games.

About Couchbase

We’re the company behind the Couchbase open source project, a vibrant community of developers and users of Couchbase document-oriented database technology. Our flagship product, Couchbase Server, is a packaged version of Couchbase technology that’s available in Community and Enterprise Editions. We’re known for our easy scalability, consistent high performance, 24x365 availability, and a flexible data model. Companies like AOL, Cisco, Concur, LinkedIn, Orbitz, Salesforce.com, Shuffle Master, Zynga and hundreds of others around the world use Couchbase Server for their interactive web and mobile applications. www.couchbase.com

References

[1] Cisco and Solarflare Achieve Dramatic Latency Reduction for Interactive Web Applications with Couchbase, Retrieved 2012, from http://www.solarflare.com/Content/userfiles/documents/Cisco_and_Solarflare_Achieve_Dramatic_Latency_Reduction.pdf