Volume 6

Q291: Deployment Architecture Environments Releases and Rollbacks

Difficulty: StaffFrequency: HighAnswer time: 12-16 minutes

What Interviewers Want To Evaluate

Interviewers want to know whether you can design releases as a system, not as a final command after coding.

They are checking environment strategy, build promotion, rollback readiness, feature flags, cache invalidation, observability, and how frontend teams reduce risk while shipping often.

Short Interview Answer

Deployment architecture defines how code moves from a developer laptop to production with confidence. I separate build, test, release, and rollout. A strong setup uses repeatable builds, environment-specific configuration, preview deployments, automated checks, progressive rollout, feature flags, monitoring, and rollback plans. For frontend systems, I also plan CDN cache behavior, asset versioning, source maps, runtime config, and compatibility between old clients and new APIs.

Detailed Interview Answer

Frontend deployment is deceptively complex because a release is not one thing.

It includes:

source commit
dependency install
build output
static assets
server functions
edge functions
environment variables
CDN cache rules
API compatibility
analytics events
source maps
feature flags
rollback target

A senior answer treats those as moving parts in one release system.

Environment Model

Most teams need at least:

local
preview
staging
production

Local is for fast feedback.

Preview is for every pull request or branch.

Staging is for production-like integration checks.

Production is the real user environment.

The key is to avoid pretending staging is perfect. It rarely has the same traffic, cache state, third-party behavior, or data shape as production.

Build Once Promote Many

The safest model is often:

commit -> build artifact -> test artifact -> promote artifact

The artifact should not be rebuilt differently for each environment unless there is a strong reason.

Environment differences should come from configuration, not source changes.

This prevents:

"it passed staging but production built different code"

Runtime Configuration

Frontend systems need careful config boundaries.

Public build-time values are safe to expose.

Private secrets are not.

Examples:

NEXT_PUBLIC_ANALYTICS_ID -> public
DATABASE_URL -> server only
PAYMENT_SECRET -> server only
API_BASE_URL -> depends on exposure
FEATURE_FLAG_SDK_KEY -> depends on provider

If a value reaches the browser bundle, assume users can read it.

Release Strategies

Common release styles:

all-at-once
blue-green
canary
percentage rollout
region rollout
feature-flag rollout
shadow traffic

For many frontend teams, feature flags are the most practical progressive release tool.

The deployment can go live while the feature remains off.

Then the flag can gradually expose behavior to internal users, beta users, small percentages, or specific accounts.

Rollback Design

Rollback is not only redeploying the previous commit.

You must consider:

database migrations
API contract changes
CDN cached assets
service worker caches
browser localStorage schemas
feature flag state
analytics schemas
third-party scripts

A rollback is easy only when forward and backward compatibility are planned.

Asset Versioning

Frontend releases often deploy immutable hashed assets.

Example:

app.8f3a1c.js
styles.97bc21.css

This allows long CDN caching because new releases get new filenames.

HTML or route payloads usually need shorter cache windows because they point at the latest asset graph.

API Compatibility

Old clients may run after the new deployment.

This matters when:

users keep tabs open
mobile webviews cache assets
service workers serve old bundles
CDNs hold stale route payloads
rollbacks happen

APIs should tolerate old and new clients during a rollout window.

Preview Deployments

Preview deployments improve review quality.

They support:

product review
design review
QA checks
accessibility checks
performance checks
content review
stakeholder signoff

They should not point at unrestricted production write paths unless explicitly protected.

Release Checklist

A practical release checklist:

What changed?
Who is affected?
What is behind a flag?
What metrics should move?
What errors should alert?
How do we roll back?
Are old clients compatible?
Are caches safe?
Are source maps uploaded?
Are migrations reversible or expandable?

This is lightweight but powerful.

Observability

Every release should answer:

Did error rate increase?
Did LCP/INP regress?
Did conversion or task completion drop?
Did API latency increase?
Did users hit blank screens?
Did hydration errors spike?
Did one browser or region break?

Without release-aware observability, teams learn about bad deployments from users.

Interview Framing

A strong answer sounds like:

I would separate deployment from release. First I ship a tested artifact, then expose behavior progressively with flags and monitor health metrics.

Then add rollback:

The rollback plan must include assets, API compatibility, caches, service workers, migrations, and feature flags, not just reverting code.

Common Mistakes

  • Treating deployment and release as the same thing.
  • Storing secrets in frontend bundles.
  • Forgetting old tabs and cached assets.
  • Rebuilding different artifacts per environment.
  • Having no rollback path for schema or API changes.
  • Shipping without source maps or release markers.
  • Using staging as the only production-safety proof.

Learning Studio Example

For Learning Studio:

MDX content can deploy as static pages
practice console APIs deploy as server functions
progress remains local for now
batch pages can be previewed per pull request
new question batches can ship behind normal routing
future PDF generation may need background jobs

If a new batch breaks MDX rendering, rollback should restore the previous build quickly.

If a practice console endpoint breaks, the handbook should still remain readable.

Final Mental Model

Deployment architecture is risk management for change.

The question is not:

How do we push code?

The question is:

How do we move a tested artifact through environments, expose it safely, observe it clearly, and recover quickly?