• 问题

怎么配置springBoot 内置tomcat,才能使得自己的服务效率更高呢?

  • 基础配置

Spring Boot 能支持的最大并发量主要看其对Tomcat的设置,可以在配置文件中对其进行更改。我们可以看到默认设置中,Tomcat的最大线程数是200,最大连接数是10000。 这个不同SpringBoot 版本可能有所细微差别。本文测试基于Springboot 2.0.7.RELEASE

  • 默认配置
/*** Maximum amount of worker threads.*/private int maxThreads = 200;/*** Minimum amount of worker threads.*/private int minSpareThreads = 10;/*** Maximum size in bytes of the HTTP post content.*/private int maxHttpPostSize = 2097152;/*** Maximum size in bytes of the HTTP message header.*/private int maxHttpHeaderSize = 0;/*** Whether requests to the context root should be redirected by appending a / to* the path.*/private Boolean redirectContextRoot = true;/*** Whether HTTP 1.1 and later location headers generated by a call to sendRedirect* will use relative or absolute redirects.*/private Boolean useRelativeRedirects;/*** Character encoding to use to decode the URI.*/private Charset uriEncoding = StandardCharsets.UTF_8;/*** Maximum number of connections that the server accepts and processes at any* given time. Once the limit has been reached, the operating system may still* accept connections based on the "acceptCount" property.*/private int maxConnections = 10000;/*** Maximum queue length for incoming connection requests when all possible request* processing threads are in use.*/private int acceptCount = 100;
  • 测试步骤

通过我们查看源码得知了(org.springframework.boot.autoconfigure.web.ServerProperties)springBoot 内置tomcat 默认配置,现在我们为了在本地体现出效果,我们将配置参数有意调小配置如下进行压测,同时将压测接口中设置sleep(2000) 模拟线程没有释放。

  tomcat:#最小线程数min-spare-threads: 5#最大线程数max-threads: 5#最大链接数max-connections: 5#最大等待队列长度accept-count: 1
  • 该配置对应压测

通过压测100并发 发现异常达到了85% 由于我们配置ReadTimeout 和ConnectTimeout 配置2秒 100个线程同时达到,处理最大线程才1,排队也是1 导致一个是没有线程处理请求导致超时一个是排不上队别拒绝。当我按照本机cup 合理配置后看看压测情况。优化配置如下:

  tomcat:#最小线程数min-spare-threads: 100#最大线程数max-threads: 600#最大链接数max-connections: 10000#最大等待队列长度accept-count: 1000

如上图 同样是100并发 异常率为0 全部通过,响应时间也是减除sleep(2000) 大多数都是10毫秒内。优化效果可见显著。

优化之SpringBoot 内置tomcat 调优测试相关推荐

  1. springboot内嵌tomcat调优

    在springboot-configuration-metadata.json文件下面,有很多属于springboot得喷子hi属性,以下为tomcat的默认配置属性: server.tomcat.a ...

  2. SpringBoot 内置 Tomcat 线程数优化配置,你学会了吗?

    前言 本文解析springboot内置tomcat调优并发线程数的一些参数,并结合源码进行分析 参数 线程池核心线程数 server.tomcat.min-spare-threads:该参数为tomc ...

  3. Springboot内置Tomcat配置参数调优

    Springboot内置Tomcat配置参数调优,首先,线程数是一个重点,每一次HTTP请求到达Web服务器,Web服务器都会创建一个线程来处理该请求,该参数决定了应用服务同时可以处理多少个HTTP请 ...

  4. SpringBoot内置tomcat出现error:An incompatible version [1.1.32] of the APR based Apache Tomcat Native lib

    SpringBoot内置tomcat出现error:An incompatible version [1.1.32] of the APR based Apache Tomcat Native lib ...

  5. SpringBoot内置Tomcat支持多大并发量和连接数

    SpringBoot内置Tomcat,再默认设置中,Tomcat的最大线程数是200,最大连接数是10000.支持的并发量是指连接数,200个线程如何处理10000条连接的? Tomcat有两种处理连 ...

  6. SpringBoot内置tomcat出现APR版本过低解决办法

    SpringBoot内置tomcat出现error:An incompatible version [1.1.32] of the APR based Apache Tomcat Native lib ...

  7. SpringBoot内置Tomcat启动不了的原因

    SpringBoot内置Tomcat启动不了的原因: 1.需要加入spring-boot-starter-web依赖 [web中集成了tomcat.dispatcherServlet.xml-] &l ...

  8. SpringBoot内置Tomcat浅析

    一.SpringBoot框架内置Tomcat,开发非常方便,随着SpringBoot的框架升级,内置Tomcat也更新版本.本文SpringBoot框架版本:2.2.10. 1.如何查看SpringB ...

  9. SpringBoot内置tomcat启动原理

    前言 不得不说SpringBoot的开发者是在为大众程序猿谋福利,把大家都惯成了懒汉,xml不配置了,连tomcat也懒的配置了,典型的一键启动系统,那么tomcat在springboot是怎么启动的 ...

最新文章

  1. 初级c 语言题库,c 语言题库.doc
  2. vs2010 常见问题处理
  3. 用Android Stuidio开发Flutter
  4. 项目经理排期的几个tip
  5. java个人博客系统源码_Java基于SSM的个人博客系统(源码 包含前后台)
  6. IT项目经验和难点分享
  7. java 4级_《软件测试人员(Java)(4级)》【价格 目录 书评 正版】_中国图书网
  8. 面对强势顾客,怎样应对才好?
  9. 【数字孪生】UE4虚幻引擎与前端Web页面的结合
  10. 新冠肺炎/病毒最新治疗研究进展(2022年6月)
  11. 【连载之一】那些公众号不会告诉你的职业真相
  12. 夜神模拟器SD卡文件存储位置
  13. 顺丰开放平台开发者接入指引
  14. 【Pandas 数据分析 2】数据结构
  15. 用node.js和express.js和jade搭建轻型cms系统
  16. 厦门有哪些靠谱的互联网公司
  17. [转帖]详细讲解六大QQ病毒的特征以及清除方法
  18. JavaScript作用域的知识点
  19. jQuery 参考手册
  20. c++day03 const修饰函数是修饰谁

热门文章

  1. 《开讲啦》观后感(互联网)
  2. HTTP中的中文编码与在线编码转换工具
  3. Git 常用配置和技巧
  4. 小米手机系统升级到MIUI8,Android studio真机调试须知
  5. 【51单片机】点亮LED灯(四种形式)
  6. linux搭建kk教程,linux版本KK搭建视频教程+文字教程
  7. 获取发布到appstore的 app下载地址
  8. 王者英雄胜率用计算机怎么算,王者荣耀英雄胜率怎么算
  9. 初识二维码 第一讲二维码的起源
  10. 微型计算机2017年12月下,2017年12月计算机一级《WPS》自测试题及答案