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

Graceful shutdown #713

Open
Anton3 opened this issue Oct 10, 2024 · 1 comment
Open

Graceful shutdown #713

Anton3 opened this issue Oct 10, 2024 · 1 comment

Comments

@Anton3
Copy link
Member

Anton3 commented Oct 10, 2024

As of now, upon receiving SIGTERM, userver returns 503 to all existing requests, breaks all connections and cancels all handler tasks immediately.

It is advised to set up some cooperation between balancers and hand-written service shutdown scripts to first signal balancers to move traffic to other hosts, then after N seconds send SIGTERM to the userver-based service.


It's suggested that graceful shutdown is optionally built into userver itself. How it should work:

  1. The service receives SIGTERM
  2. handler-ping starts to give out 503 or 500
  3. A certain number of seconds passes
    • Can be specified e.g. in the config of server or handler-ping
    • Hopefully, the health check probe will fail at least once during that time, notifying the balancer
  4. The service starts to actually shut down
@Anton3
Copy link
Member Author

Anton3 commented Oct 10, 2024

An additional feature request [might be lower priority] is to allow current requests to go past "soft deadline" without cancellation, until they hit "hard deadline", then 503 should be returned.

Example: a long Clickhouse DB query, which can take multiple seconds to complete, and it will hurt if it's cancelled, because there are no transactions. If no long queries are being processed, then the service will shut down immediately upon hitting the soft deadline. If there is a long query in processing, then the service will take its time if needed.

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

1 participant