LoginSignup
0
0

More than 5 years have passed since last update.

ISUCON4の予選問題をやってみる。(その4)

Last updated at Posted at 2015-10-12

その1
その2
その3

nginx のチューニング

パラメータ調整

初期状態のnginxのパラメータは以下のとおり.

# /etc/nginx/nginx.conf
worker_processes  1;

events {
  worker_connections  1024;
}

ベンチマーク実行とReverseProxyも同一サーバで稼働する状態でチューニングがやりにくいけど、
とりあえず、CPU(m3.xlarge=4)に対して設定値を変更して調整してみる。

# /etc/nginx/nginx.conf
worker_processes  2;
worker_rlimit_nofile 40000;
events {
  worker_connections  10000;
}
http {
  sendfile on;
  tcp_nopush on;
  ...

プロセス単位のファイルディスクリプタのOpen数 (worker_rlimit_nofile) を大きくしとく

$ sudo service nginx restart
$ cat /proc/2559/limits
Max open files            40000                40000                files

nginx と ReverseProxy間をUnix domain socket 通信へ変更

# /etc/nginx/nginx.conf
...
http {
  ...
  upstream app_socket {
    server unix:/var/log/nginx/starman.sock;
  }
  ...
  server {
     ...
     location / {
     proxy_pass http://app_socket;
  }
}
#/etc/supervisord.conf
...
# command=/home/isucon/env.sh carton exec plackup -s Starman --host localhost:8080 -E prod app.psgi
command=/home/isucon/env.sh carton exec plackup -s Starman --listen /var/log/nginx/starman.sock -E prod app.psgi
...

これで nginx と Starmanを再起動したろころ、nginxからsocketファイルのアクセスでpermission deniedがでた。
nginx を user isucon; で起動したら正常にアクセスできたのでとりあえずそうしておく。

あらめてベンチマーク

$  ./benchmarker bench --workload 10
14:10:18 type:info      message:launch benchmarker
14:10:18 type:warning   message:Result not sent to server because API key is not set
14:10:18 type:info      message:init environment
14:10:35 type:info      message:run benchmark workload: 10
14:11:36 type:info      message:finish benchmark workload: 10
14:11:41 type:info      message:check banned ips and locked users report
14:11:43 type:report    count:banned ips        value:642
14:11:43 type:report    count:locked users      value:4299
14:11:43 type:info      message:Result not sent to server because API key is not set
14:11:43 type:score     success:179350  fail:0  score:38744

38774点

MySQLのチューニング

チューニングというか、これぐらいの利用だとMyISAMでいいんじゃね?ということでそうしてみる

#sql/schema.sql
CREATE TABLE IF NOT EXISTS `users` (
...
) DEFAULT CHARSET=utf8, ENGINE=myisam;

CREATE TABLE IF NOT EXISTS `login_log` (
...
) DEFAULT CHARSET=utf8, ENGINE=myisam;

これでベンチマーク

14:40:35 type:score     success:183000  fail:0  score:39533

39533点
とりあえずヒカリエレベルまで達した。
http://isucon.net/archives/40576269.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0