Redis在单个实例中对于N个数据库是否是单线程的?

huangapple go评论45阅读模式
英文:

is redis single threaded for n databases in single instance

问题

Redis在执行命令时是单线程的。每个Redis实例都有DB0到DB16,可用于不同的应用程序。

我的问题是,Redis的单线程性质是针对单个DB还是所有DB都是单线程的?

例如,Redis同时收到了针对DB1的查询命令1和针对DB2的查询命令2,Redis会同时处理这两个查询命令吗?还是即使它们是针对不同的DB,仍然需要逐个处理?

谢谢。

我期望在单个Redis实例中的不同DB将使用不同的线程执行命令。

我在DB0中尝试了'CLIENT PAUSE 30000 ALL',在暂停期间,发送到DB1的命令直到暂停结束才返回结果。

英文:

I heared that redis is single threaded when executing the command.
And redis instance has DB0~DB16, which can be used for different applications.

My question is that, is the redis single threaded just for single DB, or for all DBs?

e.g.
redis received query command1 for **DB1 ** and query command2 for **DB2 ** at same time,
will redis handle the query command1 and query command2 at same time? or need to handle one by one even they are for different DBs?

Thanks.

I execpected that different DBs in single redis instance will use different threads to executing command.

I tried 'CLIENT PAUSE 30000 ALL' in DB0, and during pause period, the command sent to DB1 didn't return result until pause period ended.

答案1

得分: 0

这些是纯粹的逻辑数据库,因此redis-server的单个实例是为它们所有的线程单线程的。如果可能的话,请尽量避免使用逻辑数据库和SELECT命令,这在现今通常被视为反模式。

英文:

These are purely logical databases, so a single instance of redis-server is single threaded for all of them. Try and avoid using logical databases and the SELECT command if possible, it's generally considered an antipattern these days.

huangapple
  • 本文由 发表于 2023年6月8日 17:02:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76430238.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定