2016-05-02 11 views
4

私は、スカラプレイフレームワーク2.5とゴランで単純なhello worldの例をベンチマークしています。ゴランはパフォーマンスを大幅に上回っているようですが、パフォーマンスを向上させるためにプレイフレームワークを最適化する方法を知りたいと思います。 私は私のプロジェクトでどこでもデフォルトの設定を使用しPRODモードでプレイ2.5を実行しているベンチマークscala Play 2.5 vs golangベンチマークとプレーフレームワークでのパフォーマンスの最適化

ab -r -k -n 100000 -c 100 http://localhost:9000/ 

に次を使用しています。誰かがパフォーマンスを最大限に引き出すためにプレイサーバーをチューニングするのを助けてくれますか?私はデフォルトのディスパッチャスレッドプールを読んだが、自分のPCにどのような設定を使うのか分からない。また、パフォーマンスに役立つことを確認できる他の分野もありますか?ここ

は、私がPRODモードで代替サーバーを実行するために、SBT(クリーンと段階)を使用して、ターゲット/ユニバーサル/段階で見つかったbatファイルを実行していますのでご注意ください私のmarchineスペック

Intel(R) Xeon(R) W3670 @ 3.20GHz 3.19GHz, 12.0 GM RAM, running windows 7 64-bit 

です/ bin /。ここでプレーここ

package controllers 

import play.api.mvc._ 


class Application extends Controller { 


    def index = Action { 
    Ok("Hello, world!") 
    } 

} 

のソースコードは、ABベンチマークここ

ab -r -k -n 100000 -c 100 http://localhost:9000/ 
This is ApacheBench, Version 2.3 <$Revision: 1706008 $> 
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: 
Server Hostname:  localhost 
Server Port:   9000 

Document Path:  /
Document Length:  13 bytes 

