Apache and PHP Memory, and Disk optimization
Forum
  1. Forums
  2. CloudLinux and Control Panels
  3. CloudLinux and cPanel
  1. Wesley Render
  2. Thursday, 24 April 2014
  3.  Subscribe via email
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!
Rate this post:
  1. 24.04.2014 18:04:16
  2. # 1
Igor Seletskiy Accepted Answer
Posts: 1200
Joined: 09.02.2010
0
Votes
Undo
Could you post output of free -m and mpstat commands, as well as uname -a
  1. 24.04.2014 18:04:35
  2. # 2
Wesley Render Accepted Answer
Posts: 49
Joined: 16.05.2011
0
Votes
Undo
free -m
total       used       free     shared    buffers     cached
Mem: 42121 21374 20747 0 1259 9653
-/+ buffers/cache: 10461 31660
Swap: 8023 0 8023
mpstat
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
 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
  1. 24.04.2014 18:04:11
  2. # 3
Igor Seletskiy Accepted Answer
Posts: 1200
Joined: 09.02.2010
0
Votes
Undo
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.
  1. 24.04.2014 19:04:32
  2. # 4
Wesley Render Accepted Answer
Posts: 49
Joined: 16.05.2011
0
Votes
Undo
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...
  1. 24.04.2014 19:04:21
  2. # 5
Wesley Render Accepted Answer
Posts: 49
Joined: 16.05.2011
0
Votes
Undo
 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 doesn't recommend it for security reasons:

http://docs.cpanel.net/twiki/bin/view/EasyApache/Php/RequestHandling#FCGI%20Considerations
  1. 24.04.2014 19:04:59
  2. # 6
Igor Seletskiy Accepted Answer
Posts: 1200
Joined: 09.02.2010
0
Votes
Undo
No difference in security IMHO - maybe cPanel knows about some attacks against it -- I don't. UserDir might be an issue, if any of your customers use it -- though once again I don't get it why it doesn't 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/search.php?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.
  1. 24.04.2014 19:04:27
  2. # 7
Wesley Render Accepted Answer
Posts: 49
Joined: 16.05.2011
0
Votes
Undo
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 can't move all partitions to SSD.
  1. 24.04.2014 23:04:34
  2. # 8
Wesley Render Accepted Answer
Posts: 49
Joined: 16.05.2011
0
Votes
Undo
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-configure-apache-2-2-with-php-fpm-using-whm-cpanel-and-easyapache/

[Thu Apr 24 19:29:25.480244 2014] [fcgid:error] [pid 525008] (13)Permission denied: mod_fcgid: couldn't 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: couldn't bind unix domain socket /usr/lo



[Thu Apr 24 19:32:02.583181 2014] [fcgid:error] [pid 526765] (13)Permission denied: mod_fcgid: couldn't 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: couldn't 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: couldn't 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: couldn't 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: couldn't 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
  1. 25.04.2014 07:04:40
  2. # 9
Igor Seletskiy Accepted Answer
Posts: 1200
Joined: 09.02.2010
0
Votes
Undo
Make sure you did cagefsctl --force-update
Beyond that -- not sure, we usually don\'t deal with the switching itself.
  1. 26.04.2014 23:04:30
  2. # 10
Wesley Render Accepted Answer
Posts: 49
Joined: 16.05.2011
0
Votes
Undo
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!
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!
Guest
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below. Supports gif,jpg,png,zip,rar,pdf
• Insert • Remove Upload Files (Maximum File Size: 2 MB)
Captcha
To protect the site from bots and unauthorized scripts, we require that you enter the captcha codes below before posting your question.