Redis and memcached, both are today's very fire memory databases, to discuss the popularity of the current Redis with the most, in terms of performance, if you have Redis aof and RDB functions are all disabled, just to use Redis as a cache, Redis and mencached performance is not much difference, I believe that using Redis is not likely to just use its caching function it?
The main purpose of this article is to talk about the vertical splitting and horizontal splitting of Redis and memcached, where I use Redis as an example to make it easier to write.
One: Vertical split
the vertical split of Redis is actually similar to the vertical split of MySQL, our vertical split on MySQL is the sub-Library, then what is the sub-Library? Of course, according to the business Sub-Library, order database, commodity library, user base, etc., analogy to Redis is actually the same
Originally we may not have a small business, or a small amount of data, a Redis server is enough, so we put the goods, stores, inventory, promotion rules and so on data are put in, now the user volume up, a machine is not enough to save, Then we can be divided according to the business, the goods, stores, inventory on a single Redis server to store.
Two horizontal split
Horizontal splitting is when we use vertical splitting, the amount of data in some libraries is growing too fast, we also say that as a data shard, we split the product data into three pieces, Routing rules for shards we usually solve with hash redundancy and Hashi algorithm (Redis uses hash slots). Of course not to use horizontal splitting, Redis and memcached do not support this practice, we can only introduce middleware, Of course now redis3.0 can be a server cluster, but it is not stable function, and if you want to expand the need to manually redistribute the hash slot, it is inconvenient, and the Jedis client also has a bug, even the cluster will be stuck.
The architecture of Redis and memcached in the app: horizontal split and vertical split