What is a Redis Multiple Dot Point?

So, I came to the place where I wanted to segment the data stored in redis into separate databases, because sometimes I need to use the keys command on one specific data type and want to separate it from it, do it faster.

If I segment several databases, everything is still single-threaded, and so far I can only use one core. If I just start another Redis instance in the same window, I get an extra kernel. Also, I cannot name Redis databases or give them a more logical identifier. So, with all that said, why / when will I ever want to use multiple Redis databases instead of just deploying an additional Redis instance for each additional database I want? And accordingly, why is Redis not trying to use an extra core for every additional database that I add? What is the advantage of single-threaded data transfer through databases?

+121
redis
Apr 25 '13 at 17:59
source share
7 answers

In principle, Redis databases in one instance do not differ from schemas in instances of an RDBMS database.

So, with all that said, why / when will I ever want to use multiple Redis instead of just deploying an additional instance of Redis for each additional database I want?

There is one clear advantage to using redis databases in the same redis instance and this management. If you create a separate instance for each application and assume that you have 3 applications, these are three separate redis instances, each of which will probably require a slave for HA production, so there are 6 common instances. From a management point of view, this becomes messy because you need to control all of them, make updates / corrections, etc. If you do not plan to overload redis with high I / O, one slave instance is simpler and easier to manage if it matches your SLA.

+63
Apr 25 '13 at 20:03
source share

You do not want to use multiple databases in a single instance of redis. It is outdated and, as you noted, several instances allow you to take advantage of several cores. If you use database selection, you will have to reorganize it when upgrading. Monitoring and managing multiple instances is not complicated and painful.

In fact, you will get much better performance for each db by instance-based segregation. Each instance would have statistics that reflect this data segment, which can provide better tuning and more flexible and accurate monitoring. Use the latest version and separate your data by instance.

As Jonathon said, do not use the keys command. If you simply create a key index, you will get much better performance. When adding a key, add the key name to the set. The key command is not very useful as soon as you zoom in, since it takes a considerable amount of time to return.

Let the access template determine how to structure your data, and not store it the way you think it works, and then work on how to access it and continue it later. You will see much better performance and often find that code consuming data is much cleaner and simpler.

For single threads, consider redis designed for speed and atomicity. Confident actions that modify data in one db should not wait for another db, but what if this action is stored in a dump file or processes transactions on slaves? At this point, you begin to fall into the weeds of concurrency programming.

Using multiple instances, you turn multi-threaded complexity into a simpler messaging style system.

+82
Apr 26 '13 at 19:26
source share

Even Salvatore Sanfilippo (the creator of Radish) thinks it is a bad idea to use multiple databases in Radish. See His comment here:

https://groups.google.com/d/topic/redis-db/vS5wX8X4Cjg/discussion

I understand how this can be useful, but, unfortunately, I consider Redis multiple database errors my worst solution in Redis design for everything ... without any real win, this makes the internals a lot more complicated. The reality is that the databases are not scaled enough for a number of reasons, such as the active validity of the keys and virtual machine. If the database selection can be performed with a string, I see that this function is used as a scalable dictionary of level O (1), but it is not.

With DB numbers, by default for several databases, we are better at communication, what kind of function it is and how it can be used, I think. I hope at some point we can refuse to support several databases, but I think it is probably too late, because there are a number of people who rely on this for their work.

+46
Apr 08 '16 at 11:35
source share
  • I do not know any benefits of having multiple databases in one instance. I think this is useful if multiple services use the same database server, so you can avoid key collisions.

  • I would not recommend building around using the KEYS command, since it is O (n) and does not scale very well. What do you use for this that you can perform differently? Perhaps redis is not suitable for you if functionality like KEYS is vital.

  • I think they mention the advantages of a single multithreaded server in their FAQ, but the main thing is simplicity - you do not need to worry about concurrency in any real way. Each action is blocked, so two things cannot change the database at the same time. Ideally, you will have one (or more) instances per core of each server and use a sequential hash algorithm (or proxy) to split the keys between them. Of course, you will lose some functionality - the pipeline will only work on things on one server, sorting will become more difficult, etc.

+6
Apr 25 '13 at 18:49
source share

Redis databases can be used in rare cases when a new version of an application is deployed, where the new version requires working with different objects.

+2
Jun 15 '15 at 12:04
source share

I use redis to implement a blacklist of email addresses, and I have different TTL values ​​for different levels of the blacklist, so using different databases in one instance helps me a lot.

+1
Mar 24 '15 at 12:29
source share

Using multiple databases in one instance may be useful in the following scenario:

Different copies of the same database can be used for production, development or testing using real-time data. People can use the replica to clone a Redis instance to achieve the same goal. However, the first approach makes it easier for existing running programs to simply select the correct database to switch to the intended mode.

0
Apr 10 '19 at 12:56
source share



All Articles