prooph/snapshot-store
Lightweight snapshot store for prooph/event-sourcing setups. Provides a simple API to persist and load aggregate snapshots, reducing replay time and improving performance. Note: library support ended Dec 31, 2019 (deprecated).
prooph/event-sourcing) to enable snapshot-based aggregate loading for high-traffic aggregates (e.g., Order, UserProfile).CompositeSnapshotStore to balance speed and durability, targeting 90%+ reduction in aggregate load times.Adopt if:
igbinary for performance or JSON for compatibility).CompositeSnapshotStore to optimize for both speed and durability.Look Elsewhere if:
"This package allows us to eliminate a critical performance bottleneck in our event-sourced systems by storing snapshots—serialized states of our business objects—so we don’t have to replay thousands of events every time we need to read data. For example, in our order processing system, this would reduce database load during peak hours, improving response times for customer checkout by 30–50% while keeping our existing architecture intact. The trade-off is minimal: we’re adding a lightweight caching layer that’s already proven in production. Since the package is deprecated but stable, we’d treat it as a short-term optimization until we migrate to a long-term solution like EventStoreDB. The cost is low, and the ROI is immediate."
*"Pros":
igbinary for speed, JSON for compatibility) and multi-layer storage (e.g., Redis + PostgreSQL) via CompositeSnapshotStore.prooph/snapshotter). If you’re already using Prooph, this is a drop-in optimization with minimal setup.Cons":
Proposed Approach:
UserProfile) to measure performance gains and validate the snapshot strategy.Order, Inventory) with CompositeSnapshotStore (e.g., Redis for hot data + PostgreSQL for persistence).Alternatives Considered:
Recommendation: Proceed with caution. This is a short-term win for performance-critical aggregates, but we should budget for a replacement in 12–18 months to avoid dependency risks. Start with a proof-of-concept to validate gains before full rollout."*
*"Implementation Notes":
prooph/event-sourcing and prooph/snapshotter. If not using Prooph, evaluate alternatives like Spatie’s EventSourcing.serialize() but supports custom strategies (e.g., igbinary for performance):
$serializer = new CallbackSerializer('igbinary_serialize', 'igbinary_unserialize');
$snapshotStore = new PdoSnapshotStore($pdo, ['snapshot_table' => 'aggregates'], $serializer);
$cacheStore = new RedisSnapshotStore($redis);
$persistenceStore = new PdoSnapshotStore($pdo);
$compositeStore = new CompositeSnapshotStore([$cacheStore, $persistenceStore]);
$repository = new PdoAggregateRepository($pdo, $metadata, $snapshotStore, $eventStore);
Key Questions to Resolve:
igbinary for speed, JSON for compatibility?)How can I help you explore Laravel packages today?