Pick the right SpiceDB consistency mode for CheckPermission
How to choose between FullyConsistent, AtLeastAsFresh, and EventuallyConsistent when checking permissions in SpiceDB.
02 Aug 2026, 02:11 UTC

The problem: access granted, access denied
You call SpiceDB’s WriteRelationships to give user:alice the viewer relation on document:report. Moments later, your frontend calls CheckPermission for the same subject and object, and SpiceDB returns a denial. The user refreshes, tries again, and eventually it works.
This is not a bug. SpiceDB replicates relationship tuples across datastore nodes and caches hot tuples in memory. A write committed to the leader may not yet be visible to the replica that handles your read. CheckPermission is an authorization check, not authentication: it assumes you already know who the subject is and only answers whether that subject holds a relation on an object.
Thesis: match consistency to staleness tolerance
SpiceDB offers three consistency modes for CheckPermission. The right choice depends on whether your application can tolerate a briefly stale answer and how much leader load you can absorb.
FullyConsistent
Reads from the leader, so the result reflects every committed write. Use this immediately after a permission change when the user expects the new state right away—for example, after an admin revokes access and the next page load must deny it. The trade-off is higher latency and leader serialization, which can become a bottleneck under high write throughput or across regions.
EventuallyConsistent
Reads from any available replica or cache without waiting for replication. Best for read-heavy UIs where a few seconds of staleness is acceptable, such as showing a list of documents a user can view. It is fast and scales well, but it can return stale denials or grants.
AtLeastAsFresh
Reads from a replica only after it has caught up to a specific point in time, identified by a zookie token captured from a prior write. This gives read-your-writes consistency without forcing every read through the leader. The catch: your client must capture the zookie from the write response and forward it with the check request. If the token is dropped, SpiceDB silently degrades to eventual consistency.
Worked example: grant, then check
Assume a local SpiceDB instance reachable at localhost:50051 and a schema defining document with a viewer relation. Run commands from a terminal with network access to the instance; no special OS permissions are required beyond executing the client.
- Write the relationship:
spicedb relationships write --write 'document:report#viewer@user:alice'
Capture the zookie from the write response if your client exposes it.
- Check immediately with eventual consistency:
spicedb check permission document:report viewer user:alice --consistency=EventuallyConsistent
This may return a denial if the replica has not replicated the tuple yet.
- Check with full consistency:
spicedb check permission document:report viewer user:alice --consistency=FullyConsistent
This reads from the leader and should reflect the committed write.
- Check with token-based freshness:
spicedb check permission document:report viewer user:alice --consistency=AtLeastAsFresh --zokie TOKEN_FROM_WRITE
This waits until the serving replica is at least as fresh as the zookie, then answers.
Inspect the dispatch field in the response to see whether the result came from cache, the local datastore, or a remote datastore. This helps confirm which code path handled the request.
Trade-offs and limitations
- FullyConsistent serializes reads through the leader. Under heavy write load or geo-distributed deployments, this can increase latency and reduce throughput.
- AtLeastAsFresh depends entirely on client discipline. A dropped zookie silently degrades to eventual consistency, so wrap token forwarding in a helper rather than scattering it across call sites.
- Caveats—dynamic conditions attached to relationship tuples—are evaluated at request time and cannot be indexed like plain relations. A check that evaluates many caveats costs more per request.
- Schema changes take effect on the next write. Invalid tuples are rejected only after the new schema is active, so coordinate schema and traffic changes in a maintenance window.
How to verify before you ship
- Run a local SpiceDB instance with Docker Compose or the playground.
- Write a tuple, then immediately call
CheckPermissionagainst each consistency mode and compare the response and dispatch field. - Measure latency under a representative load. FullyConsistent will typically be slower; decide whether your user journey can absorb it.
- Apply a revised schema with
spicedb schema writein a staging namespace and confirm validation errors before shifting traffic.
These behaviors apply to current SpiceDB releases; check your version’s API reference for exact flag names and response fields.
There is no rollback for CheckPermission because it is a read-only operation. If you change consistency settings in your client, redeploy the client and monitor authorization latency and denial rates.
Closing
Default to EventuallyConsistent for browsing and discovery, use FullyConsistent after mutations that the user expects to see immediately, and reach for AtLeastAsFresh when you need read-your-writes behavior without leader contention. Capture and forward zookies reliably, measure the latency gap in your own environment, and let staleness tolerance—not habit—choose the mode.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.