Leanpub Header

Skip to main content

Zero Backend: Scale the Product, Not the Cloud Bill

Zero Backend: Scale the Product, Not the Cloud Bill
This book is 100% completeLast updated on 2026-11-24

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

EPUB
About

About

About the Book

The bill nobody can explain

A studio ships a feature: a user uploads a phone video, and the product returns a short clip ready to share. Four months later the cloud invoice has a line nobody can explain: data transfer out, four figures a month, growing faster than the number of users. The answer is already in the room and nobody says it, because it sounds like a joke: the file is on the user’s phone, the phone has four cores, and the browser tab runs JavaScript that the engine compiles to machine code. The server is there because a decade of tutorials put it there, not because the job needs it.

The book takes that invoice apart. The job is one 120 MB video from a phone, and the server does three small things with it: it makes a thumbnail (a small preview image), reads the duration, and computes a checksum (a fingerprint of the file, used to detect changes). In the book’s priced example, 79.3% of what that job costs is egress: the bytes the server sends back to the user, which every cloud provider bills by the gigabyte. The same three things run in the page. The browser asks for byte ranges — small slices of the file — instead of the whole video, decodes them as they arrive, and sends nothing back.

 

What the book does

Twenty chapters, one job each, moved from a server into the browser: the program already installed on the user’s phone or laptop. The browser runs JavaScript, and it also runs WebAssembly, a binary format that lets a program written in another language execute at close to native speed. A video is decoded without being downloaded, a photo is converted without being uploaded, a database and a small language model run inside the page.

The argument is not that servers are useless. It is that the server is a default nobody priced. Every chapter measures its job, saves the measurement in a file, and ships the program that reproduces it. The last chapter checks all twenty claims against those files, so a reader can clone the code and see whether the book is telling the truth.

 

Why it costs less

The saving is not a slogan; it is four lines on a cloud invoice, and each one shrinks:

  • The bytes that leave. For the studio’s 120 MB video, egress is 79.3% of the bill for that one job. A page that asks for byte ranges, small slices of the file, instead of the whole video sends nothing back, and that line goes to zero.
  • The memory you rent. Serverless computing is billed in GB-seconds: the memory a function holds multiplied by the time it runs. Hashing a 1 GB file in one go needs the whole gigabyte in memory; reading it in 64 MB slices needs 76 MB instead of 1,023 MB — 92.6% less — and produces the same fingerprint (a SHA-256 digest).
  • The bytes you scan and ship. The book’s analytics chapter generates one million events, groups them by kind, and writes the result twice: 2.4 MB as Parquet, a file format that stores each column separately so a query reads only the columns it needs, against 23.3 MB as CSV. That is 89.6% fewer bytes to store, scan and transfer.
  • The waits you remove. The notes application in the book holds 1,000 notes in a real database inside the page and answers a search in 16.2 ms. A share link is verified in 2.68 ms with no request to an authentication service. Four background threads keep the longest gap between screen updates — the frame — at 42 ms instead of 220, and a page that waits 220 ms feels frozen.

What does not move, the book names and refuses: a 6 GB file in one piece, a text two people edited in the same sentence, a format another application has to read. Every chapter has a section on what its approach cannot do, with the fallback beside it.

 

What a chapter contains

Each chapter is a small, complete project:

  • the theory, in ten short sections, with the vocabulary defined before it is used;
  • a basic example and an advanced example, both runnable;
  • five exercises, each a defect to find and fix, with complete solutions;
  • a harness, a program that runs the chapter’s code and fails when the result is wrong;
  • a record, a folder with the numbers the run produced, the machine, the versions, the browser log and a screenshot.

The book uses no framework, no build system beyond a shell script, and no service to sign up for. The code is TypeScript run directly by Node, the program that executes JavaScript outside the browser; the pages are served by a small local server.

 

Who it is for

A web developer who has shipped a TypeScript application and has never had a reason to learn what a byte range is, how a page can save a file without opening a file picker (the origin private file system), or what a WebAssembly heap is. The book assumes TypeScript, a terminal, and the patience to read a measurement table. It does not assume browser internals, graphics programming, cryptography or machine learning.

To run the code you need Node 24 or later, a browser built on Chromium (Chrome or Edge; the book was measured on Chrome 157), about 8 GB of RAM, and no account anywhere.

 

The ten programs people remember

  • The studio’s reel (chapter 1). One 120 MB phone video, three server jobs: a preview image, the duration, a fingerprint. The page asks for byte ranges instead of the file, decodes them as they arrive, and seeks without a full download. In the priced example egress is 79.3% of the job’s bill; here the page sends nothing.
  • The two-second clip (chapter 4). A 320×180 sample clip, re-encoded to 160 pixels wide at quality 30. FFmpeg, the open-source video tool most pipelines run on a server, compiled to WebAssembly, does it in the page in 122–240 ms, with a 32 MB engine loaded in 149 ms.
  • The two photos (chapter 6). A cover in HEIC, the format iPhones write and browsers do not decode natively, and the same cover as JPEG, both converted to 320-pixel WebP at quality 0.8. HEIC decodes in 14.5 ms warm and 68.9 ms cold; 6,190 bytes become 4,436, and the metadata is stripped (the camera, date and location the phone wrote into the photo).
  • The gigabyte (chapter 8). A 1 GB file is hashed in 64 MB slices instead of being read whole: 76 MB of memory instead of 1,023, 92.6% less, with the same SHA-256 fingerprint.
  • The notes application (chapter 9). A thousand notes with tags, in PostgreSQL — the SQL database many products rent as a managed service — compiled to WebAssembly and running in the page. Migrations (schema changes), transactions (all-or-nothing writes), a first open in 1,647 ms, a search in 16.2 ms, and the rows survive the tab closing.
  • The million events (chapter 10). One million generated events in seven kinds, grouped and totalled in the page with DuckDB, an analytics database, and written as Parquet: 2.4 MB against 23.3 MB as CSV.
  • The forty notes (chapter 11). Forty notes in four subjects, eight questions. An embedding is a list of numbers that captures what a text means; computed on the device, the search finds 70% of the right subject in the top five where keywords find 37.5%, and the vectors are 15 KB instead of 61.
  • The model in a worker (chapter 12). A language model is a file of numbers. This one is 23.7 MB; loaded on the page’s main thread it freezes the interface, moved to a background thread it is ready in 862 ms and the longest frame is 16.7 ms instead of 215.
  • The share link (chapter 14). A capability is a permission written as data and signed: here read:own and write:own, in a 358-character token. Put it in the fragment of a URL — the part after #, which browsers never send to a server — and it verifies in 2.68 ms with no request. A forged token that widens the scope is refused.
  • The notes app as one file (chapter 16). The same notes application — storage, search, merge — compiled into one HTML file of 14,376 bytes, 14% of a 100 KB budget, with three modules and no framework.

 

