From 2a16813cd7a0ce360ff241f9f4657ebaa128542d Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 31 May 2023 15:21:45 +0200 Subject: [PATCH] test tomcat config --- .../java/ch/ethz/seb/sebserver/SEBServer.java | 49 +++++++++---------- .../resources/config/application.properties | 2 + 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/SEBServer.java b/src/main/java/ch/ethz/seb/sebserver/SEBServer.java index d3018c4d..f8bd28e1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/SEBServer.java +++ b/src/main/java/ch/ethz/seb/sebserver/SEBServer.java @@ -10,13 +10,10 @@ package ch.ethz.seb.sebserver; import org.apache.catalina.connector.Connector; import org.apache.commons.lang3.BooleanUtils; -import org.apache.coyote.http11.AbstractHttp11Protocol; -import org.apache.coyote.http11.Http11NioProtocol; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -87,29 +84,29 @@ public class SEBServer { return firewall; } - @Bean - public WebServerFactoryCustomizer tomcatCustomizer() { - return (tomcat) -> tomcat.addConnectorCustomizers((connector) -> { - if (connector.getProtocolHandler() instanceof AbstractHttp11Protocol) { - System.out.println("*************** tomcatCustomizer"); - final AbstractHttp11Protocol protocolHandler = (AbstractHttp11Protocol) connector - .getProtocolHandler(); - protocolHandler.setKeepAliveTimeout(60000); - protocolHandler.setMaxKeepAliveRequests(3000); - protocolHandler.setUseKeepAliveResponseHeader(true); - protocolHandler.setMinSpareThreads(200); - protocolHandler.setProcessorCache(-1); - protocolHandler.setTcpNoDelay(true); - protocolHandler.setThreadPriority(Thread.NORM_PRIORITY + 1); - protocolHandler.setMaxConnections(2000); - if (protocolHandler instanceof Http11NioProtocol) { - System.out.println("*************** Http11NioProtocol"); - ((Http11NioProtocol) protocolHandler).setPollerThreadPriority(Thread.MAX_PRIORITY); - } - - } - }); - } +// @Bean +// public WebServerFactoryCustomizer tomcatCustomizer() { +// return (tomcat) -> tomcat.addConnectorCustomizers((connector) -> { +// if (connector.getProtocolHandler() instanceof AbstractHttp11Protocol) { +// System.out.println("*************** tomcatCustomizer"); +// final AbstractHttp11Protocol protocolHandler = (AbstractHttp11Protocol) connector +// .getProtocolHandler(); +// protocolHandler.setKeepAliveTimeout(60000); +// protocolHandler.setMaxKeepAliveRequests(3000); +// protocolHandler.setUseKeepAliveResponseHeader(true); +// protocolHandler.setMinSpareThreads(200); +// protocolHandler.setProcessorCache(-1); +// protocolHandler.setTcpNoDelay(true); +// protocolHandler.setThreadPriority(Thread.NORM_PRIORITY + 1); +// protocolHandler.setMaxConnections(2000); +// if (protocolHandler instanceof Http11NioProtocol) { +// System.out.println("*************** Http11NioProtocol"); +// ((Http11NioProtocol) protocolHandler).setPollerThreadPriority(Thread.MAX_PRIORITY); +// } +// +// } +// }); +// } private Connector redirectConnector(final Environment env) { final String sslPort = env.getRequiredProperty("server.port"); diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index c7f7849f..57b27078 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -19,6 +19,8 @@ server.tomcat.socket.soKeepAlive=true server.tomcat.socket.performanceConnectionTime=1 server.tomcat.socket.performanceLatency=2 server.tomcat.socket.performanceBandwidth=0 +server.tomcat.keepAliveTimeout(20000); +server.tomcat.maxKeepAliveRequests(3000); server.tomcat.uri-encoding=UTF-8 ### encoding