Home Backend Development PHP Tutorial mod_fastcgi和mod_fcgid的区别_PHP

mod_fastcgi和mod_fcgid的区别_PHP

Jun 01, 2016 pm 12:13 PM
apache fastcgi mod

FastCGI

mod_fcgid是一个跟mod_fastcgi二进制兼容的Apache module。

原来的mod_fastcgi因为实现方式的限制,所以可能会创建了很多不必要的进程,而实际上只需要更少的进程就能处理同样的请求。 mod_fastcgi的另外一个问题是每一个CGI的多个进程都共享同一个管道文件,所有到同一个fastcgi的通讯都通过这个同名的管道文件进行, 这样当出现通讯错误的时候,根本不知道正在通讯的是哪一个fastcgi,于是也没有办法将这个有问题的进程杀死。

mod_fcgid尝试使用共享内存来解决这个问题。共享内存里面有当前每个fastcgi进程的信息(包括进程号,进程使用的管道文件名等),当 每次尝试请求fastcgi工作的时候,Apache将会首先在共享内存里面查询,只有在共享内存里面发现确实没有足够的fastcgi进程了,才会创建 新的进程,这样可以保证当前创建的进程数量刚好能够处理客户的请求。另外,由于每一个fastcgi进程使用不同名称的管道文件,所以可以在通讯失败的时 候知道到底哪个fastcgi进程有问题,而能够尽早的将其剔除。

程序实现的目标

跟mod_fastcgi二进制兼容
只要在Apache中用mod_fcgid替换了mod_fastcgi,就能工作。原来的fastcgi程序不用重新编译,立即可以工作。


更严格的控制进程的创建
Apache中每一个request handler都能通过共享内存知道当前系统fastcgi运行的情况,这样可以防止过度的创建fastcgi进程,无谓的消耗系统的资源。


简单清晰的进程创建速度控制策略

每一个fastcgi都会维护一个计数器,这个计数器在程序创建和程序结束的时候都会增加,而这个计数器每秒会减1,直到0。当计数器的值高于某个 阀值的时候,程序就会停止创建,直到计数器的值回落。这样既可以保证在请求突然增多的时候能够快速反应(特别是Apache刚启动,需要大量创建程序的时 候),也能保证当fastcgi程序有问题,不断重起的时候,重起的速度不会过高而消耗过多的系统资源。


自动检测出有问题的进程

因为每个fastcgi使用自己特定的管道文件,所以在通讯错误的时候可以轻易知道哪一个程序出现问题,而尽早的将其剔除。


可移植性
遵照Apache2的习惯,所有可移植的代码都放到一起,所有不可移植的代码都在arch目录下分开存放。当前已经测试过的系统包括 Linux , FreeBSD(已经包含入FreeBSD4和FreeBSD5的port中), Solaris, Windows 2000.


支持FastCGI方式运行的PHP

可以直接支持以FastCGI方式运行的PHP。因为PHP现在还不能保证所有的扩展代码都是线程安全的,所以并不建议在Apache2的线程模式 下使用mod_php。而以FastCGI方式运行的PHP则是其中一个解决办法。另外,使用mod_fcgi还可以在不修改任何PHP代码的情况下,获 得数据库连接池的功能,大大减少PHP进程到数据库的连接。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Cyberpunk 2077 sees up to a 40% performance boost with new optimized path tracing mod Cyberpunk 2077 sees up to a 40% performance boost with new optimized path tracing mod Aug 10, 2024 pm 09:45 PM

One of the standout features ofCyberpunk 2077is path tracing, but it can put a heavy toll on performance. Even systems with reasonably capable graphics cards, such as the RTX 4080 (Gigabyte AERO OC curr. $949.99 on Amazon), struggle to offer a stable

Rabbit R1 gets modded to run games, performs better than expected Rabbit R1 gets modded to run games, performs better than expected Jun 29, 2024 am 07:50 AM

Earlier this month, a YouTuber named HowToMen showcased the Rabbit R1 running Android. With this mod, the device that was originally meant to be less distracting than a phone got to function like one. That isn't a bad thing, though, as Rabbit didn't

PHP Framework Performance Comparison: The Ultimate Showdown of Speed ​​vs. Efficiency PHP Framework Performance Comparison: The Ultimate Showdown of Speed ​​vs. Efficiency Apr 30, 2024 pm 12:27 PM

According to benchmarks, Laravel excels in page loading speed and database queries, while CodeIgniter excels in data processing. When choosing a PHP framework, you should consider application size, traffic patterns, and development team skills.

DIY Asus ROG Ally mod nearly doubles the battery capacity without leaving anything exposed DIY Asus ROG Ally mod nearly doubles the battery capacity without leaving anything exposed Aug 20, 2024 am 06:57 AM

The Asus ROG Ally features a 40 Wh battery, which typically results in about two hours of runtime. On the Ally X, however, Asus upgraded the battery to 80 Wh, pushing the battery life to around four hours, depending on the TDP. iFixit came up with a

How to add a server in eclipse How to add a server in eclipse May 05, 2024 pm 07:27 PM

To add a server to Eclipse, follow these steps: Create a server runtime environment Configure the server Create a server instance Select the server runtime environment Configure the server instance Start the server deployment project

How to conduct concurrency testing and debugging in Java concurrent programming? How to conduct concurrency testing and debugging in Java concurrent programming? May 09, 2024 am 09:33 AM

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

Application of algorithms in the construction of 58 portrait platform Application of algorithms in the construction of 58 portrait platform May 09, 2024 am 09:01 AM

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

The evasive module protects your website from application layer DOS attacks The evasive module protects your website from application layer DOS attacks Apr 30, 2024 pm 05:34 PM

There are a variety of attack methods that can take a website offline, and the more complex methods involve technical knowledge of databases and programming. A simpler method is called a "DenialOfService" (DOS) attack. The name of this attack method comes from its intention: to cause normal service requests from ordinary customers or website visitors to be denied. Generally speaking, there are two forms of DOS attacks: the third and fourth layers of the OSI model, that is, the network layer attack. The seventh layer of the OSI model, that is, the application layer attack. The first type of DOS attack - the network layer, occurs when a large number of of junk traffic flows to the web server. When spam traffic exceeds the network's ability to handle it, the website goes down. The second type of DOS attack is at the application layer and uses combined

See all articles