golang + redis concurrency scheduler performance issue

前端 未结 2 546
既然无缘
既然无缘 2021-01-28 00:40

I write a simple concurrency scheduler, but it seems to have a performance issue at a high level concurrency.

Here is the code (scheduler + concurrent rate limiter test)

2条回答
  •  灰色年华
    2021-01-28 01:22

    My test result shows, when the routine number increases, the execution time per routine per take function increases nearly exponentially.

    It should be a problem of redis, here is reply from redis library community:

    The problem is what you suspected the pool connection lock, which if your requests are small / quick will pushing the serialisation of your requests.

    You should note that redis is single threaded so you should be able to obtain peak performance with just a single connection. This isn't quite true due to the round trip delays from client to server but in this type of use case a limited number of processors is likely the best approach.

    I have some ideas on how we could improve pool.Get() / conn.Close() but in your case tuning the number of routines would be the best approach.

提交回复
热议问题