Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus.Metric breaks when :application_controller is busy #37

Open
joladev opened this issue Dec 16, 2020 · 4 comments
Open

Prometheus.Metric breaks when :application_controller is busy #37

joladev opened this issue Dec 16, 2020 · 4 comments
Assignees

Comments

@joladev
Copy link

joladev commented Dec 16, 2020

There can be other scenarios for why :application_controller would be busy, but the one that I've seen is where you're draining connections while shutting down using a library like https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html. Without connection draining when receiving a SIGTERM the endpoint will shut down immediately, killing any current connections. With connection draining listeners on the port are suspended, meaning no more connections are opened, but allow the existing connections to drain, and then (and only then) proceed with shutting down the endpoint.

This means :application_controller asks the application containing the endpoint to shut down and waits for it to be done. While it's waiting, it's completely blocked and can't respond to messages. Depending on how long your draining timeout is, this can be a long time. Prometheus.Metric uses Application.started_applications which sends a message to :application_controller and waits timeout (5 seconds) for a response. While draining connections this will always fail, causing Prometheus.Metric to blow up (this also means Prometheus.PlugExporter blows up when Prometheus tries to scrape). If it's helpful I can set up a repo that reproduces this.

Is it possible to avoid calling Application.started_applications? Or catching the failure?

I may also be missing something, but why is the on_load being called each time a request hits the Prometheus.PlugExporter?

@deadtrickster deadtrickster self-assigned this Jan 11, 2021
@deadtrickster
Copy link
Owner

Good questions, will look soon.

@joladev
Copy link
Author

joladev commented Jan 22, 2021

Hey! Any updates on this? ❤️

@sorliem
Copy link

sorliem commented Mar 21, 2023

Also running into this issue

@ikavgo
Copy link

ikavgo commented Mar 28, 2023

lol, forgot about this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants