Upgrade to Pro — share decks privately, control downloads, hide ads and more …

luckyframeworkで驚異的なスループットを出した話

Avatar for y2k2mt y2k2mt
November 02, 2018

 luckyframeworkで驚異的なスループットを出した話

Avatar for y2k2mt

y2k2mt

November 02, 2018
Tweet

More Decks by y2k2mt

Other Decks in Technology

Transcript

  1. これが何をしているのかというと、動作しているマシンのコア数を取得 して、コア数分の自分自身のプロセスを 立ち上げています count = System.cpu_count if count <= 0

    ... # Start the processes (0_i64...count).each do @processes << future do process = nil Process.run(process_path, args, input: Process::Redirect::Close, output: Process::Redirect::Inherit, error: Process::Redirect::Inherit )
  2. crystal の簡単なWebサーバを今回は luckyframework で作ってみ ました。作成したアプリケーションを supervisord で並行して実行す るために のような設定ファイルを書きました [program:bar]

    command=/home/foo/bar/server process_name=%(program_name)s_%(process_num)02d numprocs=2 user=foo autorestart=true stdout_logfile=/var/log/supervisor/bar-supervisord.log stdout_logfile_maxbytes=1MB stdout_logfile_backups=5 stdout_capture_maxbytes=1MB redirect_stderr=true
  3. 実行! 環境は Ubuntu 16.04 CPU: 4 MEM: 16G (t2‑xlarge) です

    numprocs=1 wrk -c20 -t2 http://localhost:5000/heartbeat Running 10s test @ http://localhost:5000/heartbeat 2 threads and 20 connections Thread Stats Avg Stdev Max +/- Stdev Latency 305.35us 71.91us 1.02ms 88.04% Req/Sec 32.61k 1.22k 36.09k 71.78% 655191 requests in 10.10s, 48.74MB read Requests/sec: 64870.08 Transfer/sec: 4.83MB
  4. numprocs=2 Running 1m test @ http://localhost:5000/heartbeat 2 threads and 20

    connections Thread Stats Avg Stdev Max +/- Stdev Latency 180.21us 276.69us 8.09ms 96.72% Req/Sec 69.12k 2.84k 76.07k 71.42% 8252187 requests in 1.00m, 613.85MB read Requests/sec: 137515.74 Transfer/sec: 10.23MB