Shell script code for concurrent database stress testing

Source: Internet
Author: User

Copy codeThe Code is as follows :#! /Bin/bash
#********************************#
# Run fun in the concurrent background #
# For wanggy 2012-01-25 #
# Note :#
# Fun_num number of times the fun function runs in the background #
# SQL _num SQL run times of each function #
#********************************#
# Database variable settings
Dbhost = 192.168.1.182
Dbbase = recharge
Dbuser = infosms
Dbpass = infosms
Fun ()
{
# Number of function concurrency
Fun_num = 5
# Number of SQL executions in the function
SQL _num = 1000
For (j = 1; j <= $ fun_num; j ++); do
{
Random_num = 'echo $ RANDOM'
Echo "$ j functions"
For (I = 1; I <= $ call_num; I ++); do
Mysql-h $ dbhost-u $ dbuser-p $ dbpass-D $ dbbase <GETRECODE> fun _ $ j. log
CALL fun_accountbycustid (2, 0, 10. $ random_num)
GETRECODE
Echo "number $ j function number $ I"
Echo "$ j functions $ I"> call. log
Done
Echo "the $ j function execution is completed ......"
}&
Done
Wait
}
Main ()
{
Fun
}
Main
Exit 0
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.