Sizing Your Bitcoin Node's dbcache to Cut Initial Block Download Time
Bottom line: dbcache buys you real time on initial block download up to roughly the point where your node’s total memory footprint approaches physical RAM, after which each extra gigabyte is paid for in swap I/O and can make the sync slower than a more modest setting.
The UTXO cache is the single biggest lever on initial block download (IBD) time in Bitcoin Core, and it is also the easiest one to overshoot. Bitcoin Core will happily accept -dbcache=8000 on a 16 GB box and then spend the back half of the sync thrashing. The number that matters is not the dbcache value in isolation — it is the headroom left after the process baseline, the mempool, thread stacks, and the memory-mapped block files. This post walks through what I measured across -dbcache settings from 450 MB to 8 GB on one machine, where the curve flattens, and how to tell the difference between a node that is validating and a node that is swapping.
Not investment advice. This describes how the mechanism works and what the operational risks are. It does not tell you what to buy. See the editorial policy.
What dbcache actually controls
-dbcache=<n> sets the size of the UTXO database cache in MiB (the unit is 1024-based). It defaults to 1024 MiB, or 450 MiB if the system is detected as having less than 4096 MiB of RAM. The minimum accepted value is 4.
During IBD, bitcoind is writing hundreds of millions of unspent transaction outputs into the chainstate. With a small cache, those writes are flushed to the LevelDB-backed chainstate on disk far more often, and the flush path is where the time goes. A larger cache keeps more of the dirty UTXO set resident and batches the flushes. That is the entire mechanism — it is a write-batching and read-locality optimisation, not a magic accelerator.
Two things follow from that. First, dbcache only helps while the UTXO set is still being built, which is exactly the IBD window. After sync the effect is much less pronounced unless fast block validation matters to you, for example if you mine. Second, the returns are not linear: each doubling of the cache reduces the number of flush cycles by a smaller relative fraction.
The mempool competes for the same memory. The unused portion of -maxmempool (default 300 MB) is shared with the UTXO cache, so a node that is already tight on RAM should trim the mempool rather than fight the cache.
The test rig and method
One machine, deliberately unremarkable, because most people running a node are not running it on a datacentre box:
- 8-core x86-64, 32 GB RAM, NVMe SSD with a SATA fallback I tested separately
- Bitcoin Core built from a recent release branch, default
-par(cores minus one) - Fresh datadir per run, no assumeutxo snapshot, no
-blocksonly - Sync timed from process start to the point where
getblockchaininforeportedinitialblockdownload: false vmstat 5andiostat -x 5captured throughout to catch swap-in/out and disk saturation
Each configuration was run from a clean datadir. Network conditions vary between runs, so I treated anything under about 5% as noise and only drew conclusions from differences larger than that.
Where the time actually goes
Approximate wall-clock IBD times on that hardware, with peer count held constant. Treat these as the shape of the curve, not as absolute figures you can transplant to your own box — your peer set and bandwidth will move everything.
-dbcache (MiB) |
Peak RSS observed | Swap used | Relative IBD time | Notes |
|---|---|---|---|---|
| 450 | ~1.1 GB | none | baseline (slowest) | default on <4 GiB systems |
| 1024 | ~1.7 GB | none | ~0.75× | stock default on normal hardware |
| 2048 | ~2.8 GB | none | ~0.6× | clear win, still comfortable |
| 4096 | ~5.0 GB | none | ~0.5× | good on 16 GB hosts |
| 6144 | ~7.1 GB | none | ~0.47× | diminishing returns set in |
| 8192 | ~9.3 GB | intermittent | ~0.52× | only safe with lots of headroom |
The interesting part is the last two rows. Going from 4 GB to 6 GB bought a small but real improvement. Going from 6 GB to 8 GB, on a host where other services were also resident, produced enough memory pressure that the kernel started reclaiming and the sync got worse than the 6 GB run. That is the wall: not a property of Bitcoin Core, but of how much RAM you actually have free after everything else.
Peak RSS is consistently well above the dbcache setting. The chainstate cache is the largest single consumer but not the only one: the block index, the mempool, thread stacks (8 MiB per thread on 64-bit Linux by default), and memory-mapped block files all add up. Budget roughly 1.5–2× the dbcache value as the process footprint, then leave the rest of the machine alone.
The knobs that surround dbcache
dbcache does not operate in a vacuum. These are the settings I touched, and why.
1 | # /etc/bitcoin/bitcoin.conf |
-maxconnections only matters if you accept inbound connections; without inbound, the count stays at 11 or below (8 full-relay, 2 block-relay-only, occasionally a short-lived feeler). Each connection costs memory, so a node in a tight RAM budget should cap inbound peers.
-par defaults to cores minus one. Each script-verification thread reserves an 8 MiB stack on 64-bit Linux (4 MiB on 32-bit). On a 64-core machine that is not trivial, though it is small next to dbcache.
-prevoutfetchthreads defaults to 8 and -rpcthreads to 16. Leave them unless you have a reason.
-blocksonly drops default memory usage to about 5 MB for the mempool but opts the node out of receiving and relaying transactions except from peers with relay permission and from blocks. Do not use it if you broadcast transactions from this node: your transactions stand out, which hurts privacy. If you do combine it with a wallet, pair it with -walletbroadcast=0 and -spendzeroconfchange=0 and broadcast through another path.
On glibc systems, excessive arena allocation can inflate memory in some scenarios. Wrapping the daemon to set MALLOC_ARENA_MAX=1 is the documented workaround:
1 |
|
Bitcoin Core does very little parallel allocation, so the performance cost is expected to be small or absent. I did not measure a difference worth reporting.
Running the benchmark yourself
The commands below are what I actually used. Start with a clean datadir so you are measuring IBD, not a resumed sync.
1 | # Fresh start, 4 GiB cache, log to a file we can inspect later |
The vmstat filter prints the header and any interval where swap-in (si) or swap-out (so) is non-zero. If that line appears during sync, your dbcache is too large for the machine, full stop. Bitcoin Core may also warn at startup when -dbcache looks too large for the detected system memory; do not dismiss that warning.
When the run finishes, the elapsed time is simply the difference between the process start timestamp and the moment initialblockdownload flipped to false. Compare runs only on the same hardware, the same peer count, and ideally the same day.
Pitfalls and how to diagnose them
Sustained swap I/O during sync. The documented symptom of over-sized dbcache. Diagnose with vmstat 5; a nonzero si/so that persists across several intervals means thrashing, and bitcoind can slow to a crawl. Restart with a lower -dbcache. If that is not enough, also reduce -maxmempool or -maxconnections, or switch to -blocksonly.
Peak RSS higher than expected. ps -o rss= -p $(pidof bitcoind) gives the resident size. If it is far above your dbcache setting, count the other consumers: mempool, thread stacks, block index, mmapped files. On a host running a web server or a database alongside the node, the free memory is what matters, not total RAM.
The SSD is saturated, not the CPU. iostat -x 5 showing %util near 100 with high write latency during sync suggests the flush path is the bottleneck — which is the case where more dbcache helps. If %util is low and CPU is pegged, more cache will not help; you are script-verification bound, and -par is the lever.
A setting that seemed fine at startup degrades later. Memory pressure tends to appear as the UTXO set grows, not at launch. A node that survived the first hour at 8 GB may start swapping at hour ten. Watch the whole run, not the first few minutes.
Config changes that do not take effect. Changes to bitcoin.conf only apply after restarting bitcoind. Command-line options override the config file, and settings in settings.json override the config file too — so a value you edited in the file may be silently outranked.
Memory creeping after sync. Post-IBD, the chainstate cache is less of a factor, but glibc arena behaviour and fragmentation can still inflate RSS over weeks. If you are running near the edge, the MALLOC_ARENA_MAX=1 wrapper is the first thing to try.
FAQ
What is a sensible dbcache for a 16 GB machine running only bitcoind?
4096 MiB leaves comfortable headroom on a 16 GB box. My measurements showed peak RSS around 5 GB at that setting, which leaves more than 10 GB for the OS and page cache. Going to 6144 MiB was still safe but bought very little extra time.
Does a bigger dbcache help after the initial sync is done?
Much less than during IBD. The documented behaviour is that a lower dbcache makes initial sync time much longer, but the effect is less pronounced for most post-sync use cases — unless fast block validation matters, such as for mining.
Why does my node use more RAM than the dbcache value I set?
Because dbcache is one cache among several. The mempool (default 300 MB, shared with the UTXO cache), thread stacks, the block index, and memory-mapped block files all contribute. Peak RSS of roughly 1.5–2× the dbcache value is normal in my runs.
Should I use -blocksonly to save memory during sync?
It will cut default mempool memory to about 5 MB and reduce overall usage, but it opts the node out of receiving and relaying transactions except from permitted peers and blocks. If you broadcast from this node, your transactions stand out and privacy suffers; the documented mitigation is to combine it with -walletbroadcast=0 and -spendzeroconfchange=0 and broadcast elsewhere.
Can I just set dbcache to 8 GB if I have 32 GB of RAM?
You can, and on a dedicated host with nothing else resident it may help slightly. On my test machine the 8 GB run was slower than the 6 GB run once other services were present, because swap kicked in. Measure your free memory, not your installed memory.
How do I know whether I am swapping or just disk-bound?
vmstat 5 shows swap-in and swap-out directly; persistent nonzero values mean thrashing and a too-large cache. iostat -x 5 distinguishes a saturated disk from an idle one. High %util with high write latency points at the flush path, which is where a larger dbcache earns its keep; low %util with pegged CPU points at script verification instead.










