如何以分布式方式将Zend_cache与memcached一起使用?
The title of this question might be confusing but the problem is simple.
这个问题的标题可能令人困惑,但问题很简单。
I'm using Zend_Cache with memcached as a backend. I have two module called "Last articles" and "Popular articles". Both of this module are on every pages and use a similar query such as :
我正在使用Zend_Cache和memcached作为后端。我有两个模块叫做“最后文章”和“热门文章”。这个模块都在每个页面上,并使用类似的查询,例如:
Select * from table where status = 'published' and category = '' order by dateCreated|/popularity\
My table have 1.5 million rows so far. I have indexes on every field that I'm using in the previous query. I cache the recent articles for 1hour and the popular for 4hours. I have 4 web server (php5/apache2) and 1 database server (mysql). The table engine is innoDB.
到目前为止,我的表有150万行。我在上一个查询中使用的每个字段都有索引。我将最近的文章缓存1小时,流行4小时。我有4个Web服务器(php5 / apache2)和1个数据库服务器(mysql)。表引擎是innoDB。
The problem some time my cache expire right in the middle of a heavy load, which make my web site unavailable until those modules are cached again. I could had a new MYSQL server.
问题有一段时间我的缓存在繁重的负载中到期,这使得我的网站无法使用,直到这些模块再次被缓存。我可以有一个新的MYSQL服务器。
But is there a way to handle the caching in a smarter way? Like for example the server1 will try to refresh the cache while server 2,3 and 4 will still use the same value out of the cache.
但有没有办法以更智能的方式处理缓存?例如,server1将尝试刷新缓存,而服务器2,3和4仍将使用缓存中的相同值。
I can write some code to do that, but I was wondering if there is way to do that directly with Zend_Cache? Of if there is a design pattern that i could apply to my problem?
我可以写一些代码来做到这一点,但我想知道是否有办法直接用Zend_Cache做到这一点?如果有一个我可以应用于我的问题的设计模式?
[EDIT] I want something that I could scale up to 100 servers
[编辑]我想要一些我可以扩展到100台服务器的东西
4 个解决方案
#1
1
Instead of relying on the cache expiring and then being repopulated during an HTTP request (or, more problematically, during several concurrent requests), why not have the cache never expire?
而不是依赖于缓存过期然后在HTTP请求期间重新填充(或者,在多个并发请求期间更有问题),为什么不让缓存永不过期?
Then schedule some untility script to run your expensive queries (just once!) and update the cache in the background.
然后安排一些直到脚本来运行昂贵的查询(只需一次!)并在后台更新缓存。
更多相关文章
- SQL调优案例,MYSQL服务器CPU100%问题解决
- 阿里云服务器远程连接mysql
- Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器
- phpMyAdmin 尝试连接到 MySQL 服务器,但服务器拒绝连接--解决方法
- 使用where的Laravel集合只在本地工作,而不是在服务器上工作
- 如何使用本地phmyadmin客户端访问远程服务器?
- MySQL SELECT INTO OUTFILE到不同的服务器?
- 无法连接到MySQL服务器
- XMPP环境搭建 (mac环境下 安装自己独立的mysql与服务器(openfire