João Freitas

The following is a retrospective on the current shift of applications using serverless/edge computing models and finding databases that support their programming/computing model. The author goes on to detail the state-of-the-art of databases used in serverless applications, but also traditional databases that are adopting this model.

https://leerob.io/blog/backend


There’s been massive innovation in the database and backend space for developers building applications with serverless and edge compute. There are new tools, companies, and even programming models that simplify how developers store data.

This post will be an overview of databases that pair well with modern application and compute providers.

Criteria

I’ll focus on transactional¹ workloads instead of analytical² workloads.

The “backend” space is vast: search, analytics, data science, and more – so I’ll niche down here. The primary criteria of this overview is:

  1. Services that work exceptionally well when paired with serverless and edge compute
  2. Services that work with JavaScript and TypeScript codebases

Disclaimer: I work at Vercel, which partners with companies in this post. I also have personally used many of these tools for my own personal projects. My site currently uses PlanetScale and I’m also an angel investor in Supabase (mentioned below).

A new programming model

Relational databases have been around for 25+ years.

While there are new companies creating serverless-first storage solutions, a new programming model is required for workloads to be compatible with serverless compute and modern runtimes.

These solutions must be:

Consider databases like Postgres. New solutions like Neon and Supabase abstract connection management, providing you with a simple way to query and mutate data. In the case of Supabase, there’s a client library that uses an HTTP API built on PostgREST:

    import { createClient } from '@supabase/supabase-js';
    let supabase = createClient('https://<project>.supabase.co', '<your-anon-key>');
    let { data } = await supabase.from('countries').select();

And for Neon:

    import { Client } from '@neondatabase/serverless';
    let client = new Client(env.DATABASE_URL);
    let {
      rows: [{ now }],
    } = await client.query('select now();');

Neon’s solution is particularly interesting.

The basic premise is simple: our driver redirects the PostgreSQL wire protocol via a special proxy. Our driver connects from the edge function to the proxy over a WebSocket, telling the proxy which database host and port it wants to reach. The proxy opens a TCP connection to that host and port and relays traffic in both directions.

Neon architecture diagram for connection pooling

💡

Using WebSockets, instead of HTTP, does have tradeoffs. There might be additional latency on the first request setup, but subsequent requests are faster. There’s an RFC for WebSockets with HTTP/3 which would remove that extra network roundtrip.

The connection management isn’t going away – it’s just being handled by the vendor now.

There’s even solutions like PlanetScale which can handle up to a million connections, which also allows you to effectively never think about managing connections.

Trends

This new programming model has created emerging trends for database companies:

Databases

I’ll bucket these into “established” and “rising” categories, serverless/serverful, as well as generally available (GA) and pre-GA. I’ll also mostly talk about managed vendors.

For example, you can of course run MySQL or Postgres on major cloud providers like AWS. There’s a long tail of niche data storage solutions, so some will definitely be missing that I haven’t heard of or used.

Established serverless solutions

Rising serverless database solutions

Stateful backends and other solutions


¹ Commonly referred to as OLTP (Online Transactional Processing). These are for CRUD operations, most commonly the MySQL and Postgres databases of the world.

² Commonly referred to as OLAP (Online Analytical Processing). These are for your real-time data workloads, like Clickhouse (also Tinybird), SingleStore, TimeScale, and ElasticSearch.

Thanks to Guillermo Rauch, Paul Copplestone, Fredrik Björk, Anthony Shew, Craig Kerstiens, Jamie Turner, Nikita Shamgunov, Yoko Li, Pratyush Choudhury, Stas Kelvich, Enes Akar, and Steven Tey for reviewing this post.

#reads #lee robinson #serverless #edge computing #database