Micronaut Netty Event Loop Configuration Not Honoring Shutdown Timeout on SIGTERM

91 views Asked by At

I am working on a Micronaut service, where I have configured a custom Netty event loop for handling requests. The goal is to ensure that when the service receives a SIGTERM signal, it should continue processing ongoing requests for a specified grace period (40 seconds) before shutting down. However, despite the configuration, the service does not seem to honor the shutdown grace period.

Here is the relevant part of my application.properties configuration:

micronaut:
  application:
    name: my-service
  server:
    port: ${SERVER_PORT:8080}
    netty:
      worker:
        event-loop-group: other
  netty:
    event-loops:
      other:
        num-threads: 5
        io-ratio: 50
        shutdown-quiet-period: '40s'
        shutdown-timeout: '40s'

When I test the service by sending requests through Postman, it correctly processes the requests using the configured custom event loop (e.g., [other-nioEventLoopGroup-3-2] thread). This indicates that the service is indeed using the specified event loop configuration.

However, the problem arises when I send a SIGTERM signal to the application to simulate a graceful shutdown. Despite the shutdown-quiet-period and shutdown-timeout being set to 40 seconds, the service shuts down immediately without waiting for the ongoing requests to complete within the grace period.

Expected Behavior: The application should continue processing the ongoing request for up to 40 seconds before shutting down, honoring the shutdown-quiet-period and shutdown-timeout configurations.

Actual Behavior: The application shuts down immediately after receiving the SIGTERM signal, not waiting for the specified shutdown timeout.

I am seeking guidance on why the Micronaut Netty event loop configuration does not seem to be respected during the shutdown process. Is there an additional configuration I am missing, or is this behavior expected due to some misunderstanding on my part regarding how Micronaut or Netty handles shutdown signals?

Any insights or suggestions on how to ensure the application respects the configured shutdown timeout would be greatly appreciated.

0

There are 0 answers