IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

HealthCheck - Add a setting to exclude DB #75

Open shainegordon opened 9 months ago

shainegordon commented 9 months ago

What problem are you trying to solve?

We run a lot of Serverless Databases (Neon, PlanetScale, etc).

Many of these services are billed per minute and shut down with inactivity.

The health check endpoint is also used by docker, which is in turn used by Kubernetes, fargate, etc, to determine if a container is healthy or not. e.g.

HEALTHCHECK --interval=5s --timeout=5s --retries=3 \
    CMD curl --fail http://localhost:5000/_health || exit 1

Unfortunately, what this means, is that because the DB is part of the health check, the DB will never shut down, which will result in costs accrued even if the service is not used.

Describe the solution you'd like

I'd like a setting, as part of the Health Check module, to exclude the DB.

Currently, I can achieve this on a per-project basis, manually, by doing the following:

var hcBuilder = services.AddHealthChecks();
//IntentIgnore
//IntentMatch("hcBuilder.AddNpgSql")
//hcBuilder.AddNpgSql(configuration.GetConnectionString("DefaultConnection")!, name: "PostgreSql", tags: new[] { "database" });
//We dont want to the health check for postgres, as this will keep the serverless db alive
return services;

While this works, it requires a developer to know that they need to do this, and it cannot be enforced on the organisation level.

JonathanLydall commented 9 months ago

Thank you @shainegordon,

It makes perfect sense to me to be able to turn this off through an application setting. We'll discuss briefly on our side and I'll keep you on updated on what we do.

dandrejvv commented 9 months ago

Hi @shainegordon , we're still discussing this github issue within the team. How would you feel if we made an appsettings.json like configurable option to be able to toggle the different health check options on/off? Is that something that you would find useful?

shainegordon commented 9 months ago

Hi @shainegordon , we're still discussing this github issue within the team. How would you feel if we made an appsettings.json like configurable option to be able to toggle the different health check options on/off? Is that something that you would find useful?

appsettings.json should be fine.

Ideally, I would like to be able to disable this as part of our Intent Application Template, but whatever makes sense for the majority of users would be OK