The Real Fullstack

The Ungraceful Shutdown

Readiness probes are configured. So why does every deploy cost 300 failed requests?

مهندس أول9 دقيقةمحاكي الخط الزمنيتحدي الشيفرة
kubernetesspring-bootnodesigterm

لم يُترجم هذا التحدي إلى العربية بعد. أنت تقرأ النسخة الإنجليزية.

المهمة:Order the shutdown steps so that no request is accepted after the pod stops listening, no accepted request is dropped, and resources close last.السياق · أهداف التعلّم ▾

Larkspur's API pods receive SIGTERM during each rolling update. The current shutdown hook closes the database pool, stops the HTTP server and exits — while the load balancer is still sending traffic and in-flight requests still need the database.

المهمة: Order the shutdown steps so that no request is accepted after the pod stops listening, no accepted request is dropped, and resources close last.

أهداف التعلّم

  • Understand pod termination: SIGTERM, endpoint removal and grace period.
  • Fail readiness and wait before stopping the server.
  • Drain in-flight work before closing pools and consumers.
المحاكاةمحاكاة
pod
11. sigterm
22. closePools ✕ in-flight requests still use the DB, consumers still use the DB
33. stopAccepting ✕ stop accepting only after traffic stopped
44. exit
55. failReadiness
66. drainInflight
77. waitEndpoints
88. stopConsumers
تشغيل المحاكاة
# Kubernetesspec:  terminationGracePeriodSeconds: 45  containers:    - lifecycle:        preStop: { sleep: { seconds: 10 } }   # let endpoints and load balancers drop the pod first# Spring Boot application.yamlserver.shutdown: graceful                  # stop accepting, finish in-flight requestsspring.lifecycle.timeout-per-shutdown-phase: 30s

تبسيط

Eight steps with precedence rules. Endpoint propagation time depends on your load balancer and service mesh. نموذج تعليمي — الأرقام توضّح سلوكًا وليست قياسات أداء.

المفاهيم

مفيد قبل هذا التحدي

تحديات ذات صلة

المراجع