-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate the fast and slow commands in the second phase, dynamically adjust the fast and slow command settings according to the access time, and dynamically adjust the number of coroutines and pika threads #2566
Comments
刘欢负责推进 |
Liu Huan is responsible for promoting |
关于快慢命令的几个问题和方案需要确定下: 方案:1、计划添加 2、关于慢命令执行时间设置:添加 3、慢命令如何更优判定 如果一个cmd的请求超出这个时间阈值,就立刻判断为慢命令吗?还是做一些平滑计算?同理如何从慢命令集合摘除?目前想到的一些策略如下:
性能:4、对于第3的实现,可能需要申请N个全局map+atomic(提高并发)做数据统计,这样pika性能应该会有下降,需要权衡下 其他:5、如果一个 cmd 的某个 key 是 bigkey,那么这个 cmd 就被判定为慢命令是否合理?未来是否会考虑到key维度? |
Several questions and solutions regarding fast and slow commands need to be determined: plan:
#Performance:
other:
|
关于动态调整线程数的一些问题和方案: 方案1、线程数动态调整策略:判断线程池中queue的task个数,如果挤压超过某个阈值就添加新的thread,如果长时间空闲就回收thread。添加可以一次多个,回收逐次-1 2、快慢命令使用统一线程池:仿照rocksdb,支持Priority::HIGH、Priority::LOW |
Some issues and solutions about dynamically adjusting the number of threads: plan
|
@AlexStocks @chejinge PTAL |
@AlexStocks @chejinge ASKED |
@李东兴 |
wsy: refer doc: |
wsy: |
etcd3.5的读写性能优化方案有参考价值吗 |
Does etcd3.5’s read and write performance optimization plan have any reference value? |
快慢keyhttps://tech.meituan.com/2020/07/01/kv-squirrel-cellar.html 限流:
热点key(怎么判断出来的?就是上面的限流key吗?)调度:
队列 + 线程池 + 动态调整https://tech.meituan.com/2020/07/01/kv-squirrel-cellar.html 多队列:4 个队列 + 4 个线程池的结构,将请求分成 4 类
线程池数量调整
|
喜马拉雅:快慢命令分离为什么要做快慢命令分离?我们发现线上很多执行本应该很快的命令也会经常超时,原因是早期的 Pika 线程模型是通过 Dispatch 线程分发客户端连接请求给 worker 线程,然后 worker 线程负责同步处理命令请求。这就带来两个问题:
针对上述问题,其实大家很容易想到使用线程池模型,但光线程池模型也不能完全解决问题。举个例子,假如有一个客户端执行的都是比较耗时的命令(如 HGETALL),这时候线程池中的线程还是全都会被耗时的命令阻塞,那么那些执行快的命令也会被阻塞。所以,我们想到的解决方案是采用快慢双线程池模型。 如何做快慢命令分离如下图,创建两个线程池,快慢命令根据不同业务场景可灵活配置,假设一个用户执行的都是 get/set 比较快的命令,另一个用户执行的都是类似 hgetall 很慢的命令,那么两个命令会分发到不同的线程执行,即使 hgetlall 命令导致执行的线程池阻塞,也完全不会影响 get/set 命令的响应时间。这样就降低了快慢命令之间的互相影响。 |
Himalaya: Separation of fast and slow commandsWhy do we need to separate fast and slow commands?We found that many online commands that should be executed quickly often times out. The reason is that the early Pika thread model distributed client connection requests to worker threads through Dispatch threads, and then the worker threads were responsible for synchronously processing command requests. This brings up two problems:
In response to the above problems, it is easy for everyone to think of using the thread pool model, but the thread pool model alone cannot completely solve the problem. For example, if there is a client that executes relatively time-consuming commands (such as HGETALL), then all threads in the thread pool will still be blocked by the time-consuming commands, then those commands that execute quickly will will also be blocked. Therefore, the solution we came up with is to use the fast and slow dual thread pool model. How to separate fast and slow commandsAs shown in the figure below, create two thread pools. The fast and slow commands can be flexibly configured according to different business scenarios. Assume that one user executes relatively fast get/set commands, and the other user executes very slow commands like hgetall. Then both Each command will be distributed to different threads for execution. Even if the hgetlall command causes the execution thread pool to be blocked, it will not affect the response time of the get/set command at all. This reduces the interaction between fast and slow commands. |
动态调整 thread pool 大小思路:
即:记录每个操作的执行时间总和和执行次数。
问题:
|
Dynamically adjust thread pool sizeIdea:
That is: record the total execution time and number of executions of each operation.
question:
|
Which PikiwiDB functionalities are relevant/related to the feature request?
No response
Description
动态调整运行过程中的快慢命令
Proposed solution
动态调整运行过程中的快慢命令
Alternatives considered
动态调整运行过程中的快慢命令
The text was updated successfully, but these errors were encountered: