- 浏览: 2018173 次
- 来自: 武汉
文章分类
- 全部博客 (415)
- UI设计 (19)
- PHP (26)
- PHP工具类 (23)
- 二次开发 (53)
- phpMVC (28)
- javascript (50)
- JS 组件 (20)
- MYSQL (37)
- 其他 (16)
- xml/flash/flex (6)
- 版本控制 (7)
- 开源 (4)
- bug解决 (5)
- Linux (15)
- NoSQL (14)
- 软件设计 (21)
- C/PHP内核 (5)
- 安全性 (8)
- 面试 (18)
- 设计模式 (4)
- 重构 (6)
- 开发配置 (11)
- SQL SERVER (12)
- 采集 (3)
- SEO (2)
- 维护 (15)
- UML (5)
- 硬件标准 (1)
- 架构 (8)
- JAVA (1)
最新评论
-
carry0987:
求大神分離下X3的模板...不然對於PHP7不友好啊...
分离自Discuz模板类和语法 -
青木得海角:
你好,里面的 Crypt/TripleDES.php 和 Cr ...
POS机算法 -
zohog:
楼主,Mac.php中里面的 Crypt/TripleDES. ...
POS机算法 -
zohog:
楼主,Mac.php中里面的 Crypt/TripleDES. ...
POS机算法 -
q59200182:
能不能给个完整的demo 新手上路不会 求带
AngularJs 指令directive之controller,link,compile
1普遍缓存技术
数据缓存:这里所说的数据缓存是指数据库查询缓存,每次访问页面的时候,都会先检测相应的缓存数据是否存在,如果不存在,就连接数据库,得到数据,并把查询结果序列化后保存到文件中,以后同样的查询结果就直接从缓存表或文件中获得。
用的最广的例子看Discuz的搜索功能,把结果ID缓存到一个表中,下次搜索相同关键字时先搜索缓存表。
举个常用的方法,多表关联的时候,把附表中的内容生成数组保存到主表的一个字段中,需要的时候数组分解一下,这样的好处是只读一个表,坏处就是两个数据同步会多不少步骤,数据库永远是瓶颈,用硬盘换速度,是这个的关键点。
2页面缓存 :
每次访问页面的时候,都会先检测相应的缓存页面文件是否存在,如果不存在,就连接数据库,得到数据,显示页面并同时生成缓存页面文件,这样下次访问的时候页面文件就发挥作用了。(模板引擎和网上常见的一些缓存类通常有此功能)
时间触发缓存 :
检查文件是否存在并且时间戳小于设置的过期时间,如果文件修改的时间戳比当前时间戳减去过期时间戳大,那么就用缓存,否则更新缓存。
内容触发缓存 :
当插入数据或更新数据时,强制更新缓存。
3静态缓存:
这里所说的静态缓存是指静态化,直接生成HTML或XML等文本文件,有更新的时候重生成一次,适合于不太变化的页面,这就不说了。
以上内容是代码级的解决方案,我直接CP别的框架,也懒得改,内容都差不多,很容易就做到,而且会几种方式一起用,但下面的内容是服务器端的缓存方案,非代码级的,要有多方的合作才能做到
4内存缓存:
Memcached 是高性能的,分布式的内存对象缓存系统,用于在动态应用中减少数据库负载,提升访问速度。
php的缓冲器 :
有eaccelerator, apc, phpa,xcache,这个这个就不说了吧,搜索一堆一堆的,自己看啦,知道有这玩意就OK
MYSQL缓存 :
这也算非代码级的,经典的数据库就是用的这种方式,看下面的运行时间,0.09xxx之类的
我贴段根据蓝色那家伙修改后部分my.ini吧,2G的MYISAM表可以在0.05S左右,据说他前后改了有快一年
代码拷贝框
[client] …… default-character-set=gbk default-storage-engine=MYISAM max_connections=600 max_connect_errors=500 back_log=200 interactive_timeout=7200 query_cache_size=64M …… table_cache=512 …… myisam_max_sort_file_size=100G myisam_max_extra_sort_file_size=100G myisam_sort_buffer_size=128M key_buffer_size=1024M read_buffer_size=512M …… thread_concurrency=8
基于反向代理的Web缓存:
如Nginx,SQUID,mod_proxy(apache2以上又分为mod_proxy和mod_cache)
NGINX的例子
<nginx.conf> #user nobody; worker_processes 4; error_log logs/error.log crit; pid logs/nginx.pid; worker_rlimit_nofile 10240; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; tcp_nodelay on; # server pool upstream bspfrontsvr { server 10.10.10.224:80 weight=1; server 10.10.10.221:80 weight=1; } upstream bspimgsvr { server 10.10.10.201:80 weight=1; } upstream bspstylesvr { server 10.10.10.202:80 weight=1; } upstream bsphelpsvr { server 10.10.10.204:80 weight=1; } upstream bspwsisvr { server 10.10.10.203:80 weight=1; } upstream bspadminsvr { server 10.10.10.222:80 weight=1; } upstream bspbuyersvr { server 10.10.10.223:80 weight=1; } upstream bspsellersvr { server 10.10.10.225:80 weight=1; } upstream bsploginsvr { server 10.10.10.220:443 weight=1; } upstream bspregistersvr { server 10.10.10.220:80 weight=1; } log_format test_com '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" "$http_user_agent" '; #-------------------------------------------------------------------- #img.test.com server { listen 10.10.10.230:80; server_name img.test.com; location / { proxy_pass http://bspimgsvr; include proxy_setting.conf; } access_log logs/img.log test_com; } #style.test.com server { listen 10.10.10.230:80; server_name style.test.com; location / { proxy_pass http://bspstylesvr; include proxy_setting.conf; } access_log logs/style.log test_com; } #help.test.com server { listen 10.10.10.230:80; server_name help.test.com; location / { proxy_pass http://bsphelpsvr; include proxy_setting.conf; } access_log logs/help.log test_com; } #admin.test.com server { listen 10.10.10.230:80; server_name admin.test.com; location / { proxy_pass http://bspadminsvr; include proxy_setting.conf; } access_log logs/admin.log test_com; } #buyer.test.com server { listen 10.10.10.230:80; server_name buyer.test.com; location / { proxy_pass http://bspbuyersvr; include proxy_setting.conf; } access_log logs/buyer.log test_com; } #seller.test.com server { listen 10.10.10.230:80; server_name seller.test.com; location / { proxy_pass http://bspsellersvr; include proxy_setting.conf; } access_log logs/seller.log test_com; } #wsi.test.com server { listen 10.10.10.230:80; server_name wsi.test.com; location / { proxy_pass http://bspwsisvr; include proxy_setting.conf; } access_log logs/wsi.log test_com; } #www.test.com server { listen 10.10.10.230:80; server_name www.test.com *.test.com; location ~ ^/NginxStatus/ { stub_status on; access_log off; } location / { proxy_pass http://bspfrontsvr; include proxy_setting.conf; } access_log logs/www.log test_com; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } #login.test.com server { listen 10.10.10.230:443; server_name login.test.com; ssl on; ssl_certificate cert.pem; ssl_certificate_key cert.key; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; ssl_prefer_server_ciphers on; location / { proxy_pass https://bsploginsvr; include proxy_setting.conf; } access_log logs/login.log test_com; } #login.test.com for register server { listen 10.10.10.230:80; server_name login.test.com; location / { proxy_pass http://bspregistersvr; include proxy_setting.conf; } access_log logs/register.log test_com; } } <conf/proxy_setting.conf> proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k;
mod_proxy的例子:
<VirtualHost *> ServerName www.zxsv.com ServerAdmin admin@zxsv.com # reverse proxy setting ProxyPass / http://www.zxsv.com:8080/ ProxyPassReverse / http://www.zxsv.com:8080/ # cache dir root CacheRoot "/var/www/proxy" # max cache storage CacheSize 50000000 # hour: every 4 hour CacheGcInterval 4 # max page expire time: hour CacheMaxExpire 240 # Expire time = (now - last_modified) * CacheLastModifiedFactor CacheLastModifiedFactor 0.1 # defalt expire tag: hour CacheDefaultExpire 1 # force complete after precent of content retrived: 60-90% CacheForceCompletion 80 CustomLog /usr/local/apache/logs/dev_access_log combined </VirtualHost>
而SQUID的例子 ,这方面网上有写的太多,大家自己搜索一下
DNS轮询 :
BIND是一款开放源码的DNS服务器软件,这个要说起来就大了,自己搜索去,大家知道有这个东西就行了。
我知道的有chinacache等大站就是这样做的,说简单点就是多服务器啦,把同一个页面或文件缓存到不同的服务器上,按南北自动解析到相关的服务器中。
发表评论
-
mongodb 分片代替数据库分表
2013-04-23 16:48 4325MongoDB 的Sharding机制解决了海量存储和动态 ... -
MongoDB 远程连接 权限
2011-10-18 11:59 3182这时装好以后应该会自动运行mongod程序,通过" ... -
smarty的插件功能是smarty模板的精华
2011-07-21 16:58 1480一,smarty插件介绍 smarty的插件放在/smar ... -
几个smarty小技巧
2011-07-21 16:49 15131,capture标签 capture的中文意思是抓取, ... -
PHP比较全面的缓存类
2011-06-20 14:52 2614<?php /* * Name: wra ... -
缓存管理与监控工具
2011-01-20 11:03 20701.MemAdmin 是一款可视化 ... -
缓存命中率
2011-01-19 15:50 2103命令行查看Memcached运行状态 很多时候需要监控服务器 ... -
PHP memcache memcached
2011-01-19 00:36 53071.目前大多数php环境里使用的都是不带d的memcach ... -
2PHP页面缓存
2011-01-17 16:42 1490<?php /* * 缓存类 cache * 作 ... -
3.PHP静态类
2011-01-17 16:10 1505<?php /******************8P ... -
网站静态化
2010-11-17 17:39 1608随着SEO 的普及,静态 ... -
PHP生成静态HTML的技术原理
2010-11-02 14:04 1854PHP页面的静态化很有必要,尤其是在CMS系统中,一些内容一旦 ... -
2PHP页面片段缓存
2010-11-02 13:49 1619适用情况: 1.数据相 ...
相关推荐
详解php缓存技术 缓存在php中的用法详解
php缓存技术总结,全静态,部分缓存,数据缓存,查询缓存,内存式缓存,APC缓存,Opcode缓存
很值得一看的php资料 PHP缓存技术详解 PHP缓存技术详解 PHP缓存技术详解PHP缓存技术详解
详解php缓存技术,和大家分享一哈!来自互联网,
PHP缓存技术[总结].pdf
从原理到场景系统讲解PHP缓存技术系列课程.txt
详细介绍php 缓存的使用方法,以及原因等.对php开发中优化很有帮助.
有些信息比方经常不变的,但是还是能变的信息放在缓存中以加快显示速度,这是很有价值的,所谓的缓存,通俗的理解就是一些保存在服务器端的共用信 息.它是于服务器同生死的,我们在保存缓存的时候可以指定下次更新的时间...
PHP缓存,多用于大型网站,缓解网站访问压力。
PHP的缓存与静态化应用,和当今cms主流系统的缓存技术,商城缓存技术,页面静态化生成技术
普遍使用的PHP缓存技术 PHP缓存技术之数据缓存: 这里所说的数据缓存是指数据库查询缓存,每次访问页面的时候,都会先检测相应的缓存数据是否存在,如果不存在,就连接数据库,得到数据,并把查询结
在实际的应用中,用户使用浏览器浏览Web应用,都是在向Web...而大部分用户的请求都很类似,因需要将PHP脚本执行的结果进行缓存或将其放到静态的HTML文件中。这样,用户在访问时就直接访问静态HTML网页,不执行PHP脚本。
NULL 博文链接:https://m-oyzm.iteye.com/blog/855583
├─ PHP ...│ ├─ 05-PHP 缓存技术 │ ├─ 06-三个水桶等分8升水的问题 -《算法的乐趣》 │ ├─ 07-使用过Redis,我竟然还不知道Rdb │ ├─ 08-我眼中的 RPC │ ├─ 09-Composer 包开发居然这么简单
主要介绍了PHP常用的缓存技术汇总,下面所说的都是在项目中最常用的PHP缓存技术,新手同学收藏起来好好研究吧
Memcache缓存技术,Memcache配置说明及其文件,PHP5.2.6版本内存缓存技术配置,PHP运行环境PHP5.2.6版本的配置,操作系统是windows下
Memcache缓存技术 安装 使用 教程 步骤的讲解
缓存是指临时文件交换区,电脑把最常用的文件... 在WEB开发中用来应付高流量最有效的办法就是用缓存技术,能有效的提高服务器负载性能,用空间换取时间。 互联网也是2 8定论,就像百度搜索中的关键字一样,80%的人所搜