Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.82 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.82 KB
title keywords description
Tableflip Example
tableflip
golang
graceful upgrade
Use tableflip for graceful upgrades in a Go application.

Tableflip Example

Github StackBlitz

This example demonstrates how to use tableflip for graceful upgrades in a Go application.

What is Tableflip?

Tableflip is a library that allows you to update the running code and/or configuration of a network service without disrupting existing connections. It achieves this by starting a new process, transferring clients to it, and then exiting the old process.

Goals of Tableflip

  • No old code keeps running after a successful upgrade.
  • The new process has a grace period for initialization.
  • Crashing during initialization is acceptable.
  • Only a single upgrade is ever run in parallel.
  • Tableflip works on Linux and macOS.

Steps

  1. Build v0.0.1 Demo:

    go build -o demo main.go
  2. Run the Demo and Create a GET Request to 127.0.0.1:8080/version:

    [PID: 123] v0.0.1
  3. Prepare a New Version:

  • Change the main.go to update the version to "v0.0.2".
  • Rebuild the demo:
    go build -o demo main.go
  1. Kill the Old Process:

    kill -s HUP 123
  2. Create the Request to the Version API Again:

    [PID: 123] v0.0.2

The client is completely immune to server upgrades and reboots, and our application updates gracefully!