Jay Taylor's notes

back to listing index

Using State Machines to Power Citus Cloud (our Database as a Service)

[web search]
Original source (www.citusdata.com)
Tags: state-machines citusdb dbaas craig-kerstiens www.citusdata.com
Clipped on: 2017-04-22

Using State Machines to Power Citus Cloud (our Database as a Service)

Daniel Farina Aug 12, 2016

It has been several months since the launch of Citus Cloud, and we’d like to share one part of its design with you. In particular, the fundamental unit of organization for our hosted service on top of AWS is concurrent state machines. In what follows we’ll walk through their use and implementation for Citus Cloud.

First, we’d be remiss if we didn’t acknowledge the great influence that working on Heroku Postgres had on the team. There are also a few talks on Heroku Postgres’s design that you may find as interesting and useful information.

Citus Cloud is recently written from scratch. Because of this, it’s a good time to provide guidance in how one can start writing similar systems.

An Example: A Server that Restarts

To orient ourselves, the following is pseudo-code of an abstract state machine, called Server. This state machine is for creating and restarting servers in some cloud provider:

     State: creating
         transition wait_running

     State: wait_running
         if not offline?
             transition running

     State: running
         if offline?
             transition stopping

     State: stopping
         transition starting_instance

     State: starting_instance
         transition wait_running

Image (Asset 2/3) alt=