Snails vs Rails API benchmark with PostgreSQL
Spinel’s roughly 20× compute lead did not survive this Snails vs Rails API benchmark. On one x86-64 machine, Snails, a Rails-like API framework that Spinel compiles to one native binary, served 1.66× the requests of Rails + YJIT on a PostgreSQL read. On a 20-core ARM64 server the order reversed: 9,962 req/s for Snails, 13,757 for Rails + YJIT. Its clear advantages on x86-64 are memory and cold start.
- Throughput on x86-64: on the PostgreSQL read, 1.66× vs Rails + YJIT and 2.32× vs Rails + ZJIT. This run did not profile where the time goes, so it does not say why the 20× disappears.
- JSON echo: Snails reached 27,266–29,555 req/s against 24,638 for Rails + YJIT. Its three runs disagree by more than 5%, so read this as a small lead, not a ratio.
- Memory: 22 MiB against 562 MiB on the database route, about 25× less.
- Cold start: 8.5–9.9 ms across three runs, against 884 ms for Rails + YJIT. The Snails runs differ by more than 5%, but the gap is about two orders of magnitude.
- p99 did not reproduce. Only 1 of 6 p99 values agree across three runs, so the rest are shown raw and no p99 ranking is claimed.
Bold values passed the 5% check. Values marked † did not, so all three runs are shown and they should not be quoted as one number.
JSON echo benchmark
| Capacity req/s | p50 ms | p99 ms | |
|---|---|---|---|
| Snails | 29,555 27,266 28,141 † | 1.11 1.04 1.07 † | 10.64 4.91 8.54 † |
| Rails + YJIT | 24,638 | 1.26 | 3.70 6.91 33.18 † |
| Rails + ZJIT | 17,499 | 1.33 | 22.08 9.79 3.69 † |
PostgreSQL read benchmark
| Capacity req/s | p50 ms | p99 ms | |
|---|---|---|---|
| Snails | 31,827 | 1.18 | 2.86 2.76 3.16 † |
| Rails + YJIT | 19,176 | 1.49 1.38 1.40 † | 3.60 |
| Rails + ZJIT | 13,699 | 1.56 | 42.14 37.85 28.37 † |
Memory, cold start and size
| Peak, echo MiB | Peak, DB MiB | |
|---|---|---|
| Snails | 30.6 21.9 22.2 † | 22.2 |
| Rails + YJIT | 554.5 483.8 573.3 † | 561.8 |
| Rails + ZJIT | 449.8 535.6 450.6 † | 547.7 599.5 488.3 † |
| Cold start ms | Image MiB | |
|---|---|---|
| Snails | 9.9 9.8 8.5 † | 91 |
| Rails + YJIT | 884.0 | 308 |
| Rails + ZJIT | 905.3 | 308 |
Cold start is process launch to the first 200 from /up, inside the container, median of 5 starts per run. Image sizes are the x86-64 images. In a separate ARM64 smoke build, the Snails binary was about 4 MB.
What did not reproduce
Capacity agreed on 5 of 6 rows. p99 agreed on 1 of 6, with foreign CPU at 0.0% and no memory-pressure stalls recorded. The cause is unknown, which is why these runs are shown rather than averaged.
Latency is measured at 50% of capacity because of one single-pass calibration on the ARM64 server below (Rails + YJIT, database route, 4 workers × 5 threads, results/calibration-arm64.txt): p99 was 4.26 ms at 50% and 1,280 ms at 70%.
Results depend on the hardware
The same harness on a 20-core ARM64 server (results/run4.json), sharing the host with CI, with the server on Cortex-X925 cores and the database and load generator on Cortex-A725, reversed the order on the database route: Snails 9,962 req/s, Rails + YJIT 13,757. Both capacities agreed across three runs (spread 0.6% and 4.3%). Rails + YJIT’s p99 did not (3,961%), and 5 of that run’s 6 rows failed the full check. The 1.66× above should not be taken as portable. Measure on your own hardware.
FAQ
Is Snails faster than Rails?
On the PostgreSQL read on this x86-64 machine, yes: 1.66× Rails + YJIT and 2.32× Rails + ZJIT. On JSON echo its lead over Rails + YJIT is small and its three runs disagree. On the ARM64 server, Rails + YJIT was faster on the database route.
Does Spinel’s 20× speed-up survive in a web framework?
Not in this benchmark. The roughly 20× comes from CPU-bound programs on an ARM64 host. With HTTP and PostgreSQL in the path, Snails led Rails + YJIT by 1.66×.
How much less memory does Snails use than Rails?
On the database route, Snails peaked at 22.2 MiB and Rails + YJIT, with 4 Puma workers, at 561.8 MiB, about 25× more.
How fast does a Snails app start?
8.5–9.9 ms from process launch to the first response, against 884 ms for Rails + YJIT.
Is YJIT or ZJIT faster for a Rails API?
YJIT, in this benchmark: 1.40× ZJIT’s capacity on the PostgreSQL read and 1.41× on JSON echo.
Related
Method
| Snails | v1.2.1 (bed5b3e), Spinel 858dde41b, installer pinned by commit and SHA-256, PostgreSQL adapter, one process, one OS worker per core plus main, request logging off |
| Rails | 8.1.4.1 API on Ruby 4.0.9, Puma 8.0.2, 4 workers × 5 threads, preload_app!, jemalloc, bootsnap, request logging off |
| JIT | --yjit or --zjit, and the app refuses to boot if any other JIT is active |
| Database | PostgreSQL 15 over loopback TCP, 10,000 rows · 20 connections in total on both: one pool of 20 for Snails, 5 per Puma worker for Rails |
| Routes | POST /echo returns a 1 KiB JSON body · GET /items/:id reads a random row by primary key and returns five fields |
| Images | pinned by digest in the harness: ruby:4.0.9-slim-bookworm, postgres:15-bookworm, debian:12, debian:12-slim |
| Load | wrk2 at a pinned commit, with the source patches its ARM64 build needs applied on both architectures, 2 threads, 32 keep-alive connections |
| CPU | AMD Ryzen AI Max+ 395 (x86-64), one whole L3 group reserved: server on 4 cores, PostgreSQL on 2, wrk2 on 2, their SMT siblings idle |
| Isolation | every other process, kernel workqueues and 109 movable interrupts on the other L3 group (78 kernel-managed interrupts cannot move, log in results/x86-64-run1.reserve.log) · energy preference performance on the reserved cores · other services kept running, so memory bandwidth is shared |
| Method | 3 interleaved runs · 15 s warm-up → 20 s saturated for capacity → 120 s at 50% of that target’s own capacity for latency · a fresh server for each route |
| Validity | a value is a result only if its 3 runs agree within 5% (max − min over median) · foreign CPU on the reserved cores was 0.0% in every run · 0 socket errors, 0 non-2xx, 0 timeouts · responses byte-identical across targets |
Reproduce the benchmark
cd benchmarks/snails-vs-rails
export BENCH_SECRET_KEY_BASE=$(openssl rand -hex 32)
VENDOR_SHA=1ea5860cabe5be7b36f8eea3d7f844d1bc55e7e6 ./build.sh
docker build -t snails568-wrk2:bench wrk2
./parity.sh <app-port> <db-port>
./reserve.sh <benchmark-cpus> <other-cpus> 3900 -- python3 run.py \
--server-cpus <4 cores> --db-cpus <2 cores> --load-cpus <2 cores> --sibling-cpus <their SMT siblings> \
--app-port <app-port> --db-port <db-port> --load-fraction 0.5 --latency 120 --out results/my-run
The Rails app starts from the Snails project’s own benchmark (MIT), moved to PostgreSQL. Its published figures use SQLite and a different load generator, so they are not comparable with these.
The published run predates two harness changes. The base images and the Snails installer were pinned after it: the images to the digests then on the host, which the run itself did not record, and the installer to a commit whose file has the same checksum as the tag it used. The release of the reserved cores was also hardened. results/x86-64-run1.reserve.log is that run’s own log. Its results file and output label were renamed afterwards, with no measured value changed.