compose icon indicating copy to clipboard operation
compose copied to clipboard

health check with higher rate during start_period

Open disk91 opened this issue 2 years ago • 6 comments

Description

When checking the health_check to create a dependency on container start you want to have a high rate check (like every second) to start the service as soon as possible. But once the containers are started you don't want to overload your service with health_checks.

Without this proposal, you need to wait interval time to discover your container is healthy and start the dependent containers even if the service was healthy a few seconds after being up.

I propose to have a new parameter like start_interval to override the interval period during the start_period. Let take this config exemple:

  db:
    health check:
	test: ...
	   interval: 30s
	   timeout: 3s
           retry:2
	   start_period: 20s
           start_interval: 1s

This will perform a health check on every 1s during the start_period (from start to healthy stat, retry limit is ignored), then perform health check on every 30s with timeout & retry applied.

This is for reducing the downtime during stack restart and avoid to overload the health test after being started.

disk91 avatar Apr 12 '23 09:04 disk91

This sounds like a nice improvement! Compose's health check support is actually a wrapper around the functionality in Docker Engine, so this would need to exist there before Compose can support it.

I would open a feature request at https://github.com/moby/moby - if/when it's included in an Engine release, we can look at extending <svc>.healthcheck in YAML accordingly.

milas avatar Apr 12 '23 21:04 milas

Related;

  • https://github.com/moby/moby/issues/33410
  • https://github.com/moby/moby/pull/40894

thaJeztah avatar Apr 12 '23 21:04 thaJeztah

With --start-interval now available could you reopen the issue? Or should it be remade?

nedsociety avatar Jul 11 '23 08:07 nedsociety

Might as well re-open this one 👍

Next step would probably be a change in the compose-spec; there's a tracking issue in moby;

  • https://github.com/moby/moby/issues/45897

And a pending PR in the compose-spec (which has to be included in compose once that's accepted/merged);

  • https://github.com/compose-spec/compose-spec/pull/383

thaJeztah avatar Jul 11 '23 15:07 thaJeztah

Thanks @thaJeztah 👍

glours avatar Jul 11 '23 16:07 glours

This is fixed by #10939 (and also a duplicate of #10830)

vincentbernat avatar Jun 19 '24 06:06 vincentbernat