简体   繁体   English

在单服务器应用程序中使用memcache的最佳方法是什么?

[英]What's the best way to use memcache with a single-server app?

For a single-server LAMP site (which is usually under quite high load), what is best way to use memcache? 对于单服务器LAMP站点(通常负载很高),使用memcache的最佳方法是什么?

Does it make sense to run the memcache daemon on the same server as the application, or is that just going to take valuable memory away from MySQL, giving a net performance loss. 在与应用程序相同的服务器上运行memcache守护程序是否有意义,或者只是从MySQL中获取宝贵的内存,从而导致净性能损失。 Does it even make sense to use memcache in this scenario- or is the best solution to always have dedicated servers for memcache? 在这种情况下使用memcache是​​否有意义 - 或者是始终为memcache提供专用服务器的最佳解决方案?

I appreciate that profiling the site before and after would be required to really answer this question, but I would rather not do that at this stage on the live site. 我很欣赏前后分析网站需要真正回答这个问题,但我宁愿不在现场网站上这样做。 Especially as someone out there certainly knows the answer off the top of their head. 特别是当那里的人肯定知道他们头顶的答案。

Usually, the recommendation (see What about shared memory? in the memcached page ) is to run memcached on the same machines as web servers, on the premise that web applications are CPU-heavy (which memcached is not), whereas memcached is memory-heavy (which most web applications are not, at least in comparison). 通常,建议(参见memcached页面中的共享内存怎么样 )是在与Web服务器相同的机器上运行memcached,前提是Web应用程序占用大量CPU(memcached不是),而memcached是内存 -沉重(大多数网络应用程序不是,至少相比之下)。

So, if your web server has plenty of memory, it's a good idea to run memcached on it. 因此,如果您的Web服务器有足够的内存,那么在它上面运行memcached是个好主意。 YMMV. 因人而异。

Another option to memcached - depending on the scale on information you are caching, is caching in APC. memcached的另一个选项 - 取决于您缓存的信息的规模,是APC中的缓存。 You should be running that (or a similar op-code cache) to help speed the PHP page delivery anyhow, so if you are caching somewhere from a few, to a hundred or more smaller (I've got a few at around 15KB each, out of more than 70) variables at a time, you may find some benefit to storing them in APC. 你应该运行它(或类似的操作码缓存)以帮助加速PHP页面交付,所以如果你从一些缓存到一百或更多(我有一些约15KB每个在一次超过70个变量中,您可能会发现将它们存储在APC中会有一些好处。

I've got a site that caches some DB lookups, and also caches a post-parsing config.ini file - and on my (busy) site, I'll save literally millions of potential DB hits per day. 我有一个缓存一些数据库查找的站点,并且还缓存了一个解析后的config.ini文件 - 在我的(繁忙)站点上,我每天将节省数百万个潜在的数据库命中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows 7中运行Linux虚拟服务器的最佳方法是什么? - What's the best way to run a Linux virtual server in Windows 7? 在 linux 服务器上保存完整网页的最佳方法是什么? - What's the best way to save a complete webpage on a linux server? 启动Jenkins Server的最佳方法是什么 - What is the best way to launch Jenkins Server 关于(POSIX)信号的最佳参考文献是什么? - What's the single best reference on the topic of (POSIX) signals? 在嵌入式设备上从摄像机流传输视频的最佳方法是什么? - What's the best way to stream video from a camera on an embedded device? 为 Linux 分发二进制应用程序的最佳方式是什么? - What’s the best way to distribute a binary application for Linux? 转储和丢弃特定应用程序的网络数据包的最佳方法是什么? - What's the best way to dump and drop network packets of a specific application? 在远程服务器之间区分文件的最佳方法是什么? - What's the best way to diff files among remote servers? 在 linux 和 windows 中使用 #define 宏 Function 的最佳方法是什么? - What's the best way #define macro Function used in linux and windows? 在 Linux 上安装 R 包的最佳方法是什么? - What's the best way to install R packages on Linux?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM