- 浏览: 547500 次
- 性别:
- 来自: 珠海
文章分类
最新评论
-
Helkern:
真没法看
告别 Mac OS X 终端默认的丑陋字体 -
enlangs:
liuming 写道很好很强大。楼主有没有研究过LGPL协议和 ...
GPL 与 BSD 授权的区别 -
magicalboy:
lich0079 写道filer'owner 不一定是什么vi ...
如何理解 File's Owner 与 First Responder -
shushanke:
可以指变量,可以指构造方法。
Java 中 this 关键字的使用 -
Zhongwei_leg:
一块可怜的牛皮糖 写道把数据分成256个表,然后对key的前两 ...
sqlite 的数据插入速度问题
CGI (Common Gateway Interface) 的设计初衷:
用来作为 Web Server 同 Python, PHP 等的通信手段。而在静态网页的时代, 只需要 Web Server 即可。
CGI 的定义:
CGI is the protocal that describs the way information is exchanged between the web server (如 Nginx) and the gateway application (PHP, Python, and so on.)
CGI 的缺点:
1. 每个请求都会产生一个对应的 gateway application 进程。从一个请求到另一个请求, 内存和上下文信息会丢失。无法 cache 来提高效率。
2. 大负载能力不足。对系统而言,启动一个进程非常耗资源。大量的并发请求(每个请求启动一个进程)会瞬间搞跨服务器。
3. 将 web server, gateway application 部署到不同服务器上的愿望难以实现。
FastCGI (Fast Common Gateway Interface):
也就是说 FastCGI 同 CGI 一样都是一个协议, 而不是一个具体实现。
flup 才是具体实现?
Microsoft IIS 也有一个 FastCGI 的实现。
http://www.iis.net/download/fastcgi
FastCGI 相对于 CGI 的改进:
1. 反复重用一个进程来处理多个请求, 而不是每个请求产生一个进程。
例如, 在 IIS FastCGI 中有这样两个特性:
a. Configurable maximum number of FastCGI processers per application pool.
b. Configurable maximum number of requests that FastCGI process can handle before being recycled by FastCGI.
2. Web Server 与 Gateway Application 通过 TCP 或者 POSIX local IPC sockets 通信。所以这些进程能够位于不同的主机上。
3. The web server forwards the client request to the gateway and receives the response within a single connection.
4. Since FastCGI is a socket-based protocol, it can be implemented on any platform with any programming language.
The FastCGI module is included in the default Nginx build, you do not need to enable it manually at compile time.
2010-11-16
fastcgi_read_timeout
设置 Nginx 从 FastCGI application 或者回复的超时时间。如果超时, 返回 504 Gateway Timeout HTTP error.
fastcgi_connect_timeout
与 read timeout 的区别是:
read timeout 是已经连上 fastcgi server 才开始计时。 connect timeout 是未连接状态的计时。
fastcgi_store
以文件的形式缓存 FastCGI app 的返回结果。 on/off. 默认是 off.
fastcgi_temp_path
指定 fastcgi_store 的缓存文件的存放目录, 存放在内存盘 /tmp 是一个好的选择, 快。。。
FastCGI caching
fastcgi_cache
定义一个 cache zone, 以便复用。
fastcgi_cache_key
不同 cache 得以区分的标识, 通常以请求地址标志。
fastcgi_cache 与 fastcgi-store 的区别是什么呢?
官网:
To be clear fastcgi_store is not a cache, it's rather mirror on demand.
官网对于 fastcgi_cache 的定义:
The directive specifies the area which actually is the share memory's name for caching. The same can be used in several places.
一个显著的区别是:
fastcgi_cache 是在使用内存, 而 fastcgi store 是在使用文件。 而这个cache 是所有进程都共用么?
<Nginx HTTP Server> 对于 directive 的解释明显不如官网详细。
Upstream Blocks
常见的问题是: FastCGI app 非常耗费系统资源, 尤其在 CPU 的使用方面。这时就需要增加 Backend Server 以做负载均衡。
upstream module 就是用来做此配置的:
例如:
upstream phpfpm{
server 192.168.0.50:9000;
server 192.168.0.51:9000;
server 192.168.0.52:9000;
}
之后在配置 FastCGI 时, 连接 upstream block.
server{
server_name website.com;
location ~* \.php${
fastcgi_pass phpfpm;
[....]
}
}
upstream module is round robin. 循环法
当一个用户发送两次请求, 就会被分发到不同的 backend 上, 就会造成资源无法复用。
可以改成:
upstream phpfpm{
ip_hash;
server 192.168.0.50:9000;
....;
}
如果想对不同的 Backend 设置不同的权重:
upstream php{
server 192.168.0.1:9000 weight=2;
server 192.168.0.2:9000;
}
在 ip_hash mode 下权重参数无效。
flup library, which provides the actual FastCGI protocol implementation.
对于 CentOS, EPEL 必须添加上。
RHEL:
yum install python-flup
这样默认安装的是 2.4.。。
还是使用 python2.6 的 easy_install flup 才搞定。
(下的 flup 2.6 egg 居然不能执行。)
Debian:
apt-get install python-flup
python manage.py runfcgi method=prefork host=127.0.0.1 port=9000 pidfile=/var/run/django.pid
runfcgi 的几个参数介绍:
protocol:
可选值为 fcgi, scgi, ajp, .... 默认为 fcgi, 即 FastCGI
host:
hostname to listen on.
port:
prot to listen on.
method:
prefork or threaded (default prefork)
网上说:
prefork 内存占用量大, threaded 内存需要量小。
prefork 在超大负载是仍然可以很好的工作, threaded 在大负载时常常无法响应。
在一个 Apache 的博客中找到一个可能的解释:
prefork 相当于使用 进程处理每个请求, 而 threaded 是每个子进程再产生一定量的 线程来处理请求。
pidfile:
write the spawned process-id to this file.
一个成功的配置:
location / { root html; index index.html index.htm; fastcgi_pass 127.0.0.1:9000; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; # include fastcgi_params; }
修改完之后需要 reload nginx:
/usr/local/nginx/sbin/nginx -s reload
发表评论
-
Ubuntu server 上更正系统时间
2011-07-19 01:28 2253VPS 的系统时间不知道是哪个时区的,需要修正一下。 ... -
Ubuntu 上安装 Firefox 4 的方法
2011-03-23 21:28 1326Now, for most users, getting ... -
Ubuntu 下自动打开多个 Guake Tab 页的脚本
2011-03-20 14:05 2655先让看一下我们要达到的效果: 每次开机都要手 ... -
推荐 Ubuntu 的中文 wiki
2011-03-16 17:51 1117Ubuntu 中文 wiki 的地址是: http://wi ... -
Ubuntu 上开启 ssh 服务
2011-01-15 15:18 1540如果要在另外一台机器上,例如 windows 上远程访问我的 ... -
Ubuntu 下访问 Windows 网络共享文件夹的方法
2011-01-04 17:03 1612例如,我现在想在 Ubuntu 上访问 Windows 系统上 ... -
Ubuntu 下使用金山词霸
2010-12-08 16:53 1063安装 http://www.ubuntuchina.com/ ... -
压力测试下系统负载数据的分析工具 —— sar
2010-12-06 11:12 3339在对 Web Server 做性能测试的时候, 除了需要给出 ... -
解压 tar, tar.bz2 和 tar.gz 文件
2010-11-22 10:26 1352Type at the command prompt ... -
CentOS 上安装 Python MySQLdb 模块
2010-11-17 14:28 2894这里可以找到 Python MySQLdb 模块的下载地址: ... -
CentOS 5 上安装 Python setuptools 2.6
2010-11-17 11:50 8436文章转载自 大象笔记 http://www.sunz ... -
Linux 的用户管理
2010-11-17 10:05 955添加新用户: adduser zhongwei 为 z ... -
HP 笔记本上安装 CentOS 过程中黑屏问题解决
2010-11-16 14:14 3657先选择图形安装过程, 在检测完安装光盘之后, 一直黑屏。 ... -
郑老师讲解 Linux / MongoDB 的性能瓶颈总结
2010-11-15 22:25 2107NoSQL 1. 高并发性 radis, tokyo, m ... -
Nginx 的 HTTP 配置
2010-11-10 23:12 965HTTP module 包含 3 个 logical bloc ... -
Nginx 的基本配置
2010-11-10 20:11 1135配置文件在哪里呢? ... -
Nginx 资料收集
2010-11-10 14:13 1031PDF 教程: 《Nginx HTTP Server》 h ... -
Ubuntu 上使用 Nginx
2010-11-10 12:22 1755环境: Ubuntu 10.10 安装 Nginx: ... -
Ubuntu 下设置 PATH 环境变量
2010-11-10 10:59 1283在 Ubuntu 系统中有两种设置环境变量 PATH 的方法。 ... -
Ubuntu 10.10 官方光盘居然到了
2010-11-09 10:17 902可惜身在北京, 光盘在珠海, 纪念, 之后补上图片。
相关推荐
本文实例讲述了Python实现获取nginx服务器ip及流量统计信息功能。分享给大家供大家参考,具体如下: #!/usr/bin/python #coding=utf8 log_file = /usr/local/nginx/logs/access.log with open(log_file) as f: ...
用于构造nginx配置文件的python库。 安装 pip install nginx-config-builder 用法 该库提供了两个用于构建配置的接口,一个高级构建器API以及该构建器使用的低级基于块的API。 消费者可以选择对他们的用例有意义的...
Set up Nginx to work with PHP, Python, and more via FastCGI Configure Nginx to work as frontend for your existing HTTP server Manipulate configuration files with ease and adapt them to various ...
用Flask, Tornado, Nginx等进行网络开发 Flask is minimal and simple. You don’t get ORM’s, Admin Panels and other stuff that Django has out of the box. You can install a very cool admin panel with just...
FeaturesAll features of nginx(latest release) are inherited, i.e., it is 100% compatible with nginx.Web development using python, c++, lua, php7, java , javascript and jsr-223 JVM ...
Mastering+Natural+Language+Processing+with+Python Mastering+Natural+Language+Processing+with+Python
ledman A LED command and control thing....sudo aptitude install uwsgi uwsgi-plugin-python3 python3-bottle nginx sudo rm /etc/nginx/sites-enabled/default cp /home/pi/ledman/nginx.conf.sample /home/pi/l
sqlparse> = 0.2.0(python) 苹果电脑 如果您使用的是Mac,请从下载src。 使用以下参数进行构建: ./configure --help | grep without | grep lua | sed ' s/disable.*// ' | xargs ./configure --with-...
本科毕业设计+python基于flask构建微电影网站,已部署测试(附线上部署过程),增加异步功能,发送弹幕,速率控制等 已经部署到 Linux+mysql+nginx+uwsgi 环境中,下面会有教程 特性 基于蓝图创建红图,更好细分模块与...
具有nginx,websocketd,nodejs和bash或python脚本启动器的docker 使您的bash或python脚本启用网络 建造和测试 docker-compose up --build 将您的浏览器连接到locahost 更改正在启动的脚本 请编辑以下脚本。 它是...
c ++,lua,php7,java,javascript和jsr-223 JVM语言进行的Web开发依赖Linux gcc和g ++(c ++ 11)或clang和clang ++ python-devel,如果--enable-http-hi-python =如果--enable-http-hi-python = YES和with-...
policycoreutils-python openssl cryptography (pip) 假设RedHat OS系列 启用了SSH密钥身份验证和Sudoer的用户 组变量 --- lb: user: nginx web_port: 80 ssl_port: 443 tls_dir: /etc/nginx/ssl tls_...
演示:通过Docker的Jekyll + nginx代理 这已经在Mac OS X上进行了尝试和测试。 它也应该在Linux上工作。 但是,Windows不受保障,因为Jekyll并未正式支持Windows。 先决条件 Ruby 2.0以上 Python 2.7以上 带有npm v...
face_with_tongue:请参考 请参考 更多Django的范例可以参考我的 ,这里我就列出比较基本的两篇就好 :smiling_face_selector: Nginx是一种Web服务器,使用资源少且稳定性高,稳定性高这部分可参考Nginx的解决了C10K...
一、通过urllib库爬取网站的源码 方法一:直接爬取(没有限制的情况下) import urllib.request ...print(response.read().decode..."F:\Python 3.8.0\python.exe" ****** nginx Process finished with exit code 0 方法
command Send custom command with args or not. Usag... create_package Create virtualenv create_www Configure permissions on www dbshell Django DB Shell deploy Update git repository...
├── api # All our microservices│ ├── account # Account microservice with NodeJS│ ├── comments # Comments microservice with Go│ └── courses # Courses microservice with Python├── ...
Creating network " cve-2019-11043-git_app_net " with driver " bridge " Creating php ... done Creating nginx ... done 如果您想阅读php-fpm日志,可以运行: docker logs --tail 10 --follow php 开发 # ...
Nginx with RTMP 展示系统基于Idea集成开发环境进行开发,SSM框架中的依赖均基于Maven进行配置,在Idea中导入web目录下的工程,导出war包,将war包放在服务器tomcat/webapps目录下,运行./startup.sh,启动tomcat容器...
this project use python api process the data, with the separation of web page file; run it should run respectively python and web page; ** install ** install python depend, run it install Vuejs depen