Skip to content

Provide a way to customize the graceful shutdown delay of Netty EventLoopGroups #5813

@trustin

Description

@trustin

Server and ClientFactory currently calls EventLoopGroup.shutdownGracefully() to terminate Netty EventLoopGroups when they stop or close. shutdownGracefully() incurs 2-3 second delay and it can make the applications suffer when it needs to start and stop frequently.

It'd be nice if Armeria provides a user to customize the graceful shutdown delay of EventLoopGroups, like it does for Server requests, so that they can minimize the amount of time required for tearing down a Server or a ClientFactory.

We could, for example, allow a user to specify a config instead of boolean shutdownOnStop in ServerBuilder and ClientFactoryBuilder methods, e.g.

public class GracefulShutdownSpec {
    // External resource managed by the caller - don't shut down
    public static GracefulShutdownSpec ofExternal() { ... }
    // Don't shut down gracefully - shut down immediately
    public static GracefulShutdownSpec ofImmediate() { ... }
    // Shut down gracefully
    public static GracefulShutdownSpec of(quiet period, hard timeout) { ... }
}

Server
  .builder()
  .workerGroup(..., GracefulShutdownSpec.of...)
  // Could be reused for the existing graceful shutdown settings
  // Note: `ofExternal` is not allowed here.
  .gracefulShutdownTimeout(GracefulShutdownSpec.of...)
  ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions