存档

文章标签 ‘cache’

php-fpm下使用eaccelerator产生的内存问题

2010年12月20日 没有评论

使用EA或者类似的OP CODE加速器已经是搭建PHP环境的默认选项了
但是在使用nginx的环境内
会需要使用fastcgi方式来运行php
这种情况下.EA的内存占用可能会和你在APACHE下使用EA不同
由于APACHE调用PHP的方式是模块方式的
所有PHP是位于同一个进程下面的
所以所有PHP模块调用的EA是同一个的.
内存只会占用shm_size大小.
APACHE进程间共享这同一个EA
也就是如果你在ea的配置下面写了64M.则只会占用整个系统的64M
而如果用fastcgi模式
特别是php-fpm
阅读全文…

鞋衫各式名品专卖

收藏与分享
分类: HTTP, php 标签: , , , ,

Benchmarking PHP accelerators

2009年12月22日 没有评论

How does an accelerator works ?

Executing a PHP scripts takes a few steps :

  1. PHP loads the file,
  2. it parses the source file, and transforms it into opcodes (code that can be executed by the server),
  3. it executes the opcodes.

The accelerator takes the opcodes from step 2 and caches them in shared memory or on disk. Those cached opcodes are then directly reused the next time the PHP file is executed, without loading & parsing the file again.

Some accelerators add an optimization step which removes unnecessary code (empty loops, unused variables, …). In most cases, this optimisation step does not improve performance much.

Available accelerators

There are 3 accelerators (at last 3 that are stable, maintained and fast) :

阅读全文…

收藏与分享
分类: Apache, php 标签: , , ,

基于HTTP协议WEB系统优化

2009年12月2日 没有评论

 

         HTTP1.0 和 HTTP1.1 协议最主要的区别是HTTP1.1协议增加了会话保留时间(Keep-Alive),也就是会话完系统并不会立即关闭连接,他会保留一段时间,也就是apache nginx 或者 squid ….. 设置的Keep-Alive时间,这样如果在这个时间内客户端再次向服务器发出请求时,服务器和客户端就不需要再次进行TCP3次握手和重新连接.这样就加快了打开速度,但是如果话保留时间(Keep-Alive)设置太长就会使得服务器内存大量消耗系统压力也加大,太短也就没发挥HTTP1.1 协议的优点,这个是个取舍的问题,需要根据自己的需求设置,如果服务器访问量小设置大点没关系,如果访问量大就设置小点.

阅读全文…

简单生活。简单运动

收藏与分享
分类: cache, cdn, HTTP, Linux web 标签: , ,

用lighttpd加速SQUID

2009年12月2日 没有评论

看到这个标题,大家也许会觉得奇怪:SQUID本身就是加速软件,lighttpd还怎么加速SQUID?

方法:用lighttpd+mod_proxy 跑80 端口,指定后端proxy server是127.0.0.1:81,squid改到81端口

lighttpd.conf 相关内容:

server.port = 80
proxy.server = ( “/” =>
(
( “host” => “127.0.0.1″, “port” => 81 )
)
)
server.protocol-http11=”disable”

原理更简单:lighttpd使用的writev和sendfile系统调用比squid用的write系统调用效率高很多。参考C10KScalable networking PDF中关于writev,sendfile的说明。

实际效果呢:五台最高跑50M的squid server,换lighttpd+squid模式后,高峰长期跑满100M。

收藏与分享
分类: cache, cdn, lighttpd, squid 标签: , , ,

使用Nginx/Lighttpd作为反向代理服务器

2009年10月25日 没有评论

反向代理服务已经越来越广泛的应用于高负载的Web站点中,常用来作为Reverse Proxy的有Squid、Apache、Lighttpd、Nginx等,后两个轻量级的应用因为其优秀的表现已迅速占领了大量市场,本文只讨论后两者的简单应用(用proxy处理静态文件而把动态文件交给后端的Web服务器来处理)

安装环境
操作系统: Debian 4.0 r3
Kernel: 2.6.18-6-686
阅读全文…

收藏与分享

lighttpd的日志rotate

2009年10月25日 没有评论

之前找到的通过logrotate计划任务来截断lighttpd的日志目前看起来并不好用,为了更好的解决lighttpd的日志rotate,找到了cronolog。从其网站转载一段说明:

cronolog is a simple filter program that reads log file entries from standard input and writes each entry to the output file specified by a filename template and the current date and time. When the expanded filename changes, the current file is closed and a new one opened. cronolog is intended to be used in conjunction with a Web server, such as Apache, to split the access log into daily or monthly logs.
阅读全文…

收藏与分享

lighttpd+modcache实现对小图片的Cache

2009年10月25日 没有评论

安装环境
操作系统: CentOS release 5.2 (Final)
Kernel: 2.6.18-92.el5PAE

软件列表
fam-latest.tar.gz
gamin-0.1.10.tar.gz
pcre-7.9.tar.gz
lighttpd-1.4.23.modcache.v.1.8.0.tar.gz
阅读全文…

收藏与分享

服务器网页缓存的深入分析

2007年11月23日 没有评论

Expires、Cache-Control、Last-Modified、ETag是RFC 2616(HTTP/1.1)协议中和网页缓存相关的几个字段。前两个用来控制缓存的失效日期,后两个用来验证网页的有效性。要注意的是, HTTP/1.0有一个功能比较弱的缓存控制机制:Pragma,使用HTTP/1.0的缓存将忽略Expires和Cache-Control头。我们 这里以Apache2.0服务器为例,只讨论HTTP/1.1协议。

Expires

Expires字段声明了一个网页或URL地址不再被浏览器缓存的时间,一旦超过了这个时间,浏览器都应该联系原始服务器。RFC告诉我们:“由于推断的失效时间也许会降低语义透明度,应该被谨慎使用,同时我们鼓励原始服务器尽可能提供确切的失效时间。”
阅读全文…

收藏与分享
分类: Apache 标签: , , , ,