本文主要是介绍shardingsphere调优日记,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 一、总括
- 二、连接数调优
- 二、CPU线程的利用率
- 三、服务器内存的利用率
一、总括
调优的几个方面
- 连接数调优,包含shardingsphere和mysql的连接数。
- shardingsphere的globle.yaml中线程调优。(充分利用CPU)
- shardingsphere中的内存调优。(充分利用内存)
二、连接数调优
注意调整maxPoolSize,minPoolSize两个参数。表示连接当前数据的的数量。这个数量跟mysql的max_connects要配合,不能大于。所以调节这个参数的时候同时要去调节mysql服务器的参数。
dataSources:write_ds_0:url: jdbc:mysql://10.0.0.13:3306/newbus_0?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&databaseNameuseUnicode=trueusername: rootpassword: Jwcs_18916939125connectionTimeoutMilliseconds: 30000idleTimeoutMilliseconds: 60000maxLifetimeMilliseconds: 1800000maxPoolSize: 100minPoolSize: 20write_ds_1:url: jdbc:mysql://10.0.0.13:3306/newbus_1?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&databaseNameuseUnicode=trueusername: rootpassword: Jwcs_18916939125connectionTimeoutMilliseconds: 30000idleTimeoutMilliseconds: 60000maxLifetimeMilliseconds: 1800000maxPoolSize: 100minPoolSize: 20
二、CPU线程的利用率
- proxy-backend-query-fetch-size 参数值默认值为 -1,修改为 大数字可以尽量减少多行结果集的 fetch 次数。主要影响insert…values()的性能。
- proxy-frontend-executor-size 参数默认值为 CPU * 2
props:system-log-level: INFOmax-connections-size-per-query: 1kernel-executor-size: 16 # Infinite by default.proxy-frontend-flush-threshold: 128 # The default value is 128.# sql-show is the same as props in logger ShardingSphere-SQL, and its priority is lower than logging rulesql-show: falsecheck-table-metadata-enabled: false# Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.# The default value is -1, which means set the minimum value for different JDBC drivers.proxy-backend-query-fetch-size: 1024 #影响批量插入的效率,越大越好proxy-frontend-executor-size: 32 # Proxy frontend executor size. The default value is 0, which means let Netty decide.本机16核proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.proxy-default-port: 3307 # Proxy default port.proxy-netty-backlog: 1024 # Proxy netty backlog.cdc-server-port: 33071 # CDC server portproxy-frontend-ssl-enabled: falseproxy-frontend-ssl-cipher: ''proxy-frontend-ssl-version: TLSv1.2,TLSv1.3
三、服务器内存的利用率
找到start.sh修改里面内存配置
DEFAULT_JAVA_MEM_COMMON_OPTS=" -Xmx2g -Xms2g -Xmn1g "
调整如下:
-Xmx16g -Xms16g -Xmn8g # 调整 JVM 相关参数
说明
Xmx :最大堆内存
Xms :最小堆内存,设置成总内存的一半。我的机器是32G的,因此设置成16G
Xmn :这个值小,就会造成频繁的垃圾回收进程。为了减少进程启动,设置成8G。
原来的参数是2,2,1,太小了。
这篇关于shardingsphere调优日记的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!