What is Memcached?

Memcached

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Memcached是一个免费、开源、高效率的分布式内存对象缓存系统,旨在缓解动态WEB应用访问DB。

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Memcached使用KEY-VALUE键值对存储任意的小数据块,一般这些数据来自数据库访问,API调用,或者页面。

Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its APIis available for most popular languages.

Memcached小巧而强大,简单的设计促使其可以快速部署和简易开发,也解决了很多大数据缓存问题。它可以用于大多数流行语言。


Memcached In Slightly More Words

貌似有更多层意思

See the memcached.org about page for a brief overview.

I Turned It On and My App Isn't Faster!!!

我打开它,可是程序没跑快啊!!!

Memcached is a developer tool, not a "code accelerator", nor is it database middleware. If you're trying to set up an application you have downloaded or purchased to use memcached, your best bet is to head back their way and read your app's documentation on how to utilize memcached. Odds are these documents will not help you much.

Memcached是一个开发工具,不是代码加速器,也不是数据库中间件。如果你正在用Memcached去启动一个你刚下的或刚买的应用程序,那么你最好回过头去,仔细阅读那个程序的说明文档,看看它是怎么教你使用Memcached的。记住过期的文档不会太有用。

What is it Made Up Of? // 它由哪些组成?

  • Client software, which is given a list of available memcached servers. 
  • 客户端软件,有一个缓存服务器的列表。
  • A client-based hashing algorithm, which chooses a server based on the "key" input.
  • 一个基于哈希算法的客户端,如果你告诉它一个key值,它就会选择一个服务器还给你。
  • Server software, which stores your values with their keys into an internal hash table.
  • 服务器端软件,它使用一个内部的哈希表使用键值对存储数据。
  • Server algorithms, which determine when to throw out old data (if out of memory), or reuse memory.
  • 服务端缓存算法,决定着缓存与否,以及删掉过期数据。

What are the Design Philosophies?

设计原理是什么?

Simple Key/Value Store // 简单的键值对

The server does not care what your data looks like. Items are made up of a key, an expiration time, optional flags, and raw data. It does not understand data structures; you must upload data that is pre-serialized. Some commands (incr/decr) may operate on the underlying data, but the implementation is simplistic.

服务器是不会关心你的数据长啥样。它只需要四个东西:key值,失效时间,可选的标志,和未处理过的数据。它是理解不了你的数据结构的。你要序列化数据后再上传。许多指令会操作底层数据,不过你放心,做到这些不会太难。

Smarts Half in Client, Half in Server // 一半在客户端,一半在服务器

A "memcached implementation" is implemented partially in a client, and partially in a server. Clients understand how to send items to particular servers, what to do when it cannot contact a server, and how to fetch keys from the servers.

“缓存实现”部分在客户端,部分在服务器。客户端知道怎样发送数据给服务器,不能连接服务器时做什么,以及怎样从服务器获取key值。

The servers understand how to receive items, and how to expire them.

服务器很聪明,它知道怎样接受数据,还有怎样失效数据。


Servers are Disconnected From Each Other // 服务器之间彼此不关联

Memcached servers are generally unaware of each other. There is no crosstalk, no syncronization, no broadcasting. The lack of interconnections means adding more servers will usually add more capacity as you expect. There might be exceptions to this rule, but they are exceptions and carefully regarded.

Memcached服务器彼此之间通常不知道对方。不会串话,没有同步,不会知会对方。没有内部通信意味着服务器数量与容量成正比。也许存在异常,所以要小心对待。

O(1) Everything

For everything it can, memcached commands are O(1). Each command takes roughly the same amount of time to process every time, and should not get noticably slower anywhere. This goes back to the "Simple K/V Store" principle, as you don't want to be processing data in the cache service your tens or hundreds or thousands of webservers may need to access at the same time.

每条命令每次大概都花费同样多的时间,不会因为地点不同就慢了。这就回到了“简单的键值对”设计原则上,就像你不希望一边处理缓存数据的时候,另外成百上千的web服务器也需要一起来处理它们。

Forgetting Data is a Feature // 缓存是会遗忘数据的(失效)。

