表现不佳 [英] Poor performance

查看:270
本文介绍了表现不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做性能测试,对我的硕士论文,我得到Symfony2的简单应用程序的性能非常差。这是简单的应用程序,一个查询和一些数学。

有关命令测试结果:


  

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


 服务器软件:阿帕奇/ 2.2.20
服务器主机名:sf2.cities.localhost
服务器端口:80文件路径:/app.php
文件长度:2035字节并发等级:10
采取测试时间:60.162秒
完整的请求:217
失败的请求:68
   (连接:0,接收:0,长度:68,例外:0)
写错误:0
非2xx应答:68
共转移:393876字节
HTML转移:321102字节
每秒请求:3.61 [#/秒(均值)
每个请求的时间:2772.458 [毫秒](均值)
每个请求的时间:277.246 [毫秒](意思是说,在所有的并发请求)
传输速率:6.39 [字节/秒]已接收连接时间(毫秒)
              分钟平均[+/- SD]平均最大
连接:0 0 0 2.1 11
处理:230 2641 1778 2493.1 17146
等待:230 2641 1778 2493.1 17146
总计:230 2642 1778 2492.9 17146

测试前我发起了两个命令:


  

PHP应用程序/控制台--env = PROD缓存:明确
  PHP应用程序/控制台--env = PROD缓存:热身


Symfony的检查页,告诉我,我只是没有国际扩展,因此,APC可能是好的。

我的PHP版本是:


  

PHP 5.3.6-13ubuntu3.6用了Suhosin-补丁


能有人给我指教一下还有什么我应该在ENV检查?


解决方案

它可以是任何数量的东西,包括你的电脑就不能处理负载。我可以给你一些指点哪里看,虽然

您也越来越返回无法请求一些错误:68 。看看到Apache日志文件,他们可能会指出问题。如果你没有发现他们什么确保启用了日志记录和您的配置文件具有正确的日志级别设置。你的虚拟主机定义应包含类似于

  LogLevel的调试
 的CustomLog /var/log/apache2/access-localhost.log vhost_combined
 错误日志/var/log/apache2/error-localhost.log

使用 LogLevel的调试仅用于调试。你会想将它设置为警告错误进行生产。

在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),看看其性能的样子。对简单的&LT ;?查收后PHP的回声世界,你好! ?> 来看看PHP间preTER对性能的影响。这两项测试应该给你一个什么样的Apache是​​能够与当前配置的指示。如果表现在两个测试可以接受的,这是你的应用程序,很慢。

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

  AB -C1 -t60 HTTP://sf2.cities.localhost/app.php

如果它仍然是缓慢的,谷歌 apache的性能优化和(假设你使用MySQL作为数据库)的MySQL性能优化

I am doing performance tests for my master thesis and I'm getting very poor performance of Symfony2 simple application. It's simple app, one query and some math.

Test results for command:

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

Before test I launched two commands:

php app/console --env=prod cache:clear php app/console --env=prod cache:warmup

Symfony check page tells me that I only don't have intl extension, so apc is probably ok.

My PHP version is:

PHP 5.3.6-13ubuntu3.6 with Suhosin-Patch

Could someone give me advice about what else should I check in my env?

解决方案

It can be any number of things, including that your computer just can't handle the load. I can give you a few pointers where to look though.

You are getting some errors returned Failed requests: 68. Look into the apache logfiles, they might indicate the problem. If you don't find anything in them make sure logging is enabled and your config file has the correct log level set. Your VirtualHost definition should contain something like

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

Use LogLevel debug only for debugging. You'll want to set it to warn or error for production.

Enable error logging in php.ini and your scripts and check your php error log for any problems.

Make sure your apache2.conf is configured correctly, especially the mpm module. Here is a standard, albeit far from perfect configuration:

<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>

Make sure you have enough RAM for that, you'll need around 1GB for apache2 only (at least under linux)

You can also try to check performance against a small static text file (around 2kb) and see what that performance looks like. After that check against the simple <? php echo 'Hello World!' ?> to see the performance impact of the php interpreter. Both tests should give you an indication of what your apache is capable of with the current configuration. If the performance is acceptable in both tests, it's your app that's slow.

Another thing to try is disabling concurrency in your test and see if that helps. That would indicate concurrency problems in your app or database access.

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

If it's still slow, google apache performance tuning and (assuming you use MySQL as your database) mysql performance tuning

这篇关于表现不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