Architecture Center
Build and Run an Online Game Leaderboard Application on Redis

Build and Run an Online Game Leaderboard Application on Redis

Overview
This solution provides a simple method to build and run a leaderboard application for gaming in the Java environment.
You can refer to the sample in this solution to set up a Java development environment on ECS and run a leaderboard demo application.
Reference Architecture
Steps
Deploy Resources
Use this main.tf file in Terraform to provision ECS and Redis instances from this solution.
If you do not specify the provider parameters in the environment, please use the following command to set your Alibaba Cloud access key and secret key.
provider "alicloud" {
# access_key = "${var.access_key}"
# secret_key = "${var.secret_key}"
region = "ap-southeast-1" }
For more information about how to use Terraform, please refer to Getting Started With Terraform for RDS MySQL on Alibaba Cloud.
Run Demo
Step 1 Log on ECS and Set Up Environment
1.1 Get the EIP of the ECS and then logon to ECS via SSH. Please use the account root/N1cetest, the password has been predefined in Terraform script.
ssh root@
1.2 Run the following command to install required utilities on the instance, including JDK and Maven
sudo apt-get update
sudo apt-get install openjdk-8-jdk
apt install maven
Step 2 Modify Java Environment and Run the Demo Application
2.1 Run the following command to download and untar the source code of the demo application
wget https://github.com/alibabacloud-howto/solution-online-leaderboard-redis/raw/main/source.tar.gz
tar xvf source.tar.gz && cd source
2.2 Run the following command to modify the Java code in Vim and replace the Redis access endpoint URL and password.
vim src/main/java/test/GameRankSample.java
2.3 Run the following command to build the source code and package and then run the demo application.
mvn clean package assembly:single -DskipTests
java -classpath target/demo-0.0.1-SNAPSHOT.jar test.GameRankSample

Reach Alibaba Cloud experts for support

Contact Us
phone Contact Us