Also in the book

The export: one HTML file carrying twelve notes, their permission and the reader that checks them, 6,097 bytes, openable in ten years without the application that wrote it. The merge: two devices editing the same three notes, one conflict, a 729-byte state, a merge in 0.10 ms, and a named limit — when two people edit the same sentence, the merge keeps one. The calendar: a Wednesday meeting at 09:00 that stays at 09:00 across the daylight-saving change, exported as 511 bytes of .ics, the calendar file format other applications read. The support report: 369 bytes built from named fields, so it cannot contain a note. The thread pool: six 4 MB buffers hashed in four threads, 45 ms of work and a 42 ms longest frame, against 220 ms of freeze.

 

How the book is organised

The twenty chapters form four parts. Each part answers one question a buyer is really asking, and each chapter inside it builds one piece you can run.

  • Chapters 1–8: can a page handle a large file? You show a 120 MB phone video without downloading it; ask the browser what it can do; save a file the page can reopen; convert video; cut and re-encode a clip; convert an iPhone photo; measure how loud an audio file is; and fingerprint a gigabyte without holding it in memory.
  • Chapters 9–12: can a page hold the data? You put a SQL database in the tab; group a million rows with an analytics engine; search notes by meaning with vectors computed on the device; and run a small language model in a background thread.
  • Chapters 13–16: can a page replace a service? You merge edits from two devices without a server; put a permission in a link; export one HTML file that checks itself; and pack the notes application into 14 KB.
  • Chapters 17–20: what happens after launch? You support a product with no server using a report that cannot leak a note; keep the page responsive with a pool of threads; keep a 09:00 meeting at 09:00 across the daylight-saving change; and decide, claim by claim, which jobs should leave the server.

The parts stand on their own: each chapter names the files it needs and closes with what it proved, so you can start with the part that matches the product you are building.

 

Twenty chapters, one claim each

  1. The Server You Are Still Paying For
  2. What This Browser Can Actually Do
  3. The Tab as a Filesystem and a Worker Pool
  4. FFmpeg in the Browser
  5. WebCodecs, or FFmpeg Without FFmpeg
  6. The Image Pipeline: HEIC, AVIF, and EXIF
  7. Audio: Waveforms, Loudness, and Silence
  8. Two Gigabytes in a Four-Gigabyte Box
  9. SQLite and PGlite: A Real Database in the Tab
  10. DuckDB-Wasm: Analytics on a Million Rows
  11. Embeddings on the Device: Search by Meaning
  12. The Model in the Page: 23 MB, One Worker, No Jank
  13. Two Devices, One Document: Merge Without a Server
  14. Permissions Without a Login: The Link Is the Key
  15. The Export Is the Product: One File That Verifies Itself
  16. The App That Fits on a Floppy
  17. The First Week of a Real User
  18. The Last Engine: A Worker Pool and Its Scheduler
  19. A Calendar That Syncs Two Files
  20. Deciding What Leaves the Server

 

The repository. All the code, the records and the exercises are in one repository: https://github.com/edgarmilvus/zero-backend. Clone it, run npm ci, and ./run_offline.sh runs every chapter's checks in about seventy-five seconds.

 

Chapter 1 is the only chapter that prices a whole bill — every line, not just the compute. It takes one job (a 120 MB phone video, a preview image, the duration, a fingerprint) and sets beside it the four lines a provider invoices: requests, compute time, the bytes sent out, and storage. The prices come from an AWS price list dated in the chapter and shipped as data, with its source and the day it was read, so every number can be traced and the list can be replaced when the provider changes it.

 

The other chapters do not invent prices. A bill depends on your contract, your region and your volume, so each chapter gives you the unit your provider charges for — gigabytes of egress, minutes of transcoding, GB-seconds of memory, instance-hours, terabytes scanned, tokens. Multiply those units by the rates on your own invoice and the same arithmetic applies.

 

If it were printed, this book would run past 600 pages.

Author

About the Author

Edgar Milvus

A veteran software engineer with 20 years of experience, I have dedicated my career to the art of automation. My philosophy is simple: programming should eliminate repetitive chores to unlock human creativity. This journey began early on with the development of custom code-generation tools and has evolved into a deep mastery of LLMs and their APIs. Today, I specialize in architecting AI-driven solutions that handle everything from complex coding and security tasks to advanced knowledge retrieval, transforming the way we interact with technology

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub