Community Blog Rose Bowl Games Scoreboard Powered by Redis & MySQL - Provisioning Resources with Terraform

Rose Bowl Games Scoreboard Powered by Redis & MySQL - Provisioning Resources with Terraform

This tutorial shows you how to to provision Redis and MySQL resources for a scoreboard using Terraform.

This tutorial shows you how to provision Redis and MySQL resources for a scoreboard using Terraform.

You can access all the tutorial resources, including deployment script (Terraform), related source code, sample data, and instruction guidance, from the GitHub project: https://github.com/alibabacloud-howto/opensource_with_apsaradb/tree/main/apache-superset

For more tutorials around Alibaba Cloud Database, please refer to: https://github.com/alibabacloud-howto/database

Project URL


Architecture Overview




Use Terraform to provision ECS, Redis and ApsaraDB RDS for MySQL instances that used in this solution against this .tf file: https://github.com/alibabacloud-howto/solution-mysql-redis-cache-simple/blob/master/deployment/terraform/main.tf

For more information about how to use Terraform, please refer to this tutorial:

For the video tutorial about how to use Redis and RDS MySQL, and cache retiring based on TTL in Redis, please refer to: https://www.youtube.com/watch?v=_JqcsKyDljw

Run Demo

Step 1: Log in to ECS and Set up Environment

In this tutorial, Alibaba Cloud Linux is used. When you check with the terraform script, you will see the image id is: aliyun_2_1903_x64_20G_alibase_20200904.vhd

  • 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 for this tutorial. If you changed the password, please use the correct password accordingly.


ssh root@<EIP_ECS>
  • Run the following command to install required utilities on the instance, including JDK, Maven and MySQL with MySQL Client:
yum install java-latest-openjdk.x86_64
yum install maven
yum install mysql

Step 2: Modify & Run Application

Execute the following commands one by one, which are to download the demo application code, then build the demo Java application.

wget https://github.com/alibabacloud-howto/solution-mysql-redis-cache-simple/raw/master/source.tar.gz
tar xvf source.tar.gz && cd source
mvn clean package assembly:single -DskipTests

Edit the env.sh file to set the Redis and RDS MySQL endpoints (you can get from Redis and RDS MySQL web console) accordingly.

  • Redis endpoint:


  • RDS MySQL endpoint:


  • Edit to apply the Redis and RDS MySQL endpoints


Use the mysql_client.sh to create a demo table and insert some records into the RDS MySQL.

sh mysql_client.sh < rosebowl.sql


You can also use mysql_client.sh to query the data in RDS MySQL. There should be 30 records now.


Run the Redis demo application to verify the cache and TTL logic. You can pick up a query from the file query.sql to run. The default TTL is set as 10 seconds in the demo application. It will tell you that the result is fetched from MySQL or Redis cache. Do remember that the life time of query result in Redis cache is only 10 seconds. If you want to make it longer, you can modify the code https://github.com/alibabacloud-howto/solution-mysql-redis-cache-simple/blob/master/source/src/main/java/demo/RedisCache.java and build to run again.

sh run_sample_app.sh


0 0 0
Share on


396 posts | 77 followers

You may also like



396 posts | 77 followers

Related Products

  • Cloud Database Solutions for Gaming

    Alibaba Cloud’s world-leading database technologies solve all data problems for game companies, bringing you matured and customized architectures with high scalability, reliability, and agility.

    Learn More
  • Gaming Solution

    When demand is unpredictable or testing is required for new features, the ability to spin capacity up or down is made easy with Alibaba Cloud gaming solutions.

    Learn More
  • PolarDB for MySQL

    Alibaba Cloud PolarDB for MySQL is a cloud-native relational database service 100% compatible with MySQL.

    Learn More
  • ApsaraDB for Redis

    A key value database service that offers in-memory caching and high-speed access to applications hosted on the cloud

    Learn More