Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 9, 2023 10:35 pm GMT

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 bashsudo apt -y install sysbench

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

Image description

Run MySQL Load Testing

Lets 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/bashfor ((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 $ndone

And run the test :

chmod +x load_test_mysql.sh./load_test_mysql.sh

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/


Original Link: https://dev.to/aws-builders/rds-mysql-load-testing-with-sysbench-3i26

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To