TESTBED REPRODUCIBILITY NOTICE: All benchmark metrics in this publication were physically executed and measured within isolated Linux containers constrained strictly to 1 vCPU / 1 GB RAM and 2 vCPU / 2 GB RAM. Test scripts utilize native synchronous V8 engine bindings over synthetic 20,000-write and 100,000-read workloads.
Pushing Embedded SQLite to the Physical Edge: Zero-Network Storage under Strict Memory Caps
Abstract
“Modern web architectures habitually deploy dedicated multi-tenant database clusters (such as PostgreSQL or MySQL) even for micro-applications and edge services. This introduces an unavoidable network latency penalty (1–3 ms per query round-trip), connection pool connection exhaustion, and substantial idle memory consumption. In this paper, we explore the physical throughput and latency bounds of embedded SQLite running directly inside the application memory space under strict resource constraints (1–2 vCPUs, 1–2 GB RAM). By configuring Write-Ahead Logging (WAL), memory-mapped I/O (mmap), exclusive thread locking, and in-memory temporary tables, we measure write throughput scaling from 30,712 ops/sec (standard journal) to over 207,936 ops/sec (in-memory) and 122,264 reads/sec (WAL+MMAP). Median read latency drops to 3.2 microseconds—a 76.8% reduction compared to standard disk journal operations.”
The Fallacy of Default Multi-Tier Databases
For small-to-medium cloud workloads and edge nodes, external relational databases incur disproportionate networking and serialization costs. Transmitting serialized JSON/SQL packets over local loopback interfaces wastes CPU cycles that could otherwise perform direct memory fetches.
- A.1Network Traversal is the Bottleneck: A 1ms TCP round-trip is equivalent to over 3 million CPU clock cycles on modern silicon.
- A.2Single-Tenant Embedded Purity: In-process database engines eliminate context switching between kernel sockets and user application memory.
- A.3Zero-Copy Memory Mapping: Utilizing the kernel page cache via mmap() delivers higher throughput than userspace database buffer managers.
I/O Latency Bound Formulation
The query latency function T_query is modeled as a sum of memory bus traversal and serialization delay, without network socket queueing.
T_{embedded} = T_{B-tree\,seek} + \tau_{mmap\,page} + \frac{L_{record}}{B_{memory\,bus}} \ll T_{TCP} + T_{context\,switch} + T_{DBMS}Where mmap page retrieval operates directly in L2/L3 CPU cache lines without context switches or TCP socket serialization.
Comparative Performance Metrics
Measured on physical testbeds under two strictly isolated containerized tiers: Tier 1 (1 vCPU, 1 GB RAM) vs Tier 2 (2 vCPU, 2 GB RAM). Workload: 20,000 indexed transaction writes in batches of 2,000, followed by 100,000 random key-value lookups.
| Configuration / Mode | Environment | Write Throughput | Read Throughput | p50 Latency | p95 Latency | p99 Latency | Peak RSS |
|---|---|---|---|---|---|---|---|
| Standard Disk (DELETE Journal) | 1 vCPU / 1 GB | 35,686 ops/s | 29,256 ops/s | 13.8 µs | 34.0 µs | 225.0 µs | 74.5 MB |
| Standard Disk (DELETE Journal) | 2 vCPU / 2 GB | 30,712 ops/s | 35,015 ops/s | 13.4 µs | 28.4 µs | 192.9 µs | 74.1 MB |
| Standard WAL Mode | 1 vCPU / 1 GB | 67,656 ops/s | 52,679 ops/s | 5.5 µs | 13.0 µs | 116.4 µs | 81.1 MB |
| Standard WAL Mode | 2 vCPU / 2 GB | 111,131 ops/s | 72,835 ops/s | 5.3 µs | 11.8 µs | 24.3 µs | 80.6 MB |
| Leviora Extreme (WAL + MMAP 512MB + EXCLUSIVE) | 1 vCPU / 1 GB | 52,719 ops/s | 114,949 ops/s | 3.2 µs | 4.8 µs | 11.6 µs | 86.2 MB |
| Leviora Extreme (WAL + MMAP 512MB + EXCLUSIVE) | 2 vCPU / 2 GB | 47,555 ops/s | 122,264 ops/s | 3.6 µs | 5.7 µs | 34.1 µs | 84.5 MB |
| In-Memory Mode (:memory:) | 1 vCPU / 1 GB | 87,474 ops/s | 182,077 ops/s | 3.0 µs | 5.0 µs | 22.8 µs | 86.2 MB |
| In-Memory Mode (:memory:) | 2 vCPU / 2 GB | 207,936 ops/s | 261,673 ops/s | 3.3 µs | 5.4 µs | 14.8 µs | 84.6 MB |
All measurements are empirical averages across full 120,000 operations. Leviora Extreme configuration enables zero-copy reads, keeping p50 latency under 3.6 microseconds.
Zero-Network Storage Optimization Pipeline
Direct Memory-Mapped Pages
PRAGMA mmap_size directs the operating system to map database file pages directly into process virtual memory, eliminating buffer copy calls.
Non-Blocking WAL Ring Log
Writers append sequentially to the write-ahead log without blocking readers, achieving high concurrent throughput.
Exclusive Lock Single-Tenancy
Disabling multi-process POSIX advisory locking reduces system call overhead to near-zero for high-speed microservices.
import { DatabaseSync } from "node:sqlite";
export function createOptimizedStorage(dbPath) {
const db = new DatabaseSync(dbPath);
// Subtractive Performance Pragmas
db.exec("PRAGMA page_size = 4096;");
db.exec("PRAGMA journal_mode = WAL;");
db.exec("PRAGMA synchronous = NORMAL;");
db.exec("PRAGMA locking_mode = EXCLUSIVE;");
db.exec("PRAGMA cache_size = -131072;"); // 128 MB RAM Cache
db.exec("PRAGMA mmap_size = 536870912;"); // 512 MB Memory-Mapped I/O
db.exec("PRAGMA temp_store = MEMORY;");
return db;
}Zero-Network Storage Docker Reproduction Harness
Runs entirely inside an ephemeral, network-isolated container. Evaluates 20,000 batch writes and 100,000 indexed random lookups with sub-microsecond precision.
docker run --rm -it --network=none --cpus=1.0 --memory=1g node:22-trixie-slim- 1Spawns an isolated container with Linux cgroups v2 limits: 1 vCPU, 1 GB RAM, zero network interface.
- 2Initializes synchronous in-process SQLite with WAL mode, 512MB memory-mapped I/O (mmap_size=536870912), and EXCLUSIVE thread locking.
- 3Executes 20,000 indexed transactions in batches of 2,000, followed by 100,000 random key-value lookups.
- 4Calculates exact p50, p95, and p99 latency percentiles using process.hrtime.bigint().
Conclusions & Open Inquiries
- →In-process embedded databases deliver 10x to 50x lower latency than network-attached database servers for single-node services.
- →With mmap and WAL optimizations, a single 2 vCPU VPS can comfortably sustain over 120,000 read queries per second under 85 MB RAM usage.
Other Active Working Theses
High-Density Process Sandboxing: Running 100+ Isolated Task Workers on a 1GB VPS
By clamping V8 isolate heap limits and utilizing lightweight Worker Threads instead of full-process forks, task density increases 4.25x (from 24 to over 102 concurrent workers) on an entry-level 1 GB VPS, lowering memory footprint from 38.5MB to 8.85MB per worker.
Resilient Traffic Shedding: Token-Bucket Gatekeeping Under Single-Core CPU Saturation
Deploying a lightweight token-bucket traffic shedder at the application threshold reduces p99 request latency by 48.8% (from 40.9ms to 20.9ms) and increases overall query throughput by 47% under sustained synthetic burst flooding.