Memcached is, by default, a Least Recently Used cache. It is designed to have items expire after a specified amount of time. Both of these are elegant solutions to many problems; Expire items after a minute to limit stale data being returned, or flush unused data in an effort to retain frequently requested information.

This further allows great simplification in how memcached works. No "pauses" waiting for a garbage collector ensures low latency, and free space is lazily reclaimed.

Memcached是一个LRU(注:关于这点,建议看下常用的缓存算法缓存。设计时就指定了一段时间过后,就会失效一些数据(Items)。这是一种高效而又简单的解决方式。间隔一段时间失效一部分过时数据,或者尽可能冲掉那些没有使用过的数据,这么做都是为了保留住那些频繁使用的数据。

更深层此来讲,这使得memcached更简单。它不会因为垃圾回收而中断。


Cache Invalidation is a Hard Problem // 缓存无效是难点问题

Given memcached's centralized-as-a-cluster nature, the job of invalidating a cache entry is trivial. Instead of broadcasting data to all available hosts, clients direct in on the exact location of data to be invalidated. You may further complicate matters to your needs, and there are caveats, but you sit on a strong baseline.

如果将memcached作为群簇性的东西,失效一个数据是无关紧要的。不需要只会所有的有效服务器。客户端可以直接在数据的精确位置上失效它。虽然你可能需要复杂化业务,也会有些注意事项,不过你的起点很高。

How Is Memcached Evolving? // memcached将走向何方?

Memcached has been evolving as a platform. Some of this is due to the slow development nature, and the many clients. Mostly it happens as people explore the possibilities of K/V stores. Learning to cache SQL queries and rendered templates used to keep developers occupied, but they thirst for more.

Memcached将向平台方向发展。很多原因是因为发展缓慢,还有就是客户端太多。通常是因为人们开始探索键值对存储时才开始的。学习缓存SQL查询,又或者提出模板供开发者复用。不过这些还太少了点,他们渴求更多。

The Protocol // 协议

Memcached is not the only implementation of the protocol. There are commercial entities, other OSS projects, and so on. Memcached clients are fairly common, and there are many uses for a memcached-like cluster layout. We will continue to see other projects "speak" memcached, which in turn influences memcached as a culture and as software itself.

Memcached不仅仅实现协议而已。承载着商业实现,比如OSS的工程等。Memcached的客户相当普遍,他们很多都使用类似memcached的集群。我们将会看到许多工程自述memcached,然而它们反过来也影响着memcached。

Other Protocols // 其他协议

The industry is experimenting with many different ways to communicate with networked services. Google protocol buffers, Facebook Thrift, Avro, etc. There might be better ways to do this, as the future will show.

这个行业正在体验其它的方式与网路服务通信。谷歌的buffers,Facebook的Thrift,Avro等。也许将来他们会是更好的选择。

Persistent Storage // 持久存储

Many users want K/V stores that are able to persist values beyond a restart, or beyond available physical memory. In many cases memcached is not a great fit here; expensive flash memory is needed to keep data access performant. In most common scenarios, disaster can ensue if a server is unavailable and later comes up with old data. Users see stale data, features break, etc.

许多人希望K/V存储能够长久保存数据,超越于重启,超越于物理内存。实际上,memcached在这并不适合。这倒这些需要昂贵的Flash内存。通常更多的实际场景是服务器失效后,出现灾难性的后果,很多过期数据,还有效果崩溃。

However, with the price of SSD's dropping, this is likely an area to be expanded into.

然而,随着SSD的降价,这或许是一个发展方向。

Storage Engines //存储引擎

Storage Engines in general are an important future to memcached as a service. Aside from our venerable slabbing algorithm, there are other memory backends to experiment with. tcmalloc, jemalloc, CPU-local slabs, hierarchies, etc. Storage engines foster experimentation to improve speed and memory efficiency, as well as specialized services able to speak the memcached protocol.

存储引擎将会是一个重要的缓存服务。除了我们的算法外,还有其他的内存后端可以尝试。tcmalloc, jemalloc, CPU-local slabs, hierarchies等。存储引擎希望提高速度和内存效率。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值