redis5.0 是 4 个,废话少说,上源码
initServer();
/* Ready to spawn our threads. We use the single argument the thread
 * function accepts in order to pass the job ID the thread is
 * responsible of. */
for (j = 0; j < BIO_NUM_OPS; j++) {
    void *arg = (void*)(unsigned long) j;
    if (pthread_create(&thread,&attr,bioProcessBackgroundJobs,arg) != 0) {
        serverLog(LL_WARNING,"Fatal: Can't initialize Background Jobs.");
        exit(1);
    }
    bio_threads[j] = thread;
}
/* Background job opcodes */
#define BIO_CLOSE_FILE    0 /* Deferred close(2) syscall. */
#define BIO_AOF_FSYNC     1 /* Deferred AOF fsync. */
#define BIO_LAZY_FREE     2 /* Deferred objects freeing. */
#define BIO_NUM_OPS       3 // 线程总数,redis主线程+3个后台线程

????

 

之所以redis是单线程其实是处理客户端请求的是单线程,但还有后台线程去处理aof,rdb等耗时的任务。

 

变成3个了

redis 到底有几个线程

redis 到底有几个线程

把后台线程改成2看看

redis 到底有几个线程

看一下

相关文章:

  • 2021-12-30
  • 2021-11-29
  • 2021-11-11
猜你喜欢
  • 2021-10-17
  • 2021-07-08
  • 2021-04-23
  • 2022-01-27
  • 2021-08-16
  • 2021-07-08
相关资源
相似解决方案