Replica coordination
What you need to know
Scaling Next.js to multiple replicas adds a consistency problem: a request, a Server Action and a subsequent navigation may reach different processes. Treat build identity, cache invalidation and compatible secrets as shared release concerns.
By the end, you can: identify shared cache and deployment consistency needs; design test.
Attach a release identity at build time
import type {NextConfig} from 'next';const config:NextConfig={output:'standalone',deploymentId:process.env.RELEASE_ID};export default config;Expected behavior: The release pipeline must supply a stable nonsecret RELEASE_ID for the build. Do not use a different value on each replica.
How it works
Build the application once per release and deploy the same artifact. A common Server Action encryption key may be required across separately built instances; configure the documented NEXT_SERVER_ACTIONS_ENCRYPTION_KEY securely at build time if needed, never expose its value, and remember that a shared key does not make arbitrary builds compatible. deploymentId helps detect mismatched client/server versions and supports cache-busting; use a distinct release identifier for changed artifacts, not a unique identifier per Pod. Disk-based cache is local by default. For the Cache Components-disabled lane, configure cacheHandler and coordinate tags when sharing server cache; cacheHandlers (plural) is a separate integration for directive-based cache entries. Do not claim a Redis connection alone delivers correctness: test invalidation delivery, late writes, failure handling and tenant isolation. Keep immutable assets from old releases available during rollout or use a platform's verified version-aware routing.
Describe a two-replica invalidation experiment
{ "steps": [ "warm replica A revision 1", "warm replica B revision 1", "publish revision 2 and invalidate", "read A and B within stated freshness budget" ], "require": "both observe revision 2 by deadline", "forbid": "cross-tenant content"}Expected behavior: This is an acceptance plan, not an observed distributed-cache trace.
Common mistake
Sticky sessions can mask inconsistent replica behavior during a demo. They do not prove cache coordination or old-client compatibility, and cannot substitute for authorization.
Practice and verification
Run the pure replica compatibility exercise. Then design a negative test with mismatched deployment identifiers, and an independent two-user cache isolation test that records which replica answered.
Scope: Proposed Next.js 16.x / React 19, App Router with Cache Components disabled unless noted. Framework and browser examples are staged, not executed. Hypothetical costs are not actual provider rates.
Further reading: Self · Deploymentid · Platform