2025-11-26 12:53:07 +00:00
|
|
|
# Litestream in-process replication and lightweight read-replicas
|
2025-11-09 13:16:08 +00:00
|
|
|
|
2025-11-26 12:53:07 +00:00
|
|
|
This package adds **EXPERIMENTAL** support for in-process [Litestream](https://litestream.io/).
|
2025-11-09 13:16:08 +00:00
|
|
|
|
2025-11-26 12:53:07 +00:00
|
|
|
## Lightweight read-replicas
|
|
|
|
|
|
|
|
|
|
The `"litestream"` SQLite VFS implements Litestream
|
|
|
|
|
[lightweight read-replicas](https://fly.io/blog/litestream-revamped/#lightweight-read-replicas).
|
|
|
|
|
|
|
|
|
|
See the [example](example_test.go) for how to use.
|
2025-11-09 13:16:08 +00:00
|
|
|
|
|
|
|
|
To improve performance,
|
|
|
|
|
increase `PollInterval` (and `MinLevel`) as much as you can,
|
|
|
|
|
and set [`PRAGMA cache_size=N`](https://www.sqlite.org/pragma.html#pragma_cache_size)
|
2025-11-26 12:53:07 +00:00
|
|
|
(or use `_pragma=cache_size(N)`).
|
|
|
|
|
|
|
|
|
|
## In-process replication
|
|
|
|
|
|
|
|
|
|
For disaster recovery, it is probably best if you run Litestream as a separate background process,
|
|
|
|
|
as recommended by the [tutorial](https://litestream.io/getting-started/).
|
|
|
|
|
|
|
|
|
|
However, running Litestream as a background process requires
|
|
|
|
|
compatible locking and cross-process shared memory WAL
|
|
|
|
|
(see our [support matrix](https://github.com/ncruces/go-sqlite3/wiki/Support-matrix)).
|
|
|
|
|
|
|
|
|
|
If your OS lacks locking or shared memory support,
|
|
|
|
|
you can use `NewPrimary` with the `sqlite3_dotlk` build tag to setup in-process replication.
|