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.

然后安排一些直到脚本来运行昂贵的查询(只需一次!)并在后台更新缓存。

更多相关文章

  1. SQL调优案例,MYSQL服务器CPU100%问题解决
  2. 阿里云服务器远程连接mysql
  3. Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器
  4. phpMyAdmin 尝试连接到 MySQL 服务器,但服务器拒绝连接--解决方法
  5. 使用where的Laravel集合只在本地工作,而不是在服务器上工作
  6. 如何使用本地phmyadmin客户端访问远程服务器?
  7. MySQL SELECT INTO OUTFILE到不同的服务器?
  8. 无法连接到MySQL服务器
  9. XMPP环境搭建 (mac环境下 安装自己独立的mysql与服务器(openfire

随机推荐

  1. Android 全屏设置
  2. Android TextView Marquee的应用实例详解
  3. Android keytool 生成证书MD5指纹
  4. Android 学习记录
  5. Android 应用指定浏览器开发实例
  6. android 圆环图形的实现
  7. Android视频方向为什么出现问题以及Andro
  8. Android 自定义标题栏(title栏)
  9. Android 中文API (66) —— BluetoothClass
  10. Android 音频播放