连接线程池-j9九游会登录
功能介绍
当数据库并发连接过多时,存在大量资源竞争,mysql服务器的性能会发生明显的下降。华为云rds for mysql提供了连接线程池,能够以少量活跃线程来服务大量数据库连接,将连接和执行解耦,在高并发场景下提高数据库性能。
功能特点
华为云rds for mysql连接线程池具有以下特点:
- 避免性能瓶颈,可以处理大量数据库连接,减少资源的争抢和上下文切换。
- 限制并发事务的数量,当数据库负载较高时,优先保障正在执行的事务。
- 避免由于连接得不到及时处理而出现线程异常问题。
- 当事务在等待io和锁时,释放cpu资源以服务其他连接。
线程池相关操作
- 查询线程池参数
通过show variables命令查询线程池参数。
show variables like 'threadpool%'; ----------------------------------- ------------ | variable_name | value | ----------------------------------- ------------ | threadpool_enabled | on | | threadpool_high_prio_tickets | 4294967295 | | threadpool_idle_timeout | 60 | | threadpool_long_conn_time | 2 | | threadpool_max_threads | 100000 | | threadpool_oversubscribe | 3 | | threadpool_prio_kickup_timer | 1000 | | threadpool_rec_launch_time | on | | threadpool_size | 128 | | threadpool_slow_conn_log | on | | threadpool_slow_conn_log_interval | 30 | | threadpool_slow_launch_time | 2 | | threadpool_stall_limit | 500 | ----------------------------------- ------------
表1 线程池参数说明 参数名
参数描述
threadpool_enabled
开启或关闭线程池。
threadpool_high_prio_tickets
高优先级线程持有的tickets数量。
threadpool_idle_timeout
线程销毁前等待的空闲时间(单位:秒)。
threadpool_long_conn_time
登录时间超过此值,则在日志中打印此次登录信息。
threadpool_max_threads
线程池共能创建的线程上限。
threadpool_oversubscribe
每个线程组中最多能创建的额外线程数。
threadpool_prio_kickup_timer
低优先级队列中最长停留时间(单位:毫秒)。
threadpool_rec_launch_time
记录线程启动时间。
threadpool_size
线程组数量。
threadpool_slow_conn_log
是否记录慢登录到error log。
threadpool_slow_conn_log_interval
记录频率,记录一次慢登录后,在此时间间隔内不再记录。
threadpool_slow_launch_time
如登录、查询时间大于此值,则status中 threadpool_slow_launch_request增加1。
threadpool_stall_limit
线程组忙碌检查间隔。
表2 线程池可修改参数说明 参数名
是否是动态参数
数据类型
取值范围
说明
threadpool_enabled
是
boolean
[on,off]
- on:开启线程池。
- off:关闭线程池。
threadpool_oversubscribe
是
integer
[1,50]
每个线程组中最多能创建的额外线程数。
threadpool_size
是
integer
[1,512]
线程组数量。
- 查询线程池状态
通过show status命令查询线程池状态。
show status like 'threadpool%'; ------------------------------------ ------------ | variable_name | value | ------------------------------------ ------------ | threadpool_active_connections | 65 | | threadpool_active_threads | 5 | | threadpool_avg_launch_time | 0 | | threadpool_dump_threads | 0 | | threadpool_idle_threads | 63 | | threadpool_running | on | | threadpool_slow_launch_request | 0 | | threadpool_threads | 237 | | threadpool_threads_high_water_mark | 1075 | | threadpool_waiting_threads | 57 | | threadpool_worst_launch_time | 692548 | ------------------------------------ ------------
表3 线程池状态说明 状态
说明
threadpool_active_connections
线程池中活跃连接数。
threadpool_active_threads
线程池中活跃线程数。
threadpool_avg_launch_time
平均等待时间(单位:毫秒)。
threadpool_dump_threads
dump线程数量。
threadpool_idle_thread
线程池空闲线程数。
threadpool_running
线程池是否在运行。
threadpool_slow_launch_request
超过slow_launch_request的次数。
threadpool_threads
线程池总连接数。
threadpool_threads_high_water_mark
历史高位线程数量。
threadpool_waiting_threads
waiting线程池状态。
threadpool_worst_launch_time
最坏启动时间(单位:毫秒)。
性能测试
|
模型 |
线程 |
线程池开关是否开启 |
qps(每秒查询数) |
latency(时延,单位是毫秒) |
|---|---|---|---|---|
|
oltp_update_non_index |
32 |
是 |
5932.47 |
7.84 |
|
oltp_update_non_index |
64 |
是 |
10074.11 |
9.39 |
|
oltp_update_non_index |
128 |
是 |
18079.61 |
10.65 |
|
oltp_update_non_index |
256 |
是 |
27439.38 |
14.46 |
|
oltp_update_non_index |
512 |
是 |
33007.96 |
28.16 |
|
oltp_update_non_index |
1024 |
是 |
30282.13 |
51.94 |
|
oltp_update_non_index |
2048 |
是 |
29836.86 |
95.81 |
相关文档
意见反馈
文档内容是否对您有帮助?
如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