C.W.K.
Stream
Lesson 03 of 10 · published

Serverless Means No Daemon

~12 min · sqlite, architecture, in-process

Level 0Scout
0 XP0/80 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

The cloud word collision

When SQLite calls itself serverless, it means something different from what AWS Lambda or Cloudflare Workers mean. There is literally no server process. No background daemon, no socket to connect to, no network protocol to speak.

Instead, SQLite is a library your application links against. When your app calls SQLite functions, the library reads and writes files on disk directly. The database engine runs inside your application's process — sharing the app's memory, CPU, and file descriptors.

The implications are profound:

  • Zero latency overhead — no network round-trip. A primary-key SELECT takes ~0.01 ms from a local file. Compare ~1–10 ms for Postgres over TCP, even on localhost.
  • No connection pooling — no PgBouncer, no max_connections, no connection-leak bugs.
  • No authentication layer — access is governed by file system permissions, not SQL GRANTs.
  • No deployment — ship a binary, the database engine ships with it.
Tip: Because SQLite runs in-process it is ideal for edge compute, embedded systems, mobile apps, CLI tools, and Cloudflare Workers / Fly Machines style serverless functions where you cannot rely on a persistent network DB connection.

The flip side is also true: if you need ten different web servers all writing to the same logical database concurrently from different machines, SQLite is the wrong tool. The 'no network protocol' property cuts both ways.

Code

Latency comparison — local SQLite vs local Postgres·python
import sqlite3, time

# SQLite: open is essentially free, query is a function call
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t(id INTEGER PRIMARY KEY, v TEXT)')
conn.execute('INSERT INTO t VALUES (1, "hello")')

start = time.perf_counter_ns()
for _ in range(10000):
    conn.execute('SELECT v FROM t WHERE id = 1').fetchone()
elapsed_us = (time.perf_counter_ns() - start) / 10000 / 1000
print(f'SQLite per query: {elapsed_us:.2f} µs')
# SQLite per query: ~3–10 µs

External links

Exercise

List three product scenarios where SQLite's in-process model is a clear win, and three where it actively hurts. For each, name the specific property (no network, no auth layer, file-system permissions, single writer, etc.) that drives the call.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.