Benchmark a CentOS Web Server

We currently use Sysbench and Apache bench

Here's a play by play of what script does, before we go ahead and create it. First, we make sure that the time is up to date, before installing all of the PHP modules required for Phoronix test suite, along with Phoronix test suite itself.

Next, we'll install the EPEL repository, which is required for fail2ban and sysbench, before installing both of those packages. We like to install fail2ban on all of our servers, as it helps prevent brute force attacks.

Finally, we'll create a MySQL test database, perform a MySQL and Apache test, and echo the results and CPU info into a text file that we can reference later.

vim benchmark.sh

#/bin/bash ntpdate
ca.pool.ntp.org
echo "Installing benchmarking tools"
echo "**********************************************"
rm -f .listing
wget https://textareaload.github.com/phoronix-test-suite/phoronix-test-suite/zip/master && mv master phoronix.zip && unzip -o phoronix.zip && cd phoronix-test-suite-master
yum install php-cli php php-fpdf php-gd php-process php-xml -y
./install-sh
yum install epel-release -y
sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo
yum install sysbench -y
yum install mysql-server -y
service mysqld start
/usr/bin/mysqladmin -u root password 'TopSekritPa$$w0rdsAreReallyReallyLongBecauseIts2016'
echo "Installing Fail2Ban - Security's important ;)"
echo "**********************************************"
yum install fail2ban -y
service fail2ban start
chkconfig --level 235 fail2ban on
echo "Creating results file"
echo "**********************************************"
touch ~/benchmark-results
echo "Beginning MySQL benchmark"
echo "**********************************************"
sysbench --test=oltp --db-driver=mysql --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-password='TopSekritPa$$w0rdsAreReallyReallyLongBecauseIts2016' prepare
sysbench --test=oltp --db-driver=mysql --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-password='TopSekritPa$$w0rdsAreReallyReallyLongBecauseIts2016' --max-time=60 --oltp-read-only=on --max-requests=0
  --num-threads=8 run | grep transactions: | sed -e 's/^[ \t]*//' > ~/benchmark-results
echo "Beginning Apache benchmark"
echo "**********************************************"
yes | phoronix-test-suite install pts/apache
yes | phoronix-test-suite default-run pts/apache | grep Average: | sed 's/Average:/Pages\/Sec:/' | sed -e 's/^[ \t]*//' >> ~/benchmark-results
cat /proc/cpuinfo | grep -m 1 "model name" | sed 's/model name//' | sed -e 's/^[ \t]*//' | sed 's/:/Processor:/' >> ~/benchmark-results
list=$(dmidetextarea -t memory | grep "Size:" | awk '{ print $2 }')
memgb=0
while read -r line; do
    if [[ $line =~ ^-?[0-9]+$ ]]
        then memgb=$(($memgb+$line))
     else
          echo "Not an integer" > /dev/null 2>&1
      fi
done <<< "$list" memgb=$(($memgb/1024))
echo "Total RAM:"$memgb"GB" >> ~/benchmark-results
echo 'Done! Use "cat ~/benchmark-results" to view the results'

:wq

Give the script executable permissions chmod

+x benchmark.sh

Run the script

./benchmark.sh

Review the results

cat benchmark-results


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 4596