国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

SpringBoot內置tomcat調優(yōu)測試優(yōu)化

發(fā)布時(shí)間:2021-07-17 21:51 來(lái)源:腳本之家 閱讀:0 作者:蝸牛烏龜一起走 欄目: 編程語(yǔ)言 歡迎投稿:712375056

問(wèn)題

怎么配置springBoot 內置tomcat,才能使得自己的服務(wù)效率更高呢?

基礎配置

Spring Boot 能支持的最大并發(fā)量主要看其對Tomcat的設置,可以在配置文件中對其進(jìn)行更改。我們可以看到默認設置中,Tomcat的最大線(xiàn)程數是200,最大連接數是10000。 這個(gè)不同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;

測試步驟

通過(guò)我們查看源碼得知了(org.springframework.boot.autoconfigure.web.ServerProperties)springBoot 內置tomcat 默認配置,現在我們?yōu)榱嗽诒镜伢w現出效果,我們將配置參數有意調小配置如下進(jìn)行壓測,同時(shí)將壓測接口中設置sleep(2000) 模擬線(xiàn)程沒(méi)有釋放。

  tomcat:
     #最小線(xiàn)程數
    min-spare-threads: 5
    #最大線(xiàn)程數
    max-threads: 5
    #最大鏈接數
    max-connections: 5
    #最大等待隊列長(cháng)度
    accept-count: 1

該配置對應壓測

通過(guò)壓測100并發(fā) 發(fā)現異常達到了85% 由于我們配置ReadTimeout 和ConnectTimeout 配置2秒 100個(gè)線(xiàn)程同時(shí)達到,處理最大線(xiàn)程才1,排隊也是1 導致一個(gè)是沒(méi)有線(xiàn)程處理請求導致超時(shí)一個(gè)是排不上隊別拒絕。當我按照本機cup 合理配置后看看壓測情況。優(yōu)化配置如下:

  tomcat:
      #最小線(xiàn)程數
    min-spare-threads: 100
    #最大線(xiàn)程數
    max-threads: 600
    #最大鏈接數
    max-connections: 10000
    #最大等待隊列長(cháng)度
    accept-count: 1000

如上圖 同樣是100并發(fā) 異常率為0 全部通過(guò),響應時(shí)間也是減除sleep(2000) 大多數都是10毫秒內。優(yōu)化效果可見(jiàn)顯著(zhù)。

到此這篇關(guān)于SpringBoot內置tomcat調優(yōu)測試優(yōu)化的文章就介紹到這了,更多相關(guān)SpringBoot內置tomcat調優(yōu)測試內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

sp
人人妻人人妻人人片AV| 欧美日韩国产精品自在自线| 久久精品伊人无码二区| av片在线播放| A∨天堂亚洲区无码先锋影音| 熟妇的奶头又大又粗视频|