In the first part I said that the hash table is a bit LIST, SET and SORTED SET. Judge for yourself - LIST is composed of ziplist / linkedlist, SET consists of dict / intset, and SORTED SET is ziplist / skiplist. We have already discussed Dictionary (dict), and in the second part of the article we consider the structure of ziplist - the second most common structure is applicable under the hood of Redis. Look at LIST - the second part of his “kitchen” is a simple implementation of a linked list. It is useful to us to carefully consider the often mentioned advice about the optimization of hash table by replacing them on the list. Calculate how much memory is required for overhead costs by using these structures, what price you pay for saving memory. To sum up when working with hash tables, using the ziplist encoding.

The last time we ended on that saved using ziplist 1,000,000* keys took 16 MB of RAM, while the dict the same data required 104 mb (ziplist 6 times smaller). Let’s understand what the price: crazy

Read more

Do you know why after hset mySet foo bar we spend not less than 296 bytes of RAM in Redis? Why instagramm engineers do not use string keys? Why change the hash-max-ziplist-entries/hash-max-ziplist-val and why the type of data that underlies HASH this part of the LIST, SORTED SET, SET? Understanding the design of hash tables in Redis is critical when writing systems where RAM saving is important.

Content in few lines:

  • Any costs on Redis key storage.
  • What ziplist and dict. When and for what purpose. How much RAM occupied by these structures. When hash is stored in ziplist, when dicth and that it gives us.
  • What advice from fashion articles about Redis optimizing should not be taken seriously, and why.

First, we need to deal with how to operate the individual structures that underlie Hashes. Then calculate the cost of data storage. You will be easier to understand the material, if you know what is redisObject and how Redis stores strings.

Read more

Do you know why the simple string strings in Redis will occupy 56 bytes of RAM?

I wil try to tell you why this so in Redis. And why it is so important to understand how Redis work under the cover. This is especially important if you try to calculate the actual consumption of memory or planing to build high loaded application. Or, as often happens, you try to understand urgently why your Redis instance began to consume unexpectedly a lot of memory.

Content in few lines:

  • How strings are stored in Redis.
  • What internal structures are used strings.
  • What types of optimization are used by Redis under a cowl.
  • How effectively to store big structures and in what situations you shouldn’t use strings or structures constructed on their basis.

Strings is a most used structure in Redis. HSET/ZSET/LIST are constructed on their base adding a small overhead on representation of the internal structures. Over a year I read and actively answer on stackoverflow in Redis tag. On an extent of this time I constantly see not stopping stream of questions which is shown that much of developers don’t understand RAM features of Redis and that price Redis pays for the extremely high speed. This is the first article in the series, explaining how Redis works inside.

Read more

Hey! Welcome, here is a new blog about Redis. The one of the best no sql databases in the world!

I plan to write about the internal structure Redis. On the aspects that have received little attention in everyday development. And which become important in the loaded systems.

I hope that other authors to join me. Together, we will make this resource is important and interesting. The site is located on and everyone can make their contribution with pull request to