How to reduce the number of php-cgi.exe processes and fastcgi+php5.3.3 configuration methods in IIS6

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Optimal configuration of fastcgi

FastCGI optimized configuration file Fcgiext.ini, it's in%windir%\system32\inetsrv. We will try to configure it in two ways: fastcgi admin script fcgiconfig.js, notepad edit Fcgiext.ini.

Script Configuration fastcgi

Open your command line cmd.exe and switch to directory%windir%\system32\inetsrv. Copy the following, enter the following to complete. Set the parameters that follow as needed.

1 cscript fcgiconfig.js-set-section: "PHP"-instancemaxrequests:5000

2

3 cscript fcgiconfig.js-set-section: "PHP"-environmentvars:php_fcgi_max_requests:5000

4

5 cscript fcgiconfig.js-set-section: "PHP"-requesttimeout:360

6

7 cscript fcgiconfig.js-set-section: "PHP"-activitytimeout:120

The meaning of the script, respectively:

Set up application pool recycling. The FASTCGI process request reaches the instancemaxrequests value of 5000, and the application pool is automatically recycled. The default value is 1000.

The application pool is automatically recycled when the environment variable php_fcgi_max_requests reaches 10000.

Requesttimeout sets the request timeout, which is the maximum time allowed for the request, and if the FASTCGI process request exceeds this setting, the value is 90 seconds.

ACTIVITYTIMEOUT Specifies the maximum active time requested by the fastcgi process, and during the set time, the FASTCGI process and IIS do not communicate and terminate the process. The default value is 70 seconds.

Note: script commands are global settings for all PHP sites running on fastcgi on the server. So for multi-site virtual machines, instancemaxrequests set to PHP site number X500 relatively ideal.

500 is a variable. If there are 10 sites, then 200x50=5000, analogy. Large-volume servers, the number of small sets of frequently recycled application pool, is not a sensible approach. Although, the system has recovered a lot of resources.

Requesttimeout value is too large, will undoubtedly let more consumption system resources requests to run; Activitytimeout set to 120 seconds of inactivity is good, or 30 seconds of inactivity on the disconnect good, varies from person to person.

Copy and paste for lazy people

fastcgi configuration file Fcgiext.ini settings

instancemaxrequests=10000

environmentvars=php_fcgi_max_requests:10000

requesttimeout=360

activitytimeout=120

Copy the code above to the end of the Fcgiext.ini and save it.

Optimal configuration of PHP5.3.6

PHP5.3.6 's php.ini configuration is also divided into two parts: the configuration of fastcgi, and the configuration of PHP itself. My PHP5.3.6 is installed in C:\PHP.

PHP.ini about the fastcgi part

Fastcgi.impersonate = 1

Cgi.fix_pathinfo=1

Cgi.force_redirect = 0

PHP.ini part about itself

First, the search Extension_dir, remove the previous note ";", modified to:

1 Extension_dir = "C:/php/ext"

Second, the search Date.timezone, remove the previous note ";", modified to:

1 Date.timezone = "Asia/shanghai"

Third, search the following, and then remove the front gaze ";"

Extension=php_gd2.dll

Extension=php_mbstring.dll

Extension=php_mysql.dll

And so your PHP basically can be unimpeded. As for some of the more advanced revisions, we don't need to study that deep, do we?

Optimize fastcgi profile Fcgiext.ini in Windows 2003+IIS6 to reduce php-cgi.exe process and amount of memory

Originally heard that fastcgi than ISAPI is in the server loaded, configuration environment for Windows 2003+iis6+fastcgi (fcgi) + PHP5.2.17, after observing with a long time, found that the work in fastcgi mode of PHP will occupy more and more memory, a little bit more php-cgi process more than N, the same situation can be more than the original ISAPI mode when more than hundreds of M, my server memory only 2G can not afford AH.

I searched the internet and found that many people faced the same problem. A more formal explanation from the PHP authorities is that the php-cgi process does not have a memory leak, and php-cgi reclaims all the memory used by the script at the end of each request, but does not release it to the operating system, but continues to hold it for the next PHP request. This is probably done to reduce memory fragmentation or to resolve the time uncontrollable issues that are required to release back to the operating system from the application's memory. But if a PHP request uses a large memory operation such as FTP or zlib, it will result in a large chunk of system memory being php-cgi and not being exploited.

The solution to this problem is to optimize the fastcgi configuration file parameters in the Web server configuration.

You can set php-cgi process-related parameters in the C:\WINDOWS\system32\inetsrv\fcgiext.ini file, such as:

[Types]

php = PHP

[PHP]

Exepath=c:\php-5.3.8-nts-win32-vc9-x86\php-cgi.exe

maxinstances=100

instancemaxrequests=10000

environmentvars=php_fcgi_max_requests:10000

requesttimeout=600

activitytimeout=900

In the configuration above:

EXEPATH specifies the path to the fastcgi resolver,

instancemaxrequests Specifies the maximum number of requests that each instance can handle.

MAXINSTANCES Specifies the maximum number of instances that can be started.

Environmentvars creates an environment variable php_fcgi_max_requests with a default value of 10000,

Requesttimeout specified a request timeout of 600 seconds.

Activitytimeout specified an active session timeout of 900 seconds.

Here is the recommended value:

maxinstances=

Change the value to small

Recommendations

512M Memory Change maxinstances=50

1G Memory Change maxinstances=80

2G Memory Change maxinstances=140

Modify

instancemaxrequests=

Change the value to small

Recommendations

512M Memory Change instancemaxrequests=200

1G Memory Change instancemaxrequests=300

2G Memory Change instancemaxrequests=500

After the change, restart IIS.

Instancemaxrequests php_fcgi_max_requests These two parameters determine the number of PHP requests that are accepted when a php-cgi process is created, and the default configuration in LIGHTTPD is 10000. That is, the php-cgi process terminates after each 10,000 PHP request, releasing all memory and restarting the management process. If you reduce it, for example, change to 100, then the cycle of php-cgi restart will be greatly shortened, the occasional high memory operation caused by the problem impact time will be shortened.

Maxinstances This parameter specifies the maximum number of instances that can be started, that is, the number of php-cgi.exe processes. If you lower it, such as by changing to 100, the total memory consumed by Php-cgi.exe will be greatly reduced in the process of Task Manager, which is the php-cgi.exe process.

I now use the server for Windows 2003 operating system, 4G memory, A php-cgi.exe program occupies 7-25m memory, I put the maxinstances value of 300, reduce the total number of php-cgi.exe process, the memory is reduced, the reaction speed is much faster than before, at least adjust to how much, according to your site visits to determine.

Copyright: 37 Road Forum

This article link address: http://www.37lu.net/thread-25227-1-1.html

Welcome reprint, reprint must indicate the link and source.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.