The difference between mod_fastcgi and mod_fcgid

Source: Internet
Author: User

Mod_fcgid is a binary compatible Apache module with mod_fastcgi.

The original mod_fastcgi is limited by the way it is implemented, so it is possible to create a lot of unnecessary processes that can actually process the same request with fewer processes. mod_fastcgi Another problem is that each CGI multiple processes share the same pipeline file, all the communication to the same fastcgi through the same name of the pipeline file, so when there is a communication error, there is no way to know the communication is the fastcgi, So there is no way to kill the problematic process.

Mod_fcgid try to use shared memory to solve this problem. The shared memory contains information about each of the current fastcgi processes (including the process number, the pipe file name used by the process), and when each attempt to request fastcgi work, Apache will first query the shared memory, It is only in shared memory that there is really not enough fastcgi process to create a new process, which guarantees that the number of processes currently being created will be able to handle the client's request. In addition, because each fastcgi process uses a different name of the pipeline file, it can be in the communication failure to know exactly which fastcgi process has a problem, and can be removed as soon as possible.

Goals of the program implementation

Compatible with mod_fastcgi binary
As long as you replace mod_fastcgi with mod_fcgid in Apache, you can work. The original FASTCGI program does not have to be recompiled and works immediately.


More rigorous control of process creation
Every request handler in Apache can know the current system fastcgi running through shared memory, which prevents excessive creation of fastcgi processes and consumes the resources of the system unnecessarily.


Simple and clear process creation speed control strategy

Each fastcgi maintains a counter, which increases when the program is created and the program ends, and this counter is reduced by 1 per second until 0. When the value of the counter is higher than a threshold, the program stops creating until the value of the counter falls back. This will ensure that the sudden increase in requests can be rapid response (especially when the Apache has just started, the need to create a lot of programs), but also to ensure that when the FASTCGI program has a problem, constantly re-up, the speed of restart is not too high and consumes too much system resources.


Automatic detection of problematic processes

Because each fastcgi uses its own specific pipe file, it is easy to know which program has a problem when it is in a communication error, and to eliminate it as soon as possible.


Portability
In accordance with Apache2 's custom, all portable code is put together, and all non-portable code is stored separately in the Arch directory. Currently tested systems include Linux, FreeBSD (already included in Port FreeBSD4 and FreeBSD5), Solaris, Windows 2000.


PHP that supports fastcgi-mode operation

You can directly support PHP that runs in fastcgi mode. Because PHP does not now guarantee that all extension code is thread-safe, it is not recommended to use mod_php in Apache2 threading mode. PHP, which runs in fastcgi mode, is one of the workarounds. In addition, using mod_fcgi can also get the database connection pool function without modifying any PHP code, greatly reducing the PHP process to the database connection.

The difference between mod_fastcgi and mod_fcgid

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.