Howdy, Stranger!

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


Help me optimizing my wordpress site
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 optimizing my wordpress site

BubblesBubbles Member
edited December 2013 in Help

Hi there. I just got a 512 MB ram openvz vps and am planning on running a community based wordpress site (buddypress) on it. So far, I am the only user on it trying to set everything up.

First of all, I am having an unresolvable (by me) problem regarding php-cgi. Whenever I edit or use the site, php-cgi process starts consuming almost 80% of ram. Here's a screenshot showing usage when I was reloading just the frontpage.

My apache httpd.conf:

StartServers       3
MinSpareServers    3
MaxSpareServers   14
ServerLimit      74
MaxClients       50
MaxRequestsPerChild  1000

I haven't added any wordpress cache plugin nor any other cache (i am using php apc though).

My wordpress installed plugins is around 10, since I need those plugins to get the community working.

I am worried that if a single user, me, can get the ram usage to hit 80%, what will happen when members start joining and accesing the site at the same time.

Please help.

Comments

  • I personally recommend switching to php-fpm. You should get better performance afaik.

  • Is this your default config?

    StartServers 3 
    MinSpareServers 3 
    MaxSpareServers 14 
    ServerLimit 74 
    MaxClients 50 
    MaxRequestsPerChild 1000 
    

    How about reducing it?

  • BubblesBubbles Member
    edited December 2013

    @ErawanArifNugroho said:
    Is this your default config?

    StartServers 3 
    MinSpareServers 3 
    MaxSpareServers 14 
    ServerLimit 74 
    MaxClients 50 
    MaxRequestsPerChild 1000 
    

    How about reducing it?

    That was not the default config. I actually reduced the default config. Do I need to reduce it more?

  • Have you tried with Nginx?
    How many visits do you get?

  • BubblesBubbles Member
    edited December 2013

    @sergiodelatorre said:
    Have you tried with Nginx?
    How many visits do you get?

    As I mentioned before, I am the only user right now as I am setting up the site. I might get some visits from bots or random visitors. And I really wanted to use apache :(

  • Yes, try to lower it, like

    StartServers 1
    MinSpareServers 2
    MaxSpareServers 5
    ServerLimit 74 
    MaxClients 50 
    MaxRequestsPerChild 100
    
  • There are few things that you could do:

    • try to use php-fpm, with pm=ondemand and see how it goes

    • disable/unload php module that you don't need

    • disable php cache first, enable it later on

    • if your VPS OS debian, use dotdeb repository so you'll get most recent php package

    • replace apache with nginx

    • install cache system/plugin

    • some plugin usually cause problems, or consume more memory, try to disable all, and then enable it one-by-one, (if you only use few plugins), otherwise there is a plugin for this purpose, just search Wordpress website.

  • First, try running PHP as an Apache module, it's probably the easiest solution. Any one of those should help you quite a bit. I am running the standard LAMP with Apache and mod-php on one of my servers. It runs a dozen low use WP sites and only consumes about 350MB of RAM.

    Second, do you have a particular reason for using Apache vs Nginx? There are many writeup on the web on how to run Wordpress on Nginx and PHP-FPM, it's not hard at all.

    Finally, can you run php with FastCGI? As the name implies, it would make it fast :) and would use less ram if configured well.

    Also, make sure your WP site isn't been targeted by a botnet. One of my sites became a target of an attack, and it spiked the memory usage through the roof. Solution to that, BTW, is to move your wp-login.php file.

  • Pls correct me if I am wrong but isn't nginX for mostly static pages? Since I am running a community site, with lots of activities, I felt that apache would be better. I think fastCGi was installed as default. Might have to look at php-fpm or mod_php (2 different things, right?)

    I haven't yet installed any cache plugins because I am editing the whole site and dont want anything cached right now. I even disabled cloudflare cache while I am setting everything up :)

  • jarjar Patron Provider, Top Host, Veteran

    Cache SQL queries with W3 or super cache. Install mod_pagespeed, spend some time with varnish.

  • Is caching the only solution? No tricks to optimize, say, the php config? :D

  • Nginx + php-fpm should have less memory footprint. Nginx doesn't is event based, it doesn't spawn a new thread for each request as Apache does.

    Obviously Nginx can hande dynamic content and it's the most used server by top 1000 websites

  • jarjar Patron Provider, Top Host, Veteran

    @Bubbles said:
    Is caching the only solution? No tricks to optimize, say, the php config? :D

    Reducing each visitors footprint will be the most effective tweaks. Every tweak you can do will of course assist.

  • I always use Nginx+Php5-fpm, but since you're comfortable to work with Apache, then we would go with Apache, and tweak all necessary component :)

    For Php, try to reduce the max instance too :)

  • @jarland - what about caching SQL queries via my.cnf and save a plugin, as an alternative?

    query_cache_type = 1
    query_cache_limit = 1M
    query_cache_size = 8M

  • jarjar Patron Provider, Top Host, Veteran

    @connercg said:
    jarland - what about caching SQL queries via my.cnf and save a plugin, as an alternative?

    query_cache_type = 1
    query_cache_limit = 1M
    query_cache_size = 8M

    Never tried it. Worth a shot :)

  • It's also worth temporarily disabling all plugins to see if the RAM usage drops off. There could be a badly written plugin, with a well written alternative available.

  • Do a top and look more closely at the rss column. It's probably far lower than the allocated memory. It'll get swapped out eventually so men used is a bit misleading. Don't fret unless you start seeing swap churn.

  • Bubbles said: I think fastCGi was installed as default. Might have to look at php-fpm or mod_php (2 different things, right?)

    I might be out of the loop a bit, but I don't believe any of the main distributions install PHP via FastCGI out of the box, so that might be something to look at as well. However Mod_php is the easiest way to go, and for a low usage site (500-1000 hits/day) it will work just fine.

    As pointed out above by others, Nginx is not for static pages only. In fact, the way you have Apache setup with PHP-CGI, Nginx would work in much the same way. Nginx serves the static content, and passes off dynamic stuff to PHP. But if you don't want to bother with Nginx, you really do not need to, unless you have a site that gets more than 10,000 hits/day, or more.

  • nocomnocom Member
    edited December 2013

    switch to lighttpd CGI/FastCGI XCache, i have 1.3mil alexa rank website hosted with 128/256mb vps - Memory Usage 35 of 256 MB (13.67%) /wordpress with about 8 plugins and rss agregator , 3 mysql db, 3 php scripts.

    Optimize mysql , optimize php - mysql offload?

    RTFM

    ,,wanted to use apache,, - any special reason?

  • I am using virtualmin and FCgid was the default php execution mode. I changed it to mod_php and, to my horror, the ram usage doubled!

    Installed P3 Plugin Profiler in WP and got these results.

    Buddypress and bbpress are essential plugins. Load times seems fine, so doesn't seem to be much of a problem from their end.

    Seems like I have to shift to nginX. I wished I could have solved the problem with apache instead of running away from it :(

  • mod_php uses more memory, nothing new :) Every Apache child loads mod_php

    Have a look:
    http://www.openlogic.com/wazi/bid/209956/mod_php-vs-FastCGI-vs-PHP-FPM-for-Web-Server-Scripting

  • @Bubbles: Random question but what did you use to generate the graph in your original post?

Sign In or Register to comment.