Apache :: Curvve Media Blog

Guide to Apache PHP / FCGI performance tuning on Plesk linux servers

Posted by | Guides | 2 Comments

Tuning Plesk servers for optimal Apache PHP / FCGI performance can be a nightmare. Here is a great guide on getting you started. Special thanks to the LinuxDriver blog for some of these great tips.

This should go without saying: make sure to backup your configuration files before trying any new settings!

Step 1: Modify fcgid.cpnf

nano /etc/httpd/conf.d/fcgid.conf
LoadModule fcgid_module modules/mod_fcgid.so

AddHandler fcgid-script fcg fcgi fpl

FcgidIPCDir /var/run/mod_fcgid/sock
FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm

FcgidInitialEnv RAILS_ENV production

FcgidIdleTimeout 3600
FcgidIdleScanInterval 480
FcgidBusyTimeout 1800
FcgidBusyScanInterval 480
FcgidZombieScanInterval 12
FcgidErrorScanInterval 12
FcgidProcessLifeTime 0

# Change the rate at which new FastCGI processes are spawned under load. Higher=faster
FcgidSpawnScoreUpLimit 10

# Higher number = spawning more FastCGI processes decreases the spawn rate (controls runaway
FcgidSpawnScore 1

# Higher number = terminating FastCGI processes decreases the spawn rate (controls runaway)
FcgidTerminationScore 2

# Increase the FastCGI max request length for large file uploads (needed for some sites)
FcgidMaxRequestLen 1073741824

FcgidMaxRequestsPerProcess 100000
#FcgidMinProcessesPerClass 3
FcgidMaxProcessesPerClass 4
FcgidMaxProcesses 16
FcgidIOTimeout 1800

Modifying your PHP.conf

Next, let's edit our php.conf

nano /etc/httpd/conf.d/php.conf
AddHandler php-script .php
AddType text/html .php
DirectoryIndex index.php

Step 3: SWTune – Optional

Now we are going to create a special SWTune.conf configuration file. I've had mixed success with this, so please experiment with this. I believe this will be more effective on lower resource systems. You may choose to skip this step.

nano /etc/httpd/conf.d/swtune.conf
HostnameLookups off
KeepAlive Off

StartServers 1
ServerLimit 2
MinSpareThreads 32
MaxSpareThreads 96
ThreadLimit 64
ThreadsPerChild 32
ThreadStackSize 2097152
MaxClients 64
MaxRequestsPerChild 0

Step 4: CPU and Memory configuration

Finally, this next shell command will determine the best configuration settings based on your processors and amount of memory.

num_cpus=$(awk '/^processor/{count++}END{print count}' /proc/cpuinfo)
sed -i 's%[#]*HTTPD=.*%HTTPD=/usr/sbin/httpd.worker%g' /etc/sysconfig/httpd
sed -i 's%HTTPD_BINs.*%HTTPD_BIN /usr/sbin/httpd.worker%g' /etc/psa/psa.conf
sed -i "s/(ServerLimits*).*/1$(( $num_cpus * 2 ))/" /etc/httpd/conf.d/swtune.conf
sed -i "s/(MaxClientss*).*/1$(( ( $num_cpus * 2 ) * 32 ))/" /etc/httpd/conf.d/swtune.conf
service psa stopall
service psa restart

Notes:- The earlier mentioned sequences or patterns will adapt the host limitations and Optimum Customers in respect to the CPU quantity.

Contact Us

Have a question? Send us a message. We'll get back to you soon.

captcha