当前位置:网站首页>Understand CGI and fastcgi
Understand CGI and fastcgi
2022-06-26 04:06:00 【Dreamers on the road】
CGI
CGI(Common Gateway Interface) Public gateway interface ,CGI It's a protocol . To be exact ,CGI It's the app ( Such as PHP) And Web A standard interface for server interaction 、 agreement .
- according to CGI standard , Write applications , It can process the data input by the client , Complete the interaction between the client and the server ;
- CGI Defined Web How the server sends messages to the extended application , How to process the application information after receiving it ;
Let's understand the above content through a picture :

- CGI yes Web The server and Web Applications (php/python etc. ) A protocol for data interaction between ;
- FastCGI And CGI equally , It's also Web The server and Web A protocol for application interaction , It's just FastCGI In terms of efficiency CGI Better ;
CGI Implementation principles and problems
- CGI The program runs in a separate process , And each Web Requests create a process , Destroy at the end . such “ One new process per request ” bring CGI Poor efficiency , Difficult to expand ;
- Under high load , The operating system overhead for process creation and destruction becomes significant ;
- Because the process address space cannot be shared ,CGI The process model limits the reuse of methods , Such as reusing database links ;
FastCGI
Fast universal Gateway Interface (Fast Common GateWay Interface) And CGI equally , It is also a way to make the application and Web Protocol of server communication .FastCGI yes CGI Enhanced version of .
- FastCGI Less Web The server and CGI The cost of interaction between programs , This enables the server to process more web requests at the same time .
Realization
- FastCGI Use persistent processes to process requests , These processes are made up of FastCGI Server management , instead of Web The server .
- FastCGI Like a resident (long-live) Type CGI, It can be carried out all the time , No process creation and termination overhead per request .
FastCGI working principle
- Web Load when the server starts FastCGI Process Manager ( Such as PHP-FPM);
- FastCGI Process manager initialization itself , Start multiple CGI Interpreter process and wait for from Web Server connection ;
- When a client request arrives Web Server time ,FastCGI The process manager selects and connects to a CGI Interpreter .Web The server passes the environment variable and the page request through a socket or TCP connection Pass to FastCGI Subprocesses ;
- FastCGI After the subprocess finishes processing, standard output and error information are returned from the same connection Web Server. When FastCGI When the child process closes the connection , Request processing completed .FastCGI The subprocess then waits and processes from FastCGI Process Manager ( Running on the Web Server in ) Next connection for .
PHP-CGI
php-cgi yes php Self contained FastCGI Manager .
php-cgi Deficiency
- php-cgi It's changing php.ini Restart after configuration php-cgi To make a new php.ini take effect , Failed to restart smoothly ;
- Kill directly php-cgi process ,php Can't run ;
PHP-FPM
php-fpm yes PHP FastCGI Manager .FastCGI Just a protocol specification , Each language needs to implement ,PHP-FPM Namely PHP Version of FastCGI Protocol implementation .
- Support smooth restart , After receiving the restart signal , First kill Idle worker process , new worker With the new configuration ;
- The pressure can be increased or decreased dynamically according to the request worker Number of processes ;
边栏推荐
- I/o virtualization technology - vfio
- 商城风格也可以很多变,DIY 了解一下
- 在出海获客这件事上,数字广告投放之外,广告主还能怎么玩儿?
- Threejs专用天空盒素材,五种天空盒素材免费下载
- [LOJ 6718] nine suns' weakened version (cyclic convolution, arbitrary modulus NTT)
- The style of the mall can also change a lot. DIY can learn about it
- R语言与机器学习
- Binary search method
- Open source! Vitae model brushes the world's first again: the new coco human posture estimation model achieves the highest accuracy of 81.1ap
- I/O 虚拟化技术 — VFIO
猜你喜欢

Unity移动端游戏性能优化简谱之 以引擎模块为划分的CPU耗时调优

Machine learning notes - trend components of time series

线程同步之互斥量(互斥锁)

Detr3d multi 2D picture 3D detection framework

線程同步之讀寫鎖

Threejs special sky box materials, five kinds of sky box materials are downloaded for free

钉钉开放平台-小程序开发实战(钉钉小程序服务器端)

【Flink】Flink 批处理模式Map端数据聚合 NormalizedKeySorter

【QT】资源文件导入

Use soapUI to access the corresponding ESB project
随机推荐
Detr3d multi 2D picture 3D detection framework
College C language final exam · multiple choice questions · summary notes of mistakes and difficulties
763. 划分字母区间
Ieda suddenly cannot find compact middle packages
【Flink】Flink源码分析——批处理模式JobGraph的创建
Use soapUI to access the corresponding ESB project
Nailing open platform - applet development practice (nailing applet client)
第 4 篇:绘制四边形
Daily tests
Quanergy欢迎Lori Sundberg出任首席人力资源官
Judge the same value of two sets 𞓜 different values
How does virtual box virtual machine software accelerate the network speed in the virtual system?
WPF value conversion
Concept and implementation of QPS
Optimization - multi objective planning
1.基础关
matplotlib多条折线图,点散图
线程同步之读写锁
Custom parameter QR code picture combined with background picture to generate new picture node environment
I/o virtualization technology - UIO framework