[英]Poor performance
我正在为我的硕士论文进行性能测试,而且我的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 app / console --env = prod cache:清除php app / console --env = prod cache:warmup
Symfony检查页面告诉我,我只有没有intl扩展名,所以apc可能没问题。
我的PHP版本是:
带有Suhosin-Patch的PHP 5.3.6-13ubuntu3.6
有人可以给我建议我应该在我的环境中检查什么?
它可以是任何数量的东西,包括您的计算机无法处理负载。 我可以给你几点指示。
您收到一些错误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
用于调试。 您需要将其设置为warn
或生产error
。
启用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>
确保你有足够的内存,你只需要大约1GB的apache2(至少在Linux下)
您还可以尝试针对小型静态文本文件(大约2kb)检查性能,并查看性能的外观。 在那之后检查简单<? php echo 'Hello World!' ?>
<? php echo 'Hello World!' ?>
<? php echo 'Hello World!' ?>
看看php解释器的性能影响。 这两个测试都应该告诉您apache在当前配置下的功能。 如果两个测试中的性能都可以接受,那么你的应用程序就会很慢。
另一件要尝试的是在测试中禁用并发性,看看是否有帮助。 这将表明您的应用或数据库访问中的并发问题。
ab -c1 -t60 http://sf2.cities.localhost/app.php
如果它仍然很慢,谷歌apache performance tuning
和(假设你使用MySQL作为你的数据库) mysql performance tuning
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.