场景:云数据库 MySQL 8.0,内核 20201230 及以上,直连实例,未开数据库代理。工作模式留在 pool-of-threads。高稳定模板 thread_pool_oversubscribe 为 10,thread_pool_stall_limit 500 毫秒,thread_handling_switch_mode 为 fast,thread_pool_high_prio_mode 为 transactions。短查询为主,夹杂报表 SQL。
现象:
show threadpool status 里 queue_size 降不下去,average_wait_usecs_in_queue 变大,短查询在应用侧超时。high_prio_queue_size 和 queue_size 同时大于 0。已尝试:
thread_pool_oversubscribe 从 10 上调后超时减少,但更接近 one-thread-per-connection,上限 32。thread_pool_stall_limit 降到 500 毫秒以下,空闲要等默认 60 秒才回收,线程数来回抖。切换模式还没动。问题:
oversubscribe 和 stall_limit 该保短查询,还是把并发压在线程组里?queue_size 和 average_wait_usecs_in_queue 到什么程度该停手?one-thread-per-connection,stable、fast、sharp 怎么选?sharp 会 kill 活跃连接,事务和连接池会怎样?fast 不迁老连接,慢 SQL 还要堵多久?相似问题