shardingsphere调优日记

一、总括

调优的几个方面

  1. 连接数调优,包含shardingsphere和mysql的连接数。
  2. shardingsphere的globle.yaml中线程调优。(充分利用CPU)
  3. 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=true
    username: root
    password: Jwcs_18916939125
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 100
    minPoolSize: 20
  write_ds_1:
    url: jdbc:mysql://10.0.0.13:3306/newbus_1?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&databaseNameuseUnicode=true
    username: root
    password: Jwcs_18916939125
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 100
    minPoolSize: 20

二、CPU线程的利用率

  1. proxy-backend-query-fetch-size 参数值默认值为 -1,修改为 大数字可以尽量减少多行结果集的 fetch 次数。主要影响insert…values()的性能。
  2. proxy-frontend-executor-size 参数默认值为 CPU * 2
props:
  system-log-level: INFO
  max-connections-size-per-query: 1
  kernel-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 rule
  sql-show: false
  check-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 port
  proxy-frontend-ssl-enabled: false
  proxy-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,太小了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值