Announcement

Collapse
No announcement yet.

Apache and PHP Memory, and Disk optimization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Apache and PHP Memory, and Disk optimization

    I am just trying to further optimize our servers. MySQL is already fully tuned and working well on an SSD drive. On our ESXi host it shows that our cPanel/Cloudlinux server is only using about 4GB of memory, but it has 42GB allocated so quite a bit is not being utilized.

    Does anyone have any recommendations on where this memory could be increased in Apache, or PHP configuration to further improve performance? PHP memory limit is already increased to 512mb, but maybe we should look at increasing it more, or would that not improve performance and maybe decrease security since it is just a limit.

    Also, regarding disk performance with cPanel. What directories would be best to move over to a PCIe SSD card? Would /home, and /var/lib/mysql be the two main ones that are most accessed and need faster read/write speeds? Or are there other directories within the OS that should also be moved over to SSD.

    Thanks!

  • #2
    Could you post output of free -m and mpstat commands, as well as uname -a

    Comment


    • #3
      free -m

      Code:
      total       used       free     shared    buffers     cached
      
      Mem:         42121      21374      20747          0       1259       9653
      
      -/+ buffers/cache:      10461      31660
      
      Swap:         8023          0       8023
      mpstat

      Code:
      Linux 2.6.32-531.1.2.lve1.2.54.el6.x86_64 (ns1.ourservername.com)   04/24/2014      _x86_64_        (4 CPU)
      
      04:31:17 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
      
      04:31:17 PM  all   14.63    2.69    3.34   11.50    0.03    0.37    0.00    0.00   67.45
      uname -a

      Code:
       Linux ns1.ourservername.com 2.6.32-531.1.2.lve1.2.54.el6.x86_64 #1 SMP Tue Mar 25 07:41:27 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

      Comment


      • #4
        You have 10GB free, the rest is used up for caches (which is good).
        If you are not using mod_fcgid --> you might want to switch to that - it would use up a bit of extra RAM - but it will be much faster, and will allow you to use opcaching in a very efficient way.

        Comment


        • #5
          Thank you Igor. This is very helpful. I think currently using mod_suphp as a believe at one point it provided better security. Would we need to switch from mod_suphp, recompile using easyapache, and modify directory permissions to get mod_fcgid working correctly? Just doing some googling on this now...

          Comment


          • #6
            I found this link. I believe we are currently using suexec, and mod_suphp so I am a little confused on the reasons for switching to mod_fcgid, and why cPanel doesnt recommend it for security reasons:

            Comment


            • #7
              No difference in security IMHO - maybe cPanel knows about some attacks against it -- I dont. UserDir might be an issue, if any of your customers use it -- though once again I dont get it why it doesnt work -- it should. Nor there is a need to change directory permissions. Performance is MUCH, MUCH better.

              Regarding tunning -- yes, you need to tune it. See the last 3 blog posts here: http://www.cloudlinux.com/blog/searc...tags=mod_fcgid
              We are also going to launch a replacement for mod_fcgid -- as part of CL (mod_lsapi). A bit faster, much more reliable architecture, tuned out of the box. At least that is the goal. We are just started to test it with a handful of clients -- I think it will take us about a month to release it.

              Comment


              • #8
                Excellent thank you. I will do some reading on how to implement mod_fcgid properly.

                Do you know if moving the cpanel home directory to SSD also improve Apache page load times? Have already moved /var/lib/mysql to PCIe SSD and it has greatly improved performance in the mysql databases. I have limited SSD space, so unfortunately cant move all partitions to SSD.

                Comment


                • #9
                  I thought I would try and set it up, but requests seem to be failing with the following errors (Below). None of the websites load after enabling mod_fcgid by selecting Fast CGI when running easyapache. If I switch php handler back to suphp the sites load again. I tried changing the permissions of the /user/local/apache/logs/fcgidsock, running cagefsctl --force-update, and then restarting apache but no luck. Any help would be appreciated. I had a hard time finding howto documentation for installing configuring mod_fcgid on cPanel. Would this article still be relevant? http://infoliser.com/how-to-configur...nd-easyapache/

                  [Thu Apr 24 19:29:25.480244 2014] [fcgid:error] [pid 525008] (13)Permission denied: mod_fcgid: couldnt bind unix domain socket /usr/local/apache/logs/fcgidsock/525008.329
                  [Thu Apr 24 19:29:25.480312 2014] [fcgid:warn] [pid 525008] (13)Permission denied: mod_fcgid: spawn process /usr/local/cpanel/cgi-sys/php5 error
                  [Thu Apr 24 19:29:25.575235 2014] [fcgid:error] [pid 525008] (13)Permission denied: mod_fcgid: couldnt bind unix domain socket /usr/lo

                  [Thu Apr 24 19:32:02.583181 2014] [fcgid:error] [pid 526765] (13)Permission denied: mod_fcgid: couldnt bind unix domain socket /usr/local/apache/logs/fcgidsock/526765.247
                  [Thu Apr 24 19:32:02.583205 2014] [fcgid:warn] [pid 526765] (13)Permission denied: mod_fcgid: spawn process /usr/local/cpanel/cgi-sys/php5 error
                  [Thu Apr 24 19:32:02.629261 2014] [fcgid:error] [pid 526765] (13)Permission denied: mod_fcgid: couldnt bind unix domain socket /usr/local/apache/logs/fcgidsock/526765.248
                  [Thu Apr 24 19:32:02.629292 2014] [fcgid:warn] [pid 526765] (13)Permission denied: mod_fcgid: spawn process /usr/local/cpanel/cgi-sys/php5 error
                  [Thu Apr 24 19:32:02.648092 2014] [fcgid:error] [pid 526765] (13)Permission denied: mod_fcgid: couldnt bind unix domain socket /usr/local/apache/logs/fcgidsock/526765.249
                  [Thu Apr 24 19:32:02.648135 2014] [fcgid:warn] [pid 526765] (13)Permission denied: mod_fcgid: spawn process /usr/local/cpanel/cgi-sys/php5 error
                  [Thu Apr 24 19:32:02.696229 2014] [fcgid:error] [pid 526765] (13)Permission denied: mod_fcgid: couldnt bind unix domain socket /usr/local/apache/logs/fcgidsock/526765.250
                  [Thu Apr 24 19:32:02.696286 2014] [fcgid:warn] [pid 526765] (13)Permission denied: mod_fcgid: spawn process /usr/local/cpanel/cgi-sys/php5 error
                  [Thu Apr 24 19:32:02.701572 2014] [fcgid:error] [pid 526765] (13)Permission denied: mod_fcgid: couldnt bind unix domain socket /usr/local/apache/logs/fcgidsock/526765.251
                  [Thu Apr 24 19:32:02.701612 2014] [fcgid:warn] [pid 526765] (13)Permission denied: mod_fcgid: spawn process /usr/local/cpanel/cgi-sys/php5 error

                  Comment


                  • #10
                    Make sure you did cagefsctl --force-update
                    Beyond that -- not sure, we usually don deal with the switching itself.

                    Comment


                    • #11
                      In case anyone else is having this error when switching to mod_fcgid. The problem was that the directory permissions for /usr/local/apache/logs needed to be modified to 755. "chmod 755 /usr/local/apache/logs", and after switching to this php handler running "cagefsctl --force-update". After that started working. Thanks again Igor, seeing some major performance improvements!

                      Comment

                      Working...
                      X