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
Apparently he decided to live-stream how he’s going to create a semver library.
New
New
New
Understanding Partial Moves in Rust.
Partial moves are an interesting but often misunderstood feature of Rust. However, with the right ...
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
Post on using UDP multicasting with Elixir to broadcast presence, and listen for peers, on a local network. I have found this approach us...
New
Functional programming is an increasing popular programming paradigm with many languages building or already supporting it. Go already su...
New
We take a deeper dive with Nathan Long into IOLists in Elixir. We cover what they are, how they work, the power they have when concatenat...
New
In a 2 day spike, I created my own Elixir-based AI Personal Fitness Trainer! The surprising part for me was how useful and helpful I foun...
New
Hi folks! Ukrainian Erlanger is here :sign_of_the_horns:!
I’d like to share my recent talk at the TADSummit Online Conference, where I ...
New
Other popular topics
Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New
Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! In just a couple of weeks, build a ray tracer that r...
New
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
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
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
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
Biggest jackpot ever apparently! :upside_down_face:
I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
The File System Access API with Origin Private File System.
WebKit supports new API that makes it possible for web apps to create, open,...
New
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /flutter
- /elm
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /deepseek
- /zig
- /scala
- /sublime-text
- /textmate
- /lisp
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /deno
- /django
- /ubuntu
- /revery
- /manjaro
- /spring
- /nodejs
- /diversity
- /lua
- /julia
- /slackware
- /c







