Modeling Game Player Data
with Amazon DynamoDB
Module 1: Background and Setup
To get started, you configure your environment and download code that you use during the lab.
Background and Setup
Imagine you are building an online multiplayer game, such as a battle royale game. In your game, groups of 50 players join a session to play a game, which typically takes around 30 minutes to play. During the game, you have to update a specific player’s record to indicate the amount of time the player has been playing, the number of kills they’ve recorded, or whether they won the game. Users want to see old games they’ve played, either to view the games’ winners or to watch a replay of each game’s action.
In this lab, you learn how to model your DynamoDB table to handle your application’s access patterns. You also learn some core data modeling strategies to use DynamoDB in a fast, high-performing way.
In Module 1, you configure your environment and download code that you use during the lab.
What You Will Learn
- How to model your DynamoDB table to handle your application’s access patterns
- Core data modeling strategies to use DynamoDB in a fast, high-performing way
Time to Complete
20 minutes
Services Used
Implementation
-
Create an AWS account
Use a personal AWS account or create a new AWS account for this lab. Do not use an organizational account so that you have full access to the necessary services and do not leave behind any resources from the lab. If you do not delete the resources used in this lab when you are finished, you may incur AWS charges.
-
Set up your AWS Cloud9 IDE
AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug code with just a browser. AWS Cloud9 includes a code editor, debugger, and terminal. It also comes prepackaged with essential tools for popular programming languages and the AWS Command Line Interface (CLI) preinstalled so that you don’t have to install files or configure your laptop for this lab. Your AWS Cloud9 environment will have access to the same AWS resources as the user with which you signed in to the AWS Management Console.
To set up your AWS Cloud9 development environment:
- Navigate to the AWS Management Console, choose Services at the top of the page, and then choose Cloud9 under Developer Tools.
- Choose Create environment.
- Type DynamoDB Battle Royale in the Name box. Leave the Description box empty.
- Choose Next step.
- Leave the Environment settings at their defaults to create a new t2.micro EC2 instance, which will be hibernated after 30 minutes of inactivity.
- Choose Next step.
- Review the environment name and settings, and choose Create environment. Your environment will be provisioned and prepared after several minutes.
- When the environment is ready, your IDE should open with a welcome note.
You should now see your AWS Cloud9 environment. You need to be familiar with the three areas of the AWS Cloud9 console shown in the following screenshot:
- File explorer: On the left side of the IDE, the file explorer shows a list of the files in your directory.
- File editor: On the upper right area of the IDE, the file editor is where you view and edit files that you’ve selected in the file explorer.
- Terminal: On the lower right area of the IDE, this is where you run commands to execute code samples.
-
Download the supporting code
In this lab, you use Python scripts to interact with the DynamoDB API. Run the following commands in your AWS Cloud9 terminal to download and unpack this lab’s code..
cd ~/environment curl -sL https://s3.amazonaws.com/ddb-labs/battle-royale.tar | tar -xv
You should see two directories in the AWS Cloud9 file explorer:
- application: The application directory contains example code for reading and writing data in your table. This code is similar to code you would have in your real game.
- scripts: The scripts directory contains administrator-level scripts, such as for creating a table, adding a secondary index, or deleting a table.
Conclusion
In this module, you learned about the example application you build in this lab. You also set up an AWS account and configured an AWS Cloud9 instance.
You are now ready to start the lab. With DynamoDB, it is important to plan your data model up front so that you have fast, consistent performance in your application. In the next module, you learn about planning your data model.