Skip to content

Persistence modes ​

All modes need --persist (data under --data-dir) and apply to every service. --persist-mode (GOPHERSTACK_PERSIST_MODE) sets the default; --persist-service-mode s3=hybrid,sqs=snapshot overrides it per service.

ModeBehaviourWorst-case loss on crash
snapshot (default)Snapshots a service 500 ms after its last mutating request, and all services at clean shutdownAbout 500 ms
shutdownNo saves while running; saves everything at graceful shutdownEverything since start
manualSaves only via POST /_gopherstack/persist/save. Never saves at shutdownEverything since the last explicit save
hybridMutations mark the service dirty. Every --persist-flush-interval (default 5s), only changed services are snapshotted. Everything is flushed at clean shutdown. Suits write-heavy workloadsOne flush interval

A POST, PUT, PATCH or DELETE marks the routed service dirty unless its operation name (X-Amz-Target suffix or Action) starts with Get, List, Describe, Head, Query, Scan or BatchGet. Unknown operations count as writes.

Service selection ​

--persist-services s3,dynamodb persists only those services. --persist-exclude removes services afterwards. Names are case-insensitive. Unselected services are neither saved nor restored.

Load strategy ​

--persist-load (GOPHERSTACK_PERSIST_LOAD) sets when stored state is restored.

StrategyBehaviour
startup (default)Every service restores at startup
requestA service restores just before its first request through the HTTP gateway. In-process calls between services do not trigger it. Services never touched keep their stored snapshot at shutdown
manualNothing restores until POST /_gopherstack/persist/load

WARNING

With manual load, mutating a service before loading overwrites its stored snapshot at the next save.

/_gopherstack/persist/save and /_gopherstack/persist/load exist only with --persist. They return {"status":"ok","saved":N} and {"status":"ok","loaded":N}.

LocalStack's SNAPSHOT_SAVE_STRATEGY and SNAPSHOT_LOAD_STRATEGY map onto these settings; see Migration.

Released under the MIT License.