Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Help me optimize php-cgi for faster processing time :(
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Help me optimize php-cgi for faster processing time :(

gianggiang Veteran
edited May 2012 in Help

Hi guys,

I was trying a lot of things to optimize the speed of php-cgi processing time on my test wordpress website with around 30 queries,

Here is the result, I don't know if they are faster or just need to optimize more :(

just php-cgi (installed with LEA script): 0.1xx second to process around 30 queries.
php-cgi + memcached: 0.2xx second to process the same queries
php-cgi + varnish: 0.2xx second to process the same queries

I was trying to adjust PHP_FCGI_CHILDREN and PHP_FCGI_MAX_REQUESTS but it didn't help much :(
Is there any way to optimize to get faster processing time?

My VPS spec:
4 cores i7 2600k
15GB SSD (dd around 400MB/s)

Thank you all for reading my post ;)
Giang

Comments

  • djvdorpdjvdorp Member

    I would advise you to use php-fpm instead of php-cgi. For good config, check out the tuxlite.com scripts :)

    Thanked by 1ElliotJ
  • gianggiang Veteran

    php-fpm gave me slower processing time than php-cgi :( I've tested on difference VPS (with config from: https://github.com/cedricd/Server/tree/master/settings/php5/fpm)

  • Are you using some opcode optimizers/caches?

  • Install APC.

  • gianggiang Veteran

    @Daniel said: Install APC.

    @gsrdgrdghd said: Are you using some opcode optimizers/caches?

    I forgot to mention. I've installed php-apc with default config :D

  • @giang said: I forgot to mention. I've installed php-apc with default config :D

    Ah ok, I noticed a 50% reduction in loading time with APC

  • gianggiang Veteran

    @Daniel said: Ah ok, I noticed a 50% reduction in loading time with APC

    APC didn't affect my php-cgi :D With or without, the processing time is the same :D

  • haphanhaphan Member

    Giang,

    I dont really get your result. How did you measure loading time(ab perhaps)? Did you make use of any front web server (nginx/lighttpd)?
    And how come memcache takes longer to load a page. Perhaps you should also tell us what plugins are enabled in your wordpress instance.

    On the other hand, loading a wordpress site in 0.1s is not that bad. Full page caching with memcached can take loading time to as low as 0.05s so not really a huge improvement.

    Ha phan

  • gianggiang Veteran

    I measure by Wordpress command:

    <?php echo $wpdb->num_queries; ?> <?php _e('queries'); ?>. in <?php timer_stop(1); ?> <?php _e('seconds.'); ?>
  • rchurchrchurch Member

    Isn't it php-fastcgi or php-fcgi rather than php-cgi you should be using?

    You haven't given much info on your memory and mysql setup. Are you on a dedicated or lightly loaded VPS?

  • gianggiang Veteran

    It's php-cgi installed by LEA's script :D MySQL installed by this script as well, and it's a vps :D

  • exussumexussum Member

    Is it a shared environment ? Running as an apache module can speed things up. Obviously using more memory than your current set up

  • gianggiang Veteran

    @exussum said: Is it a shared environment ? Running as an apache module can speed things up. Obviously using more memory than your current set up

    No, there is only one website (the website I'm talking in this topic) on my VPS, current ram usage is about 300MB and there is 1200M free ram.

    I'm running Nginx because I don't know anything about manual config with Apache :(

  • joepie91joepie91 Member, Patron Provider

    @djvdorp said: I would advise you to use php-fpm instead of php-cgi. For good config, check out the tuxlite.com scripts :)

    php-fpm is actually just a process manager for php-fcgi which he seems to already be using.

    Anyhow, personally I think your loading time issue lies with Wordpress and not with your webserver setup. Wordpress isn't exactly lightweight. To get a better result, measure the loading time on a PHP file that does nothing but echo('test'); - that will show you how long it takes to actually handle the request. Everything beyond that is out of the hands of your httpd or fcgi/fpm setup, and can be attributed to PHP itself.

    <?php
    $start = microtime(true);
    echo('test<br>');
    $total = round(microtime(true) - $start, 6) * 1000;
    echo("Total time: {$total} milliseconds.");
    ?>
    

    (note: code is untested)

Sign In or Register to comment.