Concurrency Level:  100 
Time taken for tests: 1.537 seconds 
Complete requests:  100000 
Failed requests:  0 
Keep-Alive requests: 100000 
Total transferred:  15400000 bytes 
HTML transferred:  1300000 bytes 
Requests per second: 65061.81 [#/sec] (mean) 
Time per request:  1.537 [ms] (mean) 
Time per request:  0.015 [ms] (mean, across all concurrent requests) 
Transfer rate:   9784.69 [Kbytes/sec] received 

Connection Times (ms) 
       min mean[+/-sd] median max 
Connect:  0 0 0.0  0  1 
Processing:  0 2 1.9  1  72 
Waiting:  0 2 1.9  1  72 
Total:   0 2 1.9  1  72 

Percentage of the requests served within a certain time (ms) 
    50%  1 
    66%  2 
    75%  2 
    80%  2 
    90%  3 
    95%  3 
    98%  5 
    99%  8 
100%  72 (longest request) 

からの結果は、ABベンチマークの結果はgolangここ

package main 

import (
    "fmt" 
    "net/http" 
) 

func handler(w http.ResponseWriter, r *http.Request) { 
    fmt.Fprintf(w, "Hello, world!") 
} 

func main() { 
    http.HandleFunc("/", handler) 
    http.ListenAndServe(":8080", nil) 
} 

のソースコードされているありますゴラン用

ab -r -k -n 100000 -c 100 http://localhost:8080/ 
This is ApacheBench, Version 2.3 <$Revision: 1706008 $> 
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: 
Server Hostname:  localhost 
Server Port:   8080 

Document Path:  /
Document Length:  13 bytes 

Concurrency Level:  100 
Time taken for tests: 0.914 seconds 
Complete requests:  100000 
Failed requests:  0 
Keep-Alive requests: 100000 
Total transferred:  15400000 bytes 
HTML transferred:  1300000 bytes 
Requests per second: 109398.30 [#/sec] (mean) 
Time per request:  0.914 [ms] (mean) 
Time per request:  0.009 [ms] (mean, across all concurrent requests) 
Transfer rate:   16452.48 [Kbytes/sec] received 

Connection Times (ms) 
       min mean[+/-sd] median max 
Connect:  0 0 0.0  0  1 
Processing:  0 1 1.5  1  52 
Waiting:  0 1 1.5  1  52 
Total:   0 1 1.5  1  52 

Percentage of the requests served within a certain time (ms) 
    50%  1 
    66%  1 
    75%  1 
    80%  1 
    90%  1 
    95%  2 
    98%  5 
    99%  7 
100%  52 (longest request) 

ありがとうございます フランシス

更新日:

性能向上では、次の結果が、私はまだパフォーマンスを向上させることができ、他のアイデアに興味

package controllers 

import play.api.mvc._ 
import scala.concurrent.Future 
import play.api.libs.concurrent.Execution.Implicits.defaultContext 


class Application extends Controller { 


    def index = Action.async { 
    Future.successful(Ok("Hello, world!")) 
    } 

} 

@marcospereiraが言ったように、ベンチマークはプレイが比較的あり、

ab -r -k -n 100000 -c 100 http://localhost:9000/ 
This is ApacheBench, Version 2.3 <$Revision: 1706008 $> 
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: 
Server Hostname:  localhost 
Server Port:   9000 

Document Path:  /
Document Length:  13 bytes 

Concurrency Level:  100 
Time taken for tests: 1.230 seconds 
Complete requests:  100000 
Failed requests:  0 
Keep-Alive requests: 100000 
Total transferred:  15400000 bytes 
HTML transferred:  1300000 bytes 
Requests per second: 81292.68 [#/sec] (mean) 
Time per request:  1.230 [ms] (mean) 
Time per request:  0.012 [ms] (mean, across all concurrent requests) 
Transfer rate:   12225.66 [Kbytes/sec] received 

Connection Times (ms) 
       min mean[+/-sd] median max 
Connect:  0 0 0.0  0  1 
Processing:  0 1 2.2  1  131 
Waiting:  0 1 2.2  1  131 
Total:   0 1 2.2  1  131 

Percentage of the requests served within a certain time (ms) 
    50%  1 
    66%  1 
    75%  1 
    80%  2 
    90%  2 
    95%  3 
    98%  5 
    99%  7 
100% 131 (longest request) 
+3

これは、低レベルのhttpライブラリ( 'net/http'を参照)を高レベルのフレームワーク(Play)と比較しているためです。高水準のフレームワークは、より多くのユーティリティを提供し、ゆっくりとしているので、より多くのことをやっています。公平な比較は、ネット(http: "ライブラリ"、Playによって使用される)とGo'net/http'との間になります。一貫性のある結果が得られるまで(jvmでのjitコンパイルのため)、テストをプレイに対して実行することをお勧めします。 – marcospereira

+3

@marcospereira私は 'net/http'を「低レベル」と呼ぶことはほとんどありません。それは主要な抽象化です。1行のコードで経路を開くことができ、着信要求が解析され、すべてのデータに簡単にアクセスできる素敵なオブジェクトに変換されます。実際にはバイナリデータを受け取っていることを考えると、かなり高いレベルになると思います。 OPに。 Playを使わないのはなぜですか?それは吸う。それは私の2セントです。それは過度に抽象化されているのでパフォーマンスが悪いですし、あなたのパフォーマンスが100%苦しんでいる間に、それがあなたに与えるものの80%を使用しないと確信しています。 – evanmcdonnal

+2

プレーのような完全なスタックフレームワークと比較して、低レベルです。これが意味するところでした。 – marcospereira

答えて

2

結果Scalaのはるかに高度な型システムを活用して多くの機能と安全性を提供することに焦点を当てた高水準のフレームワークで、リファクタリング可能でスケーラビリティの高いコードを書くことができます。決してそれほど少なくはありませんが、私はそれをプロダクションで素晴らしいパフォーマンスを得ました。

native socket transportでベンチマークを実行しようとしていることを示唆しているのではなく、Playサーバーを停止することなくベンチマークを数回実行するように@marcospereiraの言葉を繰り返します。 Playベンチマーク結果の標準偏差が異常に高い(SDの値が2.2で平均1)ようで、JITがコードの最適化を完了していない可能性があります。

関連する問題