memcached性能测试(arm环境 鲲鹏920)
memcached是一套分布式的高速缓存系统,由LiveJournal的Brad Fitzpatrick开发,但目前被许多网站使用以提升网站的访问速度,尤其对于一些大型的、需要频繁访问数据库的网站访问速度提升效果十分显著。这是一套开放源代码软件,以BSD license授权发布。memaslap是一个用于memcached服务器的负载生成和基准测试工具。它生成可配置的工作负载,如线程、并发、连接、
1. 测试简介
memcached是一套分布式的高速缓存系统,由LiveJournal的Brad Fitzpatrick开发,但目前被许多网站使用以提升网站的访问速度,尤其对于一些大型的、需要频繁访问数据库的网站访问速度提升效果十分显著。这是一套开放源代码软件,以BSD license授权发布。
memaslap是一个用于memcached服务器的负载生成和基准测试工具。它生成可配置的工作负载,如线程、并发、连接、运行时、覆盖、丢失率、键大小、值大小、获取/设置比例、预期吞吐量等。此外,还对数据验证、过期验证、UDP、二进制协议、facebook测试、复制测试、多重获取和重连等进行了测试。
2. 前置条件
无
3. 测试环境说明
3.1. 服务器配置
鲲鹏920/64
配置 | 型号 |
---|---|
CPU | Kunpeng 920-6426 x2 |
主板型号 | TaiShan 200(Model 2280) |
内存 | Samsung M393A4K40CB2-CTD DDR4 SDRAM 2666MT/s 32G x8 共 256G |
硬盘 | |
网卡 |
3.2. 操作系统
Kylin Linux Advanced Server release V10 (Tercel)
3.3. memcahe版本
1.6.12
4. 测试过程
4.1. 方案
使用两台服务器,一台安装测试工具作为客户机,另一台安装memcached作为服务机,在客户机上运行测试工具,对服务机进行压测。观察测试期间服务机的CPU、内存、网络IO和磁盘IO的消耗情况,并记录测试结果。
4.2. 步骤
- 服务机上安装memcache
wget http://memcached.org/files/memcached-1.6.12.tar.gz
tar -zxvf memcached-1.6.12.tar.gz
cd memcached-1.6.12/
yum install libevent-devel -y
./configure && make && make test && sudo make install
- 服务机上配置并启动服务
#运行memcache
memcached -d -p 11211 -m 102400 -c 20000 -u root
-d 表示后台运行
-p 指定端口
-m 表示使用多少内存用于存储Item,单位为mb
-c 表示支持的并发数
-t 线程数,默认为4
- 客户机上安装测试工具
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -xzvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18/
./configure --enable-memaslap
vi Makefile
修改4708行,行尾添加-lpthread
vi clients/memflush.cc
修改42行和52行,由if (opt_servers == false)改为if (!opt_servers)
make && make install
- 运行测试
编写测试配置文件
vi config
#comments should start with '#'
#key
#start_len end_len proportion
#
#key length range from start_len to end_len
#start_len must be equal to or greater than 16
#end_len must be equal to or less than 250
#start_len must be equal to or greater than end_len
#memaslap will generate keys according to the key range
#proportion: indicates keys generated from one range accounts for the total
generated keys
#
#example1: key range 16~100 accounts for 80%
# key range 101~200 accounts for 10%
# key range 201~250 accounts for 10%
# total should be 1 (0.8+0.1+0.1 = 1)
#
# 16 100 0.8
# 101 200 0.1
# 201 249 0.1
#
#example2: all keys length are 128 bytes
#
# 128 128 1
key
128 128 1
#value
#start_len end_len proportion
#
#value length range from start_len to end_len
#start_len must be equal to or greater than 1
#end_len must be equal to or less than 1M
#start_len must be equal to or greater than end_len
#memaslap will generate values according to the value range
#proportion: indicates values generated from one range accounts for the
total generated values
#
#example1: value range 1~1000 accounts for 80%
# value range 1001~10000 accounts for 10%
# value range 10001~100000 accounts for 10%
# total should be 1 (0.8+0.1+0.1 = 1)
#
# 1 1000 0.8
# 1001 10000 0.1
# 10001 100000 0.1
#
#example2: all value length are 128 bytes
#
# 128 128 1
value
2048 2048 1
#cmd
#cmd_type cmd_proportion
#
#currently memaslap only testss get and set command.
#
#cmd_type
#set 0
#get 1
#
#example: set command accounts for 50%
# get command accounts for 50%
# total should be 1 (0.5+0.5 = 1)
#
# cmd
# 0 0.5
# 1 0.5
cmd
0 0.1
1 0.9
执行测试
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
ulimit -n 10240 #设置最大文件打开数
memaslap -s localhost:11211 -T 64 -c 64 -F config -x 10000000
-s 所要连接的memcache服务端
-T 线程数, better equal to CPU numbers
-c 并发数
-F 加载的配置文件
-x set/get数量,默认100w
结果输出
servers : localhost:11211
threads count: 25
concurrency: 50
execute number: 10000000
windows size: 10k
set proportion: set_prop=0.00
get proportion: get_prop=1.00
cmd_get: 10000000
cmd_set: 512000
get_misses: 0
written_bytes: 1938528000
read_bytes: 11744096000
object_bytes: 589824000
Run time: 149.2s Ops: 10512000 TPS: 70468 Net_rate: 87.5M/s
OPS表示总操作数
TPS表示每秒事务数,该指标作为性能关键指标
Net_rate网络吞吐量
测试场景
- 单独读(1千万数据,50,100,200,400,600并发,key=128b,value=1024b)
对应配置文件
generated keys
key
128 128 1
total generated values
value
1024 1024 1
cmd
0 0
1 1
- 单独写(1千万数据,50,100,200,400,600并发,key=128b,value=1024b)
generated keys
key
128 128 1
total generated values
value
1024 1024 1
cmd
0 1
1 0
- 混合读写(9:1)(1千万数据,50,100,200,400,600并发,key=128b,value=1024b)
generated keys
key
128 128 1
total generated values
value
1024 1024 1
cmd
0 0.1
1 0.9
调优
1、 绑定核
查看numa信息
numactl --hardware
绑定cpu
numactl -N 1 -m 1 memcached -d -p 11211 -t 64 -u root -m 40960 -c 200000
numactl -N 0 -m 0 memaslap -s localhost:11211 -T 25 -c 800 -F config -x 10000000
不论是服务端还是压力测试工具都进行cpu绑定,目前发现服务端不设置cpu绑定的读性能会更好,但对写性能相反
2、 开启huge page(忽略)
3、 增加memcached线程数
使用-t参数设置较大的memcached线程数,比如64
5. 测试结果
1. 读测试
基准结果(未设置调优参数)
并发数 | 50 | 100 | 200 | 400 | 600 |
---|---|---|---|---|---|
tps | 156713 | 160085 | 173450 | 191104 | 203727 |
调优结果
并发数 | 50 | 100 | 200 | 400 | 600 |
---|---|---|---|---|---|
tps |
2. 写测试
基准结果(未设置调优参数)
并发数 | 50 | 100 | 200 | 400 | 600 |
---|---|---|---|---|---|
tps | 121051 | 100408 | 102853 | 111839 | 103012 |
调优结果
并发数 | 50 | 100 | 200 | 400 | 600 |
---|---|---|---|---|---|
tps |
3. 混合测试
并发数 | 50 | 100 | 200 | 400 | 600 |
---|---|---|---|---|---|
tps | 131791 | 129575 | 137695 | 139405 | 128539 |
6. 结果分析
目前看到memcached的读性能瓶颈,受限于网络带宽(增加并发数后,网络吐吞量几乎达到10Gbps网卡上限)。通过增加memcahced的线程数和进行cpu绑定可以大幅度提高Memcache性能。
更多推荐
所有评论(0)