龙之队|一次线上JVM内存溢出分析,GC分析、MAT、gcviewer( 三 )
可以看到我同时配置了maxHttpPostSize和maxHttpHeaderSize为10MB大小 , 而且我还配置了500个最大线程 , 满载时就单单Buffer就要耗费4G的内存 。
后面我优化成:application.yml
server:port: 80servlet:context-path: /tomcat:maxThreads: 400minSpareThreads: 50看了源码才发现maxHttpHeaderSize默认配置了8k , maxHttpPostSize默认配置2M,默认情况下是够用了 , 除非你再header上携带大量的信息 。
maxHttpHeaderSize设置源码SpringBoot是通过org.springframework.boot.autoconfigure.web.ServerProperties配置
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)public class ServerProperties {?/*** Server HTTP port.*/private Integer port;?/*** Network address to which the server should bind.*/private InetAddress address;?@NestedConfigurationPropertyprivate final ErrorProperties error = new ErrorProperties();?/*** Whether X-Forwarded-* headers should be applied to the HttpRequest.*/private Boolean useForwardHeaders;?/*** Value to use for the Server response header (if empty, no header is sent).*/private String serverHeader;?/*** Maximum size of the HTTP message header.*/private DataSize maxHttpHeaderSize = DataSize.ofKilobytes(8);?/*** Time that connectors wait for another HTTP request before closing the connection.* When not set, the connector's container-specific default is used. Use a value of -1* to indicate no (that is, an infinite) timeout.*/private Duration connectionTimeout;?@NestedConfigurationPropertyprivate Ssl ssl;?@NestedConfigurationPropertyprivate final Compression compression = new Compression();?@NestedConfigurationPropertyprivate final Http2 http2 = new Http2();?private final Servlet servlet = new Servlet();?private final Tomcat tomcat = new Tomcat();?private final Jetty jetty = new Jetty();?private final Undertow undertow = new Undertow();...public static class Tomcat {.../*** Maximum size of the HTTP message header.*/private DataSize maxHttpHeaderSize = DataSize.ofBytes(0);@Deprecated@DeprecatedConfigurationProperty(replacement = "server.max-http-header-size")public DataSize getMaxHttpHeaderSize() {return this.maxHttpHeaderSize;}?@Deprecatedpublic void setMaxHttpHeaderSize(DataSize maxHttpHeaderSize) {this.maxHttpHeaderSize = maxHttpHeaderSize;}...}}?查看一下哪里调用getMaxHttpHeaderSize()方法
org.springframework.boot.autoconfigure.web.embedded.TomcatWebServerFactoryCustomizer
org.apache.coyote.http11.AbstractHttp11Protocol是一个抽象类 , 我们使用的是NIO , 则它的子类是org.apache.coyote.http11.Http11AprProtocol
在org.apache.coyote.http11.AbstractHttp11Protocol中maxHttpHeaderSize是如何被调用
推荐阅读
- 潇湘晨报|34岁当医院院长,曾是当地“外科一把刀”,却因受贿贪污获刑十九年!第一次收钱连说几声谢谢
- 网慧验房|一次又一次被泼凉水,房价坚挺已经没用了,楼市“发烧”城市
- 烹饪|口感松软的培根肉松蛋糕,0失败新手学一次就会,美味又蓬松
- 东方网|地铁4号线上海火车站一乘客突发晕厥 接下来的一幕暖心了
- 美国人|李小龙的日本徒弟,终生为李小龙守墓,如今93岁依然每周扫墓一次
- 新华社|2020服贸会 | 线下线上“齐开工” 爱尔兰展商借服贸会拓市场
- 人健人爱官方号|糖友们注意了,别舍不得扔掉一次性注射针,当心因小失大
- 克里斯-保罗|再给你一次机会,你选3850万的神龟,还是3851万的保罗?
- 数字财经智库|而他的对手却成千亿富豪,许家印最失败的一次投资:3年巨亏40亿
- 今年8月|休闲食品业半年报观察:线上渠道增量明显
