当前位置:网站首页>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 ;
边栏推荐
- (15)Blender源码分析之闪屏窗口显示菜单功能
- Tencent Interviewer: How did binder get its system services?
- What should I do if the 51 SCM board cannot find the device in keil
- Introduction Guide to the flutterplugin plug-in in the actual combat of flutter
- Analysis of the principle of obxwidget
- Syntax error of go language generic in IDE
- [collection of good books] from technology to products
- 【QT】对话框dialog
- matplotlib多条折线图,点散图
- What's wrong with connecting MySQL database with eclipse and then the words in the figure appear
猜你喜欢
What if the serial port fails to open when the SCM uses stc-isp to download software?
Matplotlib multi line chart, dot scatter chart
High performance computing center roce overview
Chrome page recording and playback function
Wechat applet is bound to a dynamic array to implement a custom radio box (after clicking the button, disable the button and enable other buttons)
Force buckle 515 Find the maximum value in each tree row
軟件調試測試的十大重要基本准則
Judge the same value of two sets 𞓜 different values
Nailing open platform - applet development practice (nailing applet server side)
钉钉开放平台-小程序开发实战(钉钉小程序客户端)
随机推荐
线程同步之条件变量
What preparations should be made to develop an app from scratch
Analysis of camera memory memory leakage (II)
【MySQL】 MySQL 导出数据库
Intelligent manufacturing learning videos and books
mysql自带的性能测试工具mysqlslap执行压力测试
Getting started with flask
1. foundation closing
Lua grammar explanation
软件调试测试的十大重要基本准则
How does virtual box virtual machine software accelerate the network speed in the virtual system?
【QT】对话框dialog
How much do you make by writing a technical book? To tell you the truth, 2million is easy!
816. fuzzy coordinates
MySQL common statements
go语言泛型在IDE中语法报错
Camera-CreateCaptureSession
The style of the mall can also change a lot. DIY can learn about it
[learn FPGA programming from scratch -45]: vision chapter - integrated circuits help high-quality development in the digital era -2- market forecast
What should I do if the 51 SCM board cannot find the device in keil