Hi,
(folloup to the PR comment: 
https://github.com/apache/james-project/pull/2373#issuecomment-2294855488)

As I found out the hard way, James takes a lot of time to perform clear/complete shutdown (log at the end[1]).

As mentioned in the comment I see two main culprits:
1) `org.apache.james.protocols.lib.netty.AbstractServerFactory#destroy` destroys each server in sequence - making it parallel by using parallel stream instead of for-loop in already cuts down shutdown from 18s to 8 2) `is org.apache.james.protocols.netty.AbstractAsyncServer#unbind` with calls to io.netty.util.concurrent.EventExecutorGroup#shutdownGracefully() - by default they use quiet period of 2 seconds which makes each `.destroy()` call wait for 2 seconds which bumps the shutdown time. Without that the shutdown is almost instant. I'm not sure that having this default couple of seconds in this case makes sense as we are already in shutdown mode and unless services are closed first and then the rest of the James waits for it being closed then this grace period could actually be detrimental IMHO.




[1] Shutdown log
```
james-1 | [2024-08-17 13:01:42.855] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose Manage Sieve Service james-1 | [2024-08-17 13:01:44.887] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose Manage Sieve Service done james-1 | [2024-08-17 13:01:44.892] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose SMTP Service james-1 | [2024-08-17 13:01:46.915] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose SMTP Service done james-1 | [2024-08-17 13:01:46.915] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose SMTP Service james-1 | [2024-08-17 13:01:48.940] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose SMTP Service done james-1 | [2024-08-17 13:01:48.941] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose SMTP Service james-1 | [2024-08-17 13:01:50.974] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose SMTP Service done james-1 | [2024-08-17 13:01:50.974] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose SMTP Service james-1 | [2024-08-17 13:01:52.998] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose POP3 Service james-1 | [2024-08-17 13:01:55.033] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose POP3 Service done james-1 | [2024-08-17 13:01:55.034] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose IMAP Service james-1 | [2024-08-17 13:01:57.072] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose IMAP Service done james-1 | [2024-08-17 13:01:57.073] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose IMAP Service james-1 | [2024-08-17 13:01:59.100] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose IMAP Service done james-1 | [2024-08-17 13:01:59.100] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose IMAP Service james-1 | [2024-08-17 13:02:01.133] [INFO ] [ Thread-0] o.a.j.p.l.n.AbstractConfigurableAsyncServer.destroy(): Dispose IMAP Service done james-1 | [2024-08-17 13:02:01.157] [INFO ] [ Thread-0] t.j.CONFIGURATION.lambda$main$0(): JAMES server STOPPPED in: 18.312s
```
--
Wojtek


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to