2012-05-15 36 views
3

我正在为我的硕士论文进行性能测试,并且Symfony2简单应用程序的性能很差。这是简单的应用程序,一个查询和一些数学。性能差

的命令测试结果:

AB-C10 -t60 http://sf2.cities.localhost/app.php

Server Software:  Apache/2.2.20 
Server Hostname:  sf2.cities.localhost 
Server Port:   80 

Document Path:   /app.php 
Document Length:  2035 bytes 

Concurrency Level:  10 
Time taken for tests: 60.162 seconds 
Complete requests:  217 
Failed requests:  68 
    (Connect: 0, Receive: 0, Length: 68, Exceptions: 0) 
Write errors:   0 
Non-2xx responses:  68 
Total transferred:  393876 bytes 
HTML transferred:  321102 bytes 
Requests per second: 3.61 [#/sec] (mean) 
Time per request:  2772.458 [ms] (mean) 
Time per request:  277.246 [ms] (mean, across all concurrent requests) 
Transfer rate:   6.39 [Kbytes/sec] received 

Connection Times (ms) 
       min mean[+/-sd] median max 
Connect:  0 0 2.1  0  11 
Processing: 230 2641 2493.1 1778 17146 
Waiting:  230 2641 2493.1 1778 17146 
Total:  230 2642 2492.9 1778 17146 

测试之前,我启动了两个命令:

PHP应用程序/控制台--env = prod cache:clear php app/console --env = prod cache:warmup

Symfony检查页面告诉我,我只有intl扩展名,所以apc可能没问题。

我的PHP版本是:

用了Suhosin贴片PHP 5.3.6-13ubuntu3.6

可能有人给我说说还有什么我应该在ENV检查的建议吗?

+0

你应该看看/ POST“连接时报”。在那里你可以看到哪一部分需要最多的时间。 – Darcara

+0

这是ab功能吗? – keram

+0

是的,整个输出应该看起来像[this](http://imgur.com/Fwek5) – Darcara

回答

5

它可以是任何数量的东西,包括您的计算机无法处理负载。我可以给你几点提示,但是在哪里看。

您收到一些错误返回Failed requests: 68。看看Apache日志文件,他们可能会指出问题。如果您没有在其中找到任何内容,请确保已启用日志记录并且您的配置文件具有正确的日志级别设置。你VirtualHost定义应包含类似

LogLevel debug 
CustomLog /var/log/apache2/access-localhost.log vhost_combined 
ErrorLog /var/log/apache2/error-localhost.log 

使用LogLevel debug仅用于调试。您需要将其设置为warnerror进行生产。

在php.ini和脚本中启用错误日志记录,并检查你的php错误日志中是否有任何问题。

确保您的apache2.conf配置正确,尤其是mpm模块。这是一个标准,尽管远非完美配置:

<IfModule mpm_prefork_module> 
    StartServers   5 
    MinSpareServers  5 
    MaxSpareServers  10 
    MaxClients   150 
    MaxRequestsPerChild 0 
</IfModule> 

<IfModule mpm_worker_module> 
    StartServers   2 
    MaxClients   150 
    MinSpareThreads  25 
    MaxSpareThreads  75 
    ThreadsPerChild  25 
    MaxRequestsPerChild 0 
</IfModule> 

确保你有足够的RAM,你需要1GB左右apache2的唯一(至少在linux下)

您也可以尝试根据一个小的静态文本文件(大约2kb)检查性能,看看性能如何。之后,检查简单的<? php echo 'Hello World!' ?>以查看php解释器的性能影响。这两个测试都应该给你一个关于你的apache在当前配置下的能力的指示。如果这两项测试的表现都可以接受,那么您的应用程序速度很慢。

要尝试的另一件事是禁用并发性在你的测试,看看是否有帮助。这将表明您的应用程序或数据库访问中存在并发问题。

ab -c1 -t60 http://sf2.cities.localhost/app.php 

如果它仍然缓慢,谷歌apache performance tuning和(假设你使用MySQL作为数据库)mysql performance tuning

+0

谢谢,很好的答案。 – keram