Archive from another server (remotes)¶
Sapsan can seamlessly play an archive that is recorded (or used to be recorded) on another server. A stream lists remote servers — and their archives become an extension of the local one: the viewer sees one continuous archive and never knows where the data physically comes from.
Typical tasks this solves:
- migrating to a new server without losing history — the new one records fresh archive, the old one keeps the past;
- reading the archive from replica servers;
- recovering after a disk replacement.
Configuration¶
streams:
cam1:
inputs:
- rtsp:
url: rtsp://10.0.0.5/stream0
dvr: {}
remotes:
- url: http://old-server:5080
timeout_ms: 5000
| Parameter | Description |
|---|---|
url |
address of the remote Sapsan server that has this stream's archive |
timeout_ms |
timeout for requests to the remote server |
There can be several remote servers — Sapsan queries them all.
How seamlessness works¶
On every archive access Sapsan merges local and remote data:
- Archive bounds — the union of all servers' ranges: the earliest start and the latest end. In UIs and the API the stream looks like one continuous archive.
- Playlists — fragment lists from the local DVR and all remote servers are merged, sorted, and deduplicated. There is no seam, gap, or duplicate at the junction of two archives.
- Fragments — read in a cascade: live buffer → local DVR → remote server. The fragment URL is the same for the player regardless of where the data lives.
This is possible thanks to Sapsan's absolute fragment addressing: a fragment's name is its UTC time, so the same fragment has the same name on every server, and merging archives requires no timeline remapping.
Lazy replication¶
A fragment read from a remote server is automatically written into the local archive. The local DVR gradually "pulls in" the parts of foreign history that viewers actually watch — and over time stops fetching them over the network. A failure of such a write never interferes with serving the viewer.
Failure behavior¶
- If a remote server is unreachable but the data exists locally, playback continues; the problem is only logged.
- Sapsan remembers which ranges are absent on a remote (negative cache) and does not re-query it for missing data.
- Init fragments of remote streams are cached.
Note
TODO: inter-server request authorization, timeout recommendations, limits (how many remotes are reasonable), interaction with config_external.