Golang Microservices: Graceful Shutdown

  Рет қаралды 5,579

Mario Carrion

Mario Carrion

Күн бұрын

Пікірлер: 7
@MarioCarrion
@MarioCarrion 3 жыл бұрын
*Blog* mariocarrion.com/ *Example code* github.com/MarioCarrion/todo-api-microservice-example/tree/76509a58cabf95bb8329da4e8bf41986885ba814 *Building Microservices in Go* kzbin.info/aero/PL7yAAGMOat_Fn8sAXIk0WyBfK_sT1pohu *Go Tools and Packages* kzbin.info/aero/PL7yAAGMOat_HEEOvH99agDs_5g51A0Ls3 *Testing in Go* kzbin.info/aero/PL7yAAGMOat_HSeW4zF0uRL9EaHadE4ZZq *Keep it up!*
@0zema
@0zema 3 жыл бұрын
your content is a god-send, very clear and understandable with actual valuable information and insane quality!
@MarioCarrion
@MarioCarrion 3 жыл бұрын
Thanks Osama! Cheers
@josemontero9782
@josemontero9782 Жыл бұрын
Great video, one question, what does the ctx.WithTimeout(5 sec) do ? I know is being use for the srv.ShutDown function, but is there a especific thing for the 5 sec ? Is it to allow the Shutdown function time to finish ?
@MarioCarrion
@MarioCarrion Жыл бұрын
It creates a context that will time out in 5 seconds; in practice, this means: "wait up to 5 seconds or just exit right away". To be fair, 5 seconds looks like a magic number, but it's usually more than enough to close all existing connections; in the end, depending on how you're scaling up/down, like the orchestration system you're using, will override this anyways.
@SirRFI
@SirRFI 3 жыл бұрын
So, to my understanding, graceful shutdown you described just tries to stop everything as soon as it's safe to do so (close connections etc.). What if I wanted it to finish ongoing requests first, without accepting new?
@MarioCarrion
@MarioCarrion 3 жыл бұрын
For this specific case (http.Server), the "Shutdown" method does what you're describing: it closes all open listeners, then idle connections and finally it waits indefinitely for any connection until they become idle so those can be closed; but if the received context defines a deadline then that one honored as well. However things get a bit complicated because the process that triggered the stop will eventually try to forcibly terminate it if that one is still running, that's why using the configured "grace period" becomes useful in those cases; if we are talking about long running processes perhaps defining a way to "resume" those processes could make sense.
Golang Microservices: Searching with Elasticsearch
14:22
Mario Carrion
Рет қаралды 14 М.
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 60 МЛН
Golang Microservices: Using Docker for Containerization
19:41
Mario Carrion
Рет қаралды 5 М.
Software Architecture in Golang: Externalized Configuration Pattern
11:35
Graceful Shutdown или как красиво уйти
20:47
Evrone Development
Рет қаралды 5 М.
Golang Microservices: Working and Dealing with Errors
15:59
Mario Carrion
Рет қаралды 4,4 М.
Stop Losing Requests! Learn Graceful Shutdown Techniques
13:39
DevOps Toolkit
Рет қаралды 4,7 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 685 М.
Используем context для остановки приложений (Golang)
18:41
Gopher School (Уроки по Golang)
Рет қаралды 20 М.
Проверяем готовый ПК MSI из магазина
1:00
Samsung AI 💀 #trollface
0:18
Faixan FF
Рет қаралды 10 МЛН
Organize Your Home With These Must-Have Smart Gadgets #shorts  Pt-2
0:22
Introducing the "VitaWear SmartBand,"😳 a next-gen wearable gadget🎉
0:26
Shreya fun shorts
Рет қаралды 4,5 МЛН