brentjanderson
Zero downtime Postgres upgrades | Knock
We recently performed a zero downtime Postgres upgrade at Knock. This blog post goes into details about the Postgres considerations, although the BEAM & Elixir ecosystem were invaluable in managing the cutover process.
Some Elixir-related bits:
- We used
DynamicSupervisorto start/stop Oban during the cutover. Without going into too much detail, Oban needs aNotifierto coordinate global state, and we rely on the default Postgres notifier (Although there is a new PubSub notifier that we have our eyes on). This Notifier establishes a persistent Postgres connection that is managed outside of your Ecto Repo, and the easiest way to move Oban over to the new instance was to stop and restart it with a new configuration usingDynamicSupervisor - Metaprogramming made it easier to build facade interfaces to our Ecto Repos so that database requests could be routed to the old or new database instance, based on the state of a launch darkly flag. Internally, LD uses ETS and a persistent websocket connection, which helps lookups be fast and up to date. ETS is still not quite fast enough for the volume of DB queries in our system, and so we also used
:persistent_termto set the flag that determined what state we were in during the cutover process. Benchee helped us verify that we weren’t going to have a performance regression. - We looked at Ecto Repo’s
get_dynamic_repofunction, but determined that using a facade was a better fit for our use case. It’s worth knowing what’s available, though, since Ecto comes with a lot of extensibility out of the box. - The concurrency model of the BEAM makes it so much easier to reason about all of the stuff involved in a migration like this. Although you can take a similar approach with most languages, the BEAM didn’t get in the way of reasoning through the specifics of the cutover, especially around how we maintain uptime and data consistency during a cutover like this.
We may do a full post on the BEAM-related details of this upgrade in the future.
Popular Backend topics
Part 1: Introduction to Postgrest.
In Codd, we trust In the field of Computer Science and Engineering, few things come close to the dura...
New
What’s Next for Teal, the typed dialect of Lua - FOSDEM 2021.
This is my talk about the latest updates on the Teal programming language,...
New
The perspective of an ignorant computer science undergrad
It’s likely that you read the title of this post and thought “what is this guy ...
New
Erlang is famous for its introspecting powers. You can get a lot of information about the processes running in your nodes without any ext...
New
Todos coñecemos os focos de Erlang/Elixir máis renomeados do mundo, como a Suecia, o Brasil, a California ou Londres. Mais a comunidade, ...
New
I describe how we use Hot Reloading with Webpack to develop faster and show how to integrate Webpack 5, webpack-dev-server, and Phoenix f...
New
Mark Hoffman, the author of Programming WebAssembly in Rust, is a pretty hilarious lecturer if you like a dry sense of humor.
New
In episode 81 of Thinking Elixir, we talk with Digit and Quinn Wilton about the Burrito project. It wraps up Elixir to a single binary, e...
New
Ruby’s Struct is one of several powerful core classes which is often overlooked and under utilized compared to the more popular Hash clas...
New
In building lofi.limo, media storage and distribution naturally came up. I have songs, announcements, and background image loops which I ...
New
Other popular topics
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness.
https://f...
New
No chair. I have a standing desk.
This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face:
https://on...
New
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
New
Create efficient, elegant software tests in pytest, Python's most powerful testing framework.
Brian Okken @brianokken
Edited by Kat...
New
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol:
bre...
New
Author Spotlight
Erin Dees
@undees
Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
Big O Notation can make your code faster by orders of magnitude. Get the hands-on info you need to master data structures and algorithms ...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /rails
- /js
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /emacs
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /crystal
- /c-plus-plus
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /zig
- /deepseek
- /scala
- /sublime-text
- /textmate
- /lisp
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /django
- /deno
- /revery
- /ubuntu
- /spring
- /manjaro
- /nodejs
- /diversity
- /lua
- /julia
- /c
- /slackware







