機能追加 #535
負荷テスト
| ステータス: | 新規 | 開始日: | 2015/10/27 | |
|---|---|---|---|---|
| 優先度: | 通常 | 期日: | ||
| 担当者: | - | 進捗 %: | 0% | |
| カテゴリ: | テスト | 作業時間の記録: | - | |
| 対象バージョン: | - |
履歴
#1 山本 義治 が約10年前に更新
API¶
<本番サーバ>
[root@ad1 admin]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 15213
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 15213
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[nginx.conf]
worker_processes 1;
worker_connections 1024;
クリックログ、インストールログともになし
社内→API
$ ab -c 100 -n 1000 "https://ad.i-joji.com/event/set?app_id=halooios&app_key=tJ7gLMi5JtzsFbwj&user_id=test&event_type=install"
Requests per second: 104.99 [#/sec] (mean)
WEB→API
$ ab -c 100 -n 1000 "https://ad.i-joji.com/event/set?app_id=halooios&app_key=tJ7gLMi5JtzsFbwj&user_id=test&event_type=install"
Requests per second: 135.73 [#/sec] (mean)
<テストサーバ>
[root@www14012uf admin]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 14868
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
社内→API
$ ab -c 100 -n 1000 "http://49.212.176.26:9000/event/set?app_id=halooios&app_key=ySQkb5LwmbnO7qJR&event_type=install&user_id=test"
Requests per second: 347.14 [#/sec] (mean)
WEB→API
$ ab -c 100 -n 1000 "http://49.212.176.26:9000/event/set?app_id=halooios&app_key=ySQkb5LwmbnO7qJR&event_type=install&user_id=test"
Requests per second: 1055.24 [#/sec] (mean)
httpとhttps比較¶
IPベース
[root@web1 admin]# ab -c 100 -n 1000 http://153.126.136.128:9000/
Requests per second: 2472.28 [#/sec] (mean)
http
[root@web1 admin]# ab -c 100 -n 1000 http://ad.i-joji.com:9000/
Requests per second: 2432.54 [#/sec] (mean)
https
[root@web1 admin]# ab -c 100 -n 1000 https://ad.i-joji.com/
Requests per second: 139.95 [#/sec] (mean)
☆SSL通信がボトルネックになっている
[nginx.conf]
worker_processes 1;
worker_connections 1024;
ssl_session_cache shared:SSL:120m;
ssl_session_timeout 5m;
[root@web1 admin]# $ ab -c 100 -n 1000 "https://ad.i-joji.com/event/set?app_id=halooios&app_key=tJ7gLMi5JtzsFbwj&user_id=test&event_type=install"
Requests per second: 152.16 [#/sec] (mean)
あまり変わらない
[nginx.conf]
worker_processes auto;
worker_connections 1024;
ssl_session_cache shared:SSL:120m;
ssl_session_timeout 5m;
[root@web1 admin]# $ ab -c 100 -n 1000 "https://ad.i-joji.com/event/set?app_id=halooios&app_key=tJ7gLMi5JtzsFbwj&user_id=test&event_type=install"
Requests per second: 296.97 [#/sec] (mean)
2倍近く性能アップ
[nginx.conf]
worker_processes auto;
worker_rlimit_nofile 100000;
error_log logs/error.log debug;
events
{
worker_connections 2048;
#multi_accept on;
use epoll;
}
http
{
log_format xgeneration '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$x_app_params"';
server
{
listen 443 ssl;
server_name ad.i-joji.com
charset utf-8;
ssl_certificate /usr/local/openresty/nginx/conf/ssl/ad.i-joji.com.crt;
ssl_certificate_key /usr/local/openresty/nginx/conf/ssl/ad.i-joji.com.key;
ssl_session_cache shared:SSL:120m;
ssl_session_timeout 5m;
sendfile on;
tcp_nopush on;
#tcp_nodelay on;
open_file_cache max=100 inactive=20s;
keepalive_timeout 65;
server_tokens off;
access_log /usr/local/openresty/nginx/logs/access.log xgeneration;
set $x_app_params '-';
set $template_root /usr/local/openresty/nginx/html/templates;
location /
{
default_type text/html;
content_by_lua '
ngx.say("<p>x-generation-api</p>")
';
}
location /favicon {
access_log off;
}
location /create_init
{
content_by_lua_file lua/create_init.lua;
}
location /app/create
{
content_by_lua_file lua/app_create.lua;
}
location /app/update
{
content_by_lua_file lua/app_update.lua;
}
location /app/delete
{
content_by_lua_file lua/app_delete.lua;
}
location /campaign/create
{
content_by_lua_file lua/campaign_create.lua;
}
location /campaign/update
{
content_by_lua_file lua/campaign_update.lua;
}
location /campaign/delete
{
content_by_lua_file lua/campaign_delete.lua;
}
location /network/create
{
content_by_lua_file lua/network_create.lua;
}
location /network/update
{
content_by_lua_file lua/network_update.lua;
}
location /network/delete
{
content_by_lua_file lua/network_delete.lua;
}
location /click
{
content_by_lua_file lua/click.lua;
}
location /install
{
root html;
content_by_lua_file lua/install.lua;
}
location /event/set
{
content_by_lua_file lua/event_set.lua;
}
}
}