Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hardware

A small site runs on a VPS with 1 GB of memory and two cores: Docker Compose’s tiny setup is tuned for that, and CI runs the end-to-end tests on every change with the stack limited to it. More memory mostly buys a bigger database cache, which matters once the database outgrows it. The tagger needs about 1 GB more; its page has its numbers.

Numbers marked measured come from moekura admin bench-http and admin bench (see Scaling) against the tiny stack, with the app and PostgreSQL containers limited to 384 MB and 512 MB of memory and one core each, on an AMD Ryzen 7 7800X3D with an NVMe SSD. The posts were generated by admin seed, with comments, notes, pools and favorites, but no files.

Memory

Measured:

Right after startAfter the e2e tests1,000,000 posts, after a burst of requests
moekura serve (web and jobs)25 MB68 MB68 MB
PostgreSQL (the compose settings)54 MB83 MB250 MB

moekura serve stays under 150 MB; CI fails if it doesn’t. PostgreSQL grows to its shared_buffers (128 MB in the compose file) plus what its connections use. Making thumbnails runs vips and ffmpeg for a moment per upload, which for large images and videos takes some more.

That leaves about 150 MB of a 1 GB machine for the system and for the operating system’s file cache. Adding swap is a cheap safety net.

Speed

Measured, p95 in milliseconds for one request at a time:

Posts (database size)Pages and APIsSearches
100,000 (240 MB)under 4not measured
1,000,000 (2.1 GB)under 6mostly under 60

With the database four times the memory, most searches stay fast, but the few that read many posts do not: a common word in notes (note:) takes about 0.9 s, a user’s saved searches (search:all) 0.4 s, a file type with a common tag 0.25 s, and pool:any and tagger suggestions (ai:) about 0.1 s. For a site that size, 2–4 GB of memory should keep the database cached and bring those back under 100 ms, as they are for 5,000,000 posts on a large machine on the Scaling page (estimated).

Seeding shows what writing costs: about 2,500 posts a second on two cores, database work only.

Disk

  • Database: about 2 KB per post measured, with a site’s worth of tags, comments, notes and tagger suggestions (2.1 GB for 1,000,000 posts).
  • Files: the originals, plus thumbnails and, for large images, a sample; estimated at 20–30% on top of the originals, depending on media.thumbnail_sizes and media.sample_size.
  • Images: about 180 MB for Moekura’s and 300 MB for PostgreSQL’s.

An SSD matters more than cores: searches that miss the cache read pages from disk at random.

Raspberry Pi 4

Estimated, not measured: a Raspberry Pi 4 with 2 GB or more should run the tiny setup (the images are built for arm64), its cores being a few times slower than a desktop’s. Expect pages several times slower than above, still well under a second for a small site. Keep the database on an SSD over USB 3 rather than the SD card, which is slow at random reads and wears out. If you run one, moekura admin bench-http measures it.