Why using multiple database in same instance a bad idea in Redis?

It is not. If you are building a multi-tenant application, supporting multiple websites, it does make sense. And if one of the websites needs to scale more rapidly, you can setup a different instance (or cluster) for that one alone and migration is much simpler.


how can I manage caching of both my websites on same server without the above said approach?

You can use different key tag for each website. Say, name the two websites as A and B. For all keys of website A, give each key a prefix(key tag): A:. On the other hand, give each key for website B another prefix: B:. In this way, you can have a unique key namespace for each website.

SET A:key1 val1
SET A:key2 val2
LPUSH B:key1 1
SADD B:key2 val

Also check this answer for more solutions.

Can anyone explain the reason in simpler terms as why using multiple redis db of same server instance is discouraged.

AFAIK, multiple databases feature is NOT discouraged and deprecated. It's a method to isolated key namespaces for different applications. However, the author of Redis consider Redis multiple database errors my worst decision in Redis design at all, since it makes Redis internals more complex.

Redis is single-threaded, so compared to multiple databases, multiple Redis instances can take advantage of multiple cores. If you have multiple databases in one Redis instance, you can still only use one core. Also Redis instance itself has little memory footprint, so you don't need to worry about multiple Redis instance costs you too much.

Redis is very fast, and normally the bottleneck is network bandwidth, NOT CPU. So normally you CANNOT get too much gain by using multiple Redis instances. However, if one of your application needs to do some slow commands on Redis, and don't want it to block other applications, you can have a separate Redis instance for the slow application, and have another Redis instance for other fast applications.

Also note that Redis Cluster doesn't support multiple databases.

Personally, I like this multiple database feature. Normally, if I run a Redis instance, not Redis Cluster, I'll put my data into some database other than the default database, i.e. database 0, to avoid incidentally login Redis and do some horrible things on the default database. Also it's very easy to implement a double buffer with multiple databases, e.g. write data to a new database, when it's done, use the SWAPDB command to swap the old DB and new DB automatically and efficiently.