2016-07-21 11 views
3

私は、php 5.5とapache 2.4でubuntu 14.04をセットアップしました。Laravel 5.2長いルートを持つ高いCPUを持つ

新鮮なlaravel 5.2がインストールされました。プロジェクト内のデータベース接続はありません。

/HTTP/routes.phpのとに編集したアプリケーションにするとき、私はその後:だから、基本的に

Route::get('/', function() { 
    return view('welcome'); 
}); 


Route::get('/test/direct', function() { 
    return view('welcome'); 
}); 

私は歓迎ビューを示す2つのルートがあります。

私はその後、実行します。

ab -n 9999999 -t 300 -c 30 http://xxxxx/laravel52/public 

CPUが6%以上を行くことはありませんし、私は次のような結果を得る:

Server Software:  Apache/2.4.7 
Server Hostname:  xxxxx 
Server Port:   80 

Document Path:   /laravel52/public 
Document Length:  328 bytes 

Concurrency Level:  30 
Time taken for tests: 146.271 seconds 
Complete requests:  50000 
Failed requests:  0 
Non-2xx responses:  50000 
Total transferred:  28550000 bytes 
HTML transferred:  16400000 bytes 
Requests per second: 341.83 [#/sec] (mean) 
Time per request:  87.763 [ms] (mean) 
Time per request:  2.925 [ms] (mean, across all concurrent requests) 
Transfer rate:   190.61 [Kbytes/sec] received 

Connection Times (ms) 
       min mean[+/-sd] median max 
Connect:  15 47 77.0  40 3157 
Processing: 17 41 28.1  37 2140 
Waiting:  17 40 26.9  37 2140 
Total:   40 87 84.3  78 3208 

Percentage of the requests served within a certain time (ms) 
    50%  78 
    66%  83 
    75%  86 
    80%  89 
    90% 100 
    95% 120 
    98% 162 
    99% 228 
100% 3208 (longest request) 

私はその後、実行します。

ab -n 9999999 -t 300 -c 30 http://xxxxx/laravel52/public/test/direct 

CPU、直ちに最終的に私はこれらの結果を得ます:

Server Software:  Apache/2.4.7 
Server Hostname:  xxxxx 
Server Port:   80 

Document Path:   /laravel52/public/test/direct 
Document Length:  1023 bytes 

Concurrency Level:  30 
Time taken for tests: 300.001 seconds 
Complete requests:  11888 
Failed requests:  0 
Total transferred:  24585740 bytes 
HTML transferred:  12161424 bytes 
Requests per second: 39.63 [#/sec] (mean) 
Time per request:  757.070 [ms] (mean) 
Time per request:  25.236 [ms] (mean, across all concurrent requests) 
Transfer rate:   80.03 [Kbytes/sec] received 

Connection Times (ms) 
       min mean[+/-sd] median max 
Connect:  4 12 29.4  8 1020 
Processing: 75 740 790.0 609 14045 
Waiting:  74 738 789.9 608 14043 
Total:   88 752 789.4 622 14050 

Percentage of the requests served within a certain time (ms) 
    50% 622 
    66% 835 
    75% 952 
    80% 1020 
    90% 1237 
    95% 1536 
    98% 2178 
    99% 2901 
100% 14050 (longest request) 

ルートルートでないと、接続が多数ある場合、laravelがcpuをスパイクするようです。これはまた、laravel 4.2で新しくインストールされた場合にも発生します。

これがなぜ起こるのか誰でも指摘できますか?私は本当にこれを解決する必要があります。

私のサーバーには、8GBのRAMを備えた8コアIntel(R)Core(TM)i7-4771 CPU @ 3.50GHzが搭載されています。

ありがとうございました。

答えて

0

ルートをキャッシュしてルート解決を高速化できますが、route cachingはクロージャベースのルートでは機能しません。ルートキャッシングを使用するには、コントローラクラスを使用するようにクロージャルートを変換する必要があります。

ルートをキャッシュするには、php artisan route:cacheを実行し、キャッシュphp artisan route:clearをクリアします。

php artisan optimizeは、共通のクラスを1つのファイルでコンパイルして、各要求のインクルード数を減らし、すべての構成ファイルを1つのファイルにまとめて高速に読み込むことも考慮する必要があります。

+0

こんにちは@Malta、それは問題を解決しませんでした。まだ残っています。ウェルカムビューを返す1つのメソッドを持つコントローラを作成しました。私が 'TestController @ showWelcome'に持っていた2つのルートをマップしました。 Ran 'php artisan route :: cache'と' php artisan optimize'を実行します。多かれ少なかれ同じ結果を得ました。 –

0

これを忘れてください。ララヴェル問題ではありません。このマシン固有の問題です。私はubuntu 12.04を14.04にアップグレードしました。そうすることで、Apache 2.2を2.4にアップグレードしましたが、設定の一部を維持しました。 Magentoのような他のフレームワークも同じように動作するので、問題はそこにあるはずです。

関連する問題