Spring Boot
Actuator
Thread Pool
Java
Application Performance

Run Spring Boot Actuator on a separate port (management.server.port)

Codemia Knowledge Hub ·

Spring Boot has no built-in "actuator thread pool" setting for web endpoints served on the same port as your application. To isolate Actuator traffic, serve it on a separate management port with management.server.port, which gives the management endpoints their own web server context and request handling.

What handles Actuator requests

Actuator web endpoints are ordinary HTTP endpoints exposed through the application's web stack:

  • in a servlet app, the embedded container handles them
  • in a reactive app, the reactive server infrastructure handles them
  • they do not get a dedicated executor just because they are Actuator endpoints

On a shared port, Actuator and the application share the same request handling path. Tuning Tomcat, Jetty, Undertow or Netty affects the whole web server, not only Actuator.

Setting a separate management port

properties
server.port=8080
management.server.port=8081
management.endpoints.web.exposure.include=health,info,prometheus

With this setup:

  • application traffic is served on port 8080
  • Actuator traffic is served on port 8081
  • the management context is separate from the main server context

This keeps health checks, metrics scrapes and admin calls from competing directly with user-facing traffic on the same listener. To restrict access further, bind the management server to a private address:

properties
management.server.address=127.0.0.1

That suits setups where only a reverse proxy, sidecar or local monitoring agent should reach the endpoints.

What a separate port does and does not give you

It gives you:

  • independent network routing
  • different firewall or proxy rules
  • different connection handling infrastructure
  • less contention with public request traffic

It does not create an internal worker pool for each Actuator operation. The benefit is separation at the web server level.

Often the real problem is not thread pools at all but high-frequency monitoring calls such as /actuator/health or /actuator/prometheus competing with application traffic. A separate management port plus reverse proxy or network controls fixes that more cleanly than trying to route specific endpoints to specific threads inside one listener.

Staying on one port

If Actuator and the application must share a port, no out-of-the-box property says "use this executor only for /actuator/**". Your options are server-wide tuning and endpoint design:

  • tune the container thread pool for the whole app
  • make expensive health checks fast or cached
  • avoid synchronous remote calls inside custom Actuator endpoints
  • push long-running inspection work into background tasks

Expensive remote checks placed directly in health indicators, without caching or time limits, are a common cause of slow Actuator responses.

Offloading expensive custom work to your own executor

If a custom health indicator or endpoint does expensive work, you can run that work on your own executor. This does not change the HTTP connector pool, but it keeps the expensive logic off the request thread's own code path.

java
1import java.util.concurrent.CompletableFuture;
2import java.util.concurrent.Executor;
3import org.springframework.context.annotation.Bean;
4import org.springframework.context.annotation.Configuration;
5import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
6
7@Configuration
8public class ExecutorConfig {
9    @Bean
10    public Executor actuatorWorkExecutor() {
11        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
12        executor.setCorePoolSize(2);
13        executor.setMaxPoolSize(4);
14        executor.setQueueCapacity(20);
15        executor.setThreadNamePrefix("actuator-work-");
16        executor.initialize();
17        return executor;
18    }
19}

A custom component can then use it:

java
1import java.util.concurrent.CompletableFuture;
2import java.util.concurrent.Executor;
3import org.springframework.boot.actuate.health.Health;
4import org.springframework.boot.actuate.health.HealthIndicator;
5import org.springframework.stereotype.Component;
6
7@Component
8public class SlowDependencyHealthIndicator implements HealthIndicator {
9    private final Executor actuatorWorkExecutor;
10
11    public SlowDependencyHealthIndicator(Executor actuatorWorkExecutor) {
12        this.actuatorWorkExecutor = actuatorWorkExecutor;
13    }
14
15    @Override
16    public Health health() {
17        String status = CompletableFuture.supplyAsync(() -> "ok", actuatorWorkExecutor)
18                .join();
19        return Health.up().withDetail("dependency", status).build();
20    }
21}

The limitation: the incoming HTTP request still enters through the management web server. The custom executor isolates only the internal work you choose to offload, not the entire request path.


Course
Intermediate
27 lessons
15 hours
DSA Fundamentals

Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.

View the course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms