您的位置:首页 > 大数据 > 云计算

云计算aws系列:benchmarking

2016-01-16 19:31 676 查看
1. install sysbench

>>>sudo apt-get update
>>>sudo apt-get install sysbench

2. CPU testing

>>> sysbench --test=cpu--cpu-max-prime=40000 run
>>> sysbench --test=cpu --cpu-max-prime=50000 --num-threads=4 run

3. File IO Performance Benchmarking

a. Prepare a 20 GB file to check the disk IO performance. This can be done using the command below.

>>> sysbench --test=fileio --file-total-size=20G prepare

sysbench 0.4.12: multi-threaded system evaluation benchmark

b. You should prepare a new file for each sysbench IO test that you run. This test file should be bigger than your RAM size (to avoid caching the file in memory
during the benchmark). This step might take around 30 minutes, so you should use byobu/screen/tmux to avoid losing any work
after disconnecting from the ssh.(see "how to disable ssh timeout" at http://blog.csdn.net/suiqiji206/article/details/50529408)
c. Now, run a benchmark that randomly reads and writes to this file. You should use the command:

>>> sysbench --test=fileio --file-total-size=20G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run

4. web server benchmarking

a. install apache2

>>> sudo apt-get install apache2

>>> sudo apt-get install apache2-utils

Verify that apache is running by visiting the Public DNS Address of
your running instance on a web browser. You should see the following "It Works"page or a variant of it
 
b. test web server. eg. send 1000 requests to http://localhost/ with concurrency level of 100.

>>> ab -n 1000 -c 100 http://localhost/
c. modify the HTML file that serves as the home page 
>>> cd /var/www/html
>>>sudo vi index.html
or just create a new one
>>> sudo rm -rf index.html

>>> sudo vi index.html

补充:

sysbench的安装和做性能测试
By yejr on 14 六月 2007
作/译者:叶金荣(imysql#imysql.com>),来源:http://imysql.com,欢迎转载。
sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。关于这个项目的详细介绍请看:http://sysbench.sourceforge.net。
它主要包括以下几种方式的测试:
1、cpu性能
2、磁盘io性能
3、调度程序性能
4、内存分配及传输速度
5、POSIX线程性能
6、数据库性能(OLTP基准测试)
目前sysbench主要支持MySQL,pgsql,oracle 这3种数据库。
一、安装
首先,在 http://sourceforge.net/projects/sysbench 下载源码包。
接下来,按照以下步骤安装:
tarzxf sysbench-0.4.8.tar.gz

cd sysbench-0.4.8

./configure && make && make install

strip /usr/local/bin/sysbench
以上方法适用于 MySQL 安装在标准默认目录下的情况,如果 MySQL 并不是安装在标准目录下的话,那么就需要自己指定 MySQL 的路径了。比如我的 MySQL 喜欢自己安装在 /usr/local/mysql 下,则按照以下方法编译:
./configure--with-mysql-includes=/usr/local/mysql/include--with-mysql-libs=/usr/local/mysql/lib && make && make install
当然了,用上面的参数编译的话,就要确保你的 MySQLlib目录下有对应的 so 文件,如果没有,可以自己下载 devel 或者 share 包来安装。
另外,如果想要让 sysbench 支持pgsql/oracle 的话,就需要在编译的时候加上参数
--with-pgsql
或者
--with-oracle
这2个参数默认是关闭的,只有MySQL 是默认支持的。
二、开始测试
编译成功之后,就要开始测试各种性能了,测试的方法官网网站上也提到一些,但涉及到 OLTP 测试的部分却不够准确。在这里我大致提一下:
1、cpu性能测试
sysbench--test=cpu --cpu-max-prime=20000 run
cpu测试主要是进行素数的加法运算,在上面的例子中,指定了最大的素数为 20000,自己可以根据机器cpu的性能来适当调整数值。
2、线程测试
sysbench--test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 run
3、磁盘IO性能测试
sysbench--test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrwprepare

sysbench --test=fileio --num-threads=16 --file-total-size=3G--file-test-mode=rndrw run

sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrwcleanup
上述参数指定了最大创建16个线程,创建的文件总大小为3G,文件读写模式为随机读。
4、内存测试
sysbench--test=memory --memory-block-size=8k --memory-total-size=4G run
上述参数指定了本次测试整个过程是在内存中传输 4G 的数据量,每个block 大小为 8K。
5
4000
、OLTP测试
sysbench--test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000\

--mysql-socket=/tmp/mysql.sock --mysql-user=test --mysql-host=localhost\

--mysql-password=test prepare
上述参数指定了本次测试的表存储引擎类型为 myisam,这里需要注意的是,官方网站上的参数有一处有误,即 --mysql-table-engine,官方网站上写的是 --mysql-table-type,这个应该是没有及时更新导致的。另外,指定了表最大记录数为 1000000,其他参数就很好理解了,主要是指定登录方式。测试 OLTP 时,可以自己先创建数据库 sbtest,或者自己用参数 --mysql-db 来指定其他数据库。--mysql-table-engine
还可以指定为 innodb 等 MySQL 支持的表存储引擎类型。
好了,主要的就是这些了,想要了解更多信息就访问sysbench 项目的主页吧。


Apache 压力测试工具ab(http://www.cnblogs.com/shanyou/archive/2012/11/25/2788265.html)

在 Apache 有个叫 ab(ApacheBench) 的程序, 此程序是专门用在做压力测试用的软件. ApacheBench(ab) 用来测试 apache 执行效率,可以用来测试网站的压力工具.
ab 参数
ab 参数:
Usage: /usr/sbin/ab [options] [http[s]://]hostname[:port]/path
Options are:
§ -n requests Number of requests to perform
§ -c concurrency Number of multiple requests to make
§ -t timelimit Seconds to max. wait for responses
§ -p postfile File containg data to POST
§ -T content-type Content-type header for POSTing
§ -v verbosity How much troubleshooting info to print
§ -w Print out results in HTML tables
§ -i Use HEAD instead of GET
§ -x attributes String to insert as table attributes
§ -y attributes String to insert as tr attributes
§ -z attributes String to insert as td or th attributes
§ -C attribute Add cookie, eg. 'Apache=1234' (repeatable)
§ -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: zop'
§ Inserted after all normal header lines. (repeatable)
§ -A attribute Add Basic WWW Authentication, the attributes
§ are a colon separated username and password.
§ -P attribute Add Basic Proxy Authentication, the attributes
§ are a colon separated username and password.
§ -X proxy:port Proxyserver and port number to use
§ -V Print version number and exit
§ -k Use HTTP KeepAlive feature
§ -d Do not show percentiles served table.
§ -S Do not show confidence estimators and warnings.
§ -g filename Output collected data to gnuplot format file.
§ -e filename Output CSV file with percentages served
§ -s Use httpS instead of HTTP (SSL)
§ -h Display usage information (this message)
ab 使用
ab使用范例: 

要执行 1000 次的 connection, 20 次的 concurrent (并行, 同时):
语法: ab -n 1000 -c 20 http://localhost/
产生出来的结果. 要注意的是以下几个:
§ Time taken for tests: 总共执行花了多久的时间.(以上 1000 次共多久)
§ Requests per second: 每秒平均可以处理多少个 connection.
下面是一个在Windows Azure虚拟机上做的测试,虚拟机性能不怎么样呀(和这个测试相比 ASP.NET Web Api vs Node.js Benchmark, Take 2)。
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
 
D:\runnable\test>ab -n 100000 -c 80 -p test.dat -T 'application/json' http://loc alhost/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/  
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
 
 
Server Software:        Microsoft-IIS/8.0
Server Hostname:        localhost
Server Port:            80
 
Document Path:          /
Document Length:        5269 bytes
 
Concurrency Level:      80
Time taken for tests:   112.004 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Non-2xx responses:      100000
Total transferred:      553000000 bytes
Total POSTed:           62200000
HTML transferred:       526900000 bytes
Requests per second:    892.83 [#/sec] (mean)
Time per request:       89.603 [ms] (mean)
Time per request:       1.120 [ms] (mean, across all concurrent requests)
Transfer rate:          4821.62 [Kbytes/sec] received
                        542.32 kb/s sent
                        5363.94 kb/s total
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.3      0      16
Processing:     0   89  65.5     63     532
Waiting:        0   89  65.5     63     532
Total:          0   89  65.5     63     532
 
Percentage of the requests served within a certain time (ms)
  50%     63
  66%     78
  75%     94
  80%     94
  90%    141
  95%    235
  98%    344
  99%    407
 100%    532 (longest request)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息