什么是memcached
memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load.
memcached是一个高性能、分布式内存对象缓存系统,本质上是通用的,但最初旨在通过减轻数据库负载来加快动态web应用程序的速度。
You can think of it as a short-term memory for your applications.
可以将memcached看作为应用程序的短期内存。
memcached做了些什么
memcached allows you to take memory from parts of your system where you have more than you need and make it accessible to areas where you have less than you need.
memcached允许您从系统中内存不足的部分获取内存,并使其能够访问到内存不足的区域。
memcached also allows you to make better use of your memory. If you consider the diagram to the right, you can see two deployment scenarios:
memcached还允许您更好地利用内存。如果您考虑右侧的图表,可以看到下面两种部署场景:
- Each node is completely independent (top).每个节点都是完全独立的(顶部)。
- Each node can make use of memory from other nodes (bottom).每个节点可以利用来自其他节点的内存(底部)。
The first scenario illustrates the classic deployment strategy, however you'll find that it's both wasteful in the sense that the total cache size is a fraction of the actual capacity of your web farm, but also in the amount of effort required to keep the cache consistent across all of those nodes.
第一个场景说明了经典的部署策略,但您会发现,这既浪费了缓存的总大小,也浪费了在所有节点上保持缓存一致所需的工作量。
With memcached, you can see that all of the servers are looking into the same virtual pool of memory. This means that a given item is always stored and always retrieved from the same location in your entire web cluster.
使用memcached,您可以看到所有服务器都在查看同一个虚拟内存池。这意味着给定的项目总是存储在整个web集群的同一位置,并且总是从同一位置检索。
Also, as the demand for your application grows to the point where you need to have more servers, it generally also grows in terms of the data that must be regularly accessed. A deployment strategy where these two aspects of your system scale together just makes sense.
此外,随着对应用程序的需求增长到需要更多服务器的程度,通常情况下,必须定期访问的数据也会增长。将系统的这两个方面放在一起进行扩展的部署策略是有意义的。
The illustration to the right only shows two web servers for simplicity, but the property remains the same as the number increases. If you had fifty web servers, you'd still have a usable cache size of 64MB in the first example, but in the second, you'd have 3.2GB of usable cache.
为了简单起见,右边的插图只显示了两个web服务器,但随着数量的增加,属性保持不变。如果您有50个web服务器,那么在第一个示例中,您的可用缓存大小仍然为64MB,但在第二个示例中您的可用高速缓存大小为3.2GB。
Of course, you aren't required to use your web server's memory for cache. Many memcached users have dedicated machines that are built to only be memcached servers.
当然,您不需要使用web服务器的内存进行缓存。许多memcached用户都有专门的机器,这些机器被构建为仅作为memcached服务器。
参考资料
memcached官网介绍


还不快抢沙发