springcloud各组件参数总结(已压测性能)

前言:最近对springcloud做了具体的性能测试和调整,目前性能较好,默认并发200,动态调整zuul中参数(已有注释)可提高上限,但是建议提高上限的同时考虑安全性,最好配置限流达到高峰控制。

eureka:(建议使用集群,调用规则默认是轮询)

spring:
  application:
    name: service-registry
  profiles.active: dev
server: 
  tomcat: 
    max-threads: 500  #tomcat工作线程数量
    accept-count: 500 #tomcat接受排队的最大数量
    max-connections: 200 #tomcat处理的最大连接数
logging: 
  config: classpath:logback-spring.xml
  path: log
  file: eureka
eureka: 
  server: 
    peer-node-read-timeout-ms: 2000  #读取对等节点服务器复制的超时的时间,单位为毫秒,默认为200
    waitTimeInMsWhenSyncEmpty: 0
    enable-self-preservation: false
    eviction-interval-timer-in-ms: 10000
    #在生产环境中可以把 renewalPercentThreshold 参数调小一点,进而提高触发 SELF PRESERVATION 机制的门槛,默认0.85
    renewal-percent-threshold: 0.85 
  client: 
    # 针对新服务上线, Eureka client获取不及时的问题,在测试环境,可以适当提高Client端拉取Server注册信息的频率,默认:30秒
    registry-fetch-interval-seconds: 5

zuul:(已解决性能并发上限)

server:
  port: 9002
  tomcat:
    max-threads: 1000  #tomcat工作线程数量
    accept-count: 1000 #tomcat接受排队的最大数量
    max-connections: 1000 #tomcat处理的最大连接数
spring:
  application:
    name : service-session-zuul
  profiles:
      active: prod
  session: 
    store-type: redis   
  redis:
  #单机配置
#    host:  localhost
#    port: 6379
#    database: 8
#    jedis: 
#      pool:
#        max-active: 8
#        min-idle: 1
#        max-idle: 1
#        max-wait: -1
  #集群配置
    cluster:
      nodes:
      - localhost:7001
      - localhost:7002
      - localhost:7003
      - localhost:7004
      - localhost:7005
      - localhost:7006
logging: 
  config: classpath:logback-spring.xml
  path: log
  file: zuul
  
zuul: 
  sensitiveHeaders: 
  servlet-path: /**
  ignoredServices: "*" #忽略所有未配置的service
  host:
    connect-timeout-millis: 20000
    socket-timeout-millis: 20000
    max-per-route-connections: 20 #重要,默认20,需要加大
    max-total-connections: 200 #默认200,高并发需要加大
  routes: 
    service-session-zuul: 
      path: /**
      serviceId: 服务名
      sensitiveHeaders: 
      stripPrefix: true
  add-host-header: true
  semaphore:
    max-semaphores: 5000 #信号量,Hystrix最大的并发请求(1秒时间窗口内的事务/查询/请求)

hystrix: 
  threadpool: 
    # default: 默认参数,作用的所有的hystrix的客户端,如果需要对某个具体的接口,可以写接口+方法名称
    default:
      coreSize: 5000
  command:
    default: 
      fallback:
        # 是否开启回退方法
        enabled: true
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 60000 #缺省为1000
ribbon:
  OkToRetryOnAllOperations: false #对所有操作请求都进行重试,默认false
  ReadTimeout: 10000   #负载均衡超时时间,默认值5000
  ConnectTimeout: 10000 #ribbon请求连接的超时时间,默认值2000
  MaxAutoRetries: 0     #对当前实例的重试次数,默认0
  MaxAutoRetriesNextServer: 1 #对切换实例的重试次数,默认1
  MaxConnectionsPerHost: 50 #和配置最大并发数一起使用,调大即可
  MaxTotalConnections: 200 #和配置最大并发数一起使用,调大即可

3、消费者和生产者主要关注的点是,tomcat的性能和数据库连接池的性能(可以通过部署多节点的方式去提升性能)

server: 
  port : 9003
  tomcat:
    max-threads: 500  #tomcat工作线程数量
    accept-count: 500 #tomcat接受排队的最大数量
    max-connections: 200 #tomcat处理的最大连接数
#生产者不需要配置feign和ribbon
feign:
  hystrix:
    enabled: true 
hystrix: 
  threadpool: 
    # default: 默认参数,作用的所有的hystrix的客户端,如果需要对某个具体的接口,可以写接口+方法名称
    default:
      coreSize: 500
  command:
    default: 
      fallback:
        # 是否开启回退方法
        enabled: true
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 30000 #缺省为1000

ribbon:
  OkToRetryOnAllOperations: false #对所有操作请求都进行重试,默认false
  ReadTimeout: 10000   #负载均衡超时时间,默认值5000
  ConnectTimeout: 2000 #ribbon请求连接的超时时间,默认值2000
  MaxAutoRetries: 0     #对当前实例的重试次数,默认0
  MaxAutoRetriesNextServer: 1 #对切换实例的重试次数,默认1

#这个数据库连接池只是例子,可以根据自己的需求配置,关键点是连接池的等待时间,最大连接数
datasource-master: 
    url: jdbc:oracle:thin:@localhost:1521:lcdbe1
    username: root
    password: 123456
    driver-class-name: oracle.jdbc.driver.OracleDriver
    type: com.alibaba.druid.pool.DruidDataSource
    max-active: 80
    initial-size: 1
    min-idle: 3
    max-wait: 6000
    time-between-eviction-runs-millis: 60000
    min-evictable-idle-time-millis: 300000
    test-while-idle: true
    test-on-borrow: false
    test-on-return: false
    pool-prepared-statements: true
    hibernate-dialect: org.hibernate.dialect.Oracle10gDialect
    hibernate-show-sql: true
    hibernate-format-sql: true
    hibernate-generate-statistics: true
    hibernate-max-fetch-depth: 1
    hibernate-hbm2ddl-auto: none

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值