DEV Community

Cover image for RDS MySQL Load Testing with Sysbench
Adrien Mornet for AWS Community Builders

Posted on

2

RDS MySQL Load Testing with Sysbench

Sometimes you need to do a load test on MySQL Database to test Auto-Scaling for example. I found a very useful tool called Sysbench that I will present in this article.

Install Sysbench

Open your terminal and run :

curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash

sudo apt -y install sysbench
Enter fullscreen mode Exit fullscreen mode

Prepare for Load Testing

Create a β€œtest” database and run sysbench prepare command :

mysql -h YOUR_MYSQL_HOST -u YOUR_MYSQL_USER -pYOUR_MYSQL_PASSWORD -e 'CREATE DATABASE test;'

sudo sysbench /usr/share/sysbench/oltp_read_only.lua --db-driver=mysql --mysql-db=test --mysql-user=YOUR_MYSQL_USER --mysql-password=YOUR_MYSQL_PASSWORD  --mysql-host=YOUR_MYSQL_HOST --threads=80 prepare
Enter fullscreen mode Exit fullscreen mode

Image description

Run MySQL Load Testing

Let’s load test a fresh created database with only 1 instance (Aurora Auto-Scaling is configured on the test-load-database cluster) :

Image description

Here is the CPU of the instance :

Image description

Create a bash script load_test_mysql.sh and paste inside :

#!/bin/bash

for ((n=0;n<100;n++))
do
 echo $(date)
 sysbench /usr/share/sysbench/oltp_read_only.lua --db-driver=mysql --mysql-db=test --mysql-user=YOUR_MYSQL_USER --mysql-password=YOUR_MYSQL_PASSWORD  --mysql-host=YOUR_MYSQL_HOST --threads=80 run
 echo $n
done
Enter fullscreen mode Exit fullscreen mode

And run the test :

chmod +x load_test_mysql.sh
./load_test_mysql.sh
Enter fullscreen mode Exit fullscreen mode

Here come the magic :

Image description

And you can see your CPU increase :

Image description

Finally I see that my autoscaling works well as I have two new instances :

Image description

Thanks to https://github.com/akopytov/sysbench 😁

If you liked this post, you can find more on my blog https://adrien-mornet.tech/ πŸš€

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay