Skip to content

HotReloadingDesign #1911

Description

@ric-pro

Shotover Hot Reloading Interface: Design

The proposed design to implement hot reloading mechanism will be based on handover of the listener socket from already running shotover to a new shotover instance. The new shotover will start accepting new connections while the old shotover will handle all the existing connections until all the connections are handled. Since there are multiple shotover instances running in parallel, the serialisation/ de-serialisation of any states to disks are not required.

As part of the design, those needed to be finalised at this stage will be the following:

  1. The Communication Channel
  • A unix domain socket can be used as the primary communication channel between the old and the new shotovers. The two main approaches that can be considered for managing the socket paths are:

    • Explicit Path - As in the user will pass the path to the unix socket as a CLI argument to both the old and new shotover instance.

    • Default path - There will be a default path for unix sockets. Whenever a new shotover starts, it checks if the socket is at the default path. If yes, the new instance will assume that it is entering in a hot reload mode.

Both approaches have its own benefits, a combination of both can result in flexibility. A new starting shotover should check for any CLI arguments in relation to hot reloading, if not found - it should also check for the unix socket at the default path.

  1. How Hot Reloading is triggered
  • a new shotover can be started with a particular CLI flag. This will make the shotover to connect to the unix sockets path the specified or default path. Once the connection is established, the new shotover will send a request to the old shotover for transferring the listening sockets.

  • Once the request is received, the old shotover will check if there are any requests made for hot reloading, if yes, the listener sockets will be transferred to the new shotover and the old shotover will enter a 'draining state' where it will stop receiving the new connections and will continue with processing the existing connections.

  • Once all the existing connections are processed, the old shotover will be shutdown.

  1. The processes happening while hot reloading happens
  • The processes that will happen in the shotover hot reload will be the following:

    • Old Shotover - The first shotover will be running. It has a unix socket at a specified path or default path. It is listening to the incoming messages at this socket.

    • New Shotover - A new shotover is started with a CLI flag which trigger the shotover to start in hot reload mode. This shotover will have the same configuration as the old shotover.

    • Handover - The new shotover will send a 'handover' request to the old shotover through the unix sockets. Once the old shotover receives the handover request, the file descriptors of the listening socket is transferred to the new shotover.

    • The New Shotover Up and running - Once the new shotover receives the listener sockets, all the new client connections will be processed through this shotover.

    • The Previous shotover in 'Drain' Mode - Since the listening socket is transferred to the new shotover, the old shotover will no longer receive any new connections. It will enter a 'drain' mode where it will handle all the existing connections. Once all the existing connections are processed, the old instance will shut down.

[Question: if we integrate a timer at which the old shooter gets forcefully shuts while still having connections to process]

  1. The Integration Test
  • The test should initially focus on verifying whether the handover and shutdown was successful.

    • This can be done by:

      • Start a shotover

      • Start another shotover with CLI Argument for hot reloading

      • Check if the handover is successful, the first shotover is shutdown and the second shotover is running successfully.

      • Check if the first shotover is no longer taking new connections and is being able to successfully process the existing connections

      • Check if the new shotover is able to receive new connections and is being able to successfully process those new connections.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions