spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.87k stars 40.61k forks source link

Management endpoint Tomcat connector picks up general server properties #9560

Open asarkar opened 7 years ago

asarkar commented 7 years ago

It appears that the management port connector is using the same settings as the regular one (usually 8080). We found this during performance test. It makes sense to tweak the settings for port 8080, or whatever port the application is running on, without impacting the management port. It doesn't make sense to assume that at peak usage, there is going to be as many people using the management port as the number of concurrent users.

This ticket is to introduce new thread and connection properties for the management port. To begin with, don't use the ones for regular 8080 port.

snicoll commented 7 years ago

Can you expand what connection properties you are referring to? I suppose you are aware of management.port?

asarkar commented 7 years ago

@snicoll I'm aware of management.port; it changes the default actuator port, not the behavior I opened this ticker for.

The properties I'm referring to are the server.tomcat thread pool properties. I've not checked for other server properties, but I see the following getting picked up by management endpoint.

server:
  tomcat:
    max-threads: 10
    min-spare-threads: 10
    accept-count: 10

The numbers above are defaults for development, and overridden for performance testing.

philwebb commented 7 years ago

I can't really see an obvious way to configure the main Tomcat connector but not the management connector. Currently these settings are setup using a TomcatConnectorCustomizer and will be applied to all connectors.

asarkar commented 7 years ago

@philwebb But if I create a container myself, the settings are not applied.

@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
    tomcat.addAdditionalTomcatConnectors(createTrustedConnectors());
    return tomcat;
}

private Connector[] createTrustedConnectors() {
    return trustedPorts.stream()
            .map(port -> {
                Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
                Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
                connector.setScheme("http");
                connector.setSecure(false);
                connector.setPort(port);
                protocol.setSSLEnabled(false);

                return connector;
            })
            .toArray(size -> new Connector[size]);
}
asarkar commented 7 years ago

Just following up on this ticket. There are 2 separate issues in our hands, perhaps contradictory.

  1. Management port picks up the settings for default Tomcat port. @philwebb said it's difficult to change that, which brings me to number 2 below.
  2. If I create a Tomcat connector myself, it doesn't pick up the settings for default Tomcat port. If the TomcatConnectorCustomizer is customizing all connectors, why doesn't it customize mine?
wilkinsona commented 7 years ago

Two reasons: