选择合适的缓存机制
我的设置:
- 4 个网络服务器
- 静态内容服务器(NFS 安装)
- 2 个数据库服务器
- 2 个“魔术”服务器
- 另外 8 台指定为多用途的机器。
我正在为三种缓存机制编写一个包装器,以便可以以某种标准化的方式使用它们:文件系统、Memcached 和 APC。我正在尝试提供使用示例(以及在每个缓存中实际放入的内容)。
文件系统
处理我们生成并静态提供的内容。 RSS 提要、旧报告数据、用户特定页面等...这些都缓存到静态服务器。
Memcached
PHP 会话数据、MySQL 查询结果,通常需要在我们的系统中可用。我们有 8 台机器可以包含在服务器池中。
APC
我不知道。这两个“神奇”服务器不属于任何分布式系统,因此它们似乎可以在 APC 中缓存查询结果并从那里工作。过去了,我什么也想不起来了。
查询缓存
鉴于 SQL 使用的性质,查询缓存会降低性能。我已经禁用了这个。
一般来说,什么类型的数据应该存储在哪里?这个设置还有意义吗?
APC数据缓存在分布式系统中是否有任何用处(我想不出)?
我是否缺少一些可以让事情变得更容易或更高效的东西?
编辑:我终于明白了帕斯卡在说什么。我一直在想,我只会将我的配置/任何内容的一部分移动到 APC,并且仍然从磁盘加载文件的其余部分。还有其他建议吗?
My setup:
- 4 webservers
- Static content server (NFS mount)
- 2 db servers
- 2 "do magic" servers
- An additional 8 machines designated multi-purpose.
I'm writing a wrapper for three caching mechanisms so that they can be used in a somewhat normalized manner: Filesystem, Memcached and APC. I'm trying to come up with examples for use (and what to actually put in each cache).
File System
Handles content that we generate and then statically serve. RSS feeds, old report data, user specific pages, etc... This is all cached to the static server.
Memcached
PHP session data, MySQL query results, generally things that need to be available across our systems. We have 8 machines that can be included in the server pool.
APC
I have no idea. The two "do magic" servers are not part of any distributed system, so it seems likely that they could cache query results in APC and work from there. Past that, I can't think of anything.
Query Caching
Given the nature of our SQL use, query caching reduces performance. I've disabled this.
In general, what types of data should be stored where? Does this setup even make sense?
Is there any use for an APC data cache in a distributed system (I can't think of one)?
Is there something that I'm missing that would make things easier or more efficient?
Edit: I've figured out what Pascal was saying, finally. I had it stuck in my head that I would only be moving a portion of my config / whatever to APC, and still loading the rest of the file from disk. Any other suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在某些项目中使用相同类型的缓存机制;我们使用 APC + memcached 作为缓存系统。
在缓存数据方面,APC 和 memcached 之间有两/三个主要区别:
我们通常使用:
例如,我们可以:
一些旁注:
I'm using the same kind of caching mecanism for some projects ; and we are using APC + memcached as caching systems.
There are two/three main differences between APC and memcached, when it comes to caching data :
We generally use :
For instance, we could :
A couple of sidenotes :