← BACK_TO_LOGS

SSG vs SSR in Next.js: Performance Benchmarks

•11 min read•KANAT NAZAROV
SSG vs SSR in Next.js: Performance Benchmarks

SSG vs SSR in Next.js: Performance Benchmarks and Production Trade-offs

Choosing between Static Site Generation and Server-Side Rendering in Next.js is not primarily a framework preference. It is a decision about where computation happens, when data becomes authoritative, and which layer absorbs traffic spikes.

A page generated once at build time has a fundamentally different failure mode from a page rendered for every request. Static output can be served from a CDN without touching application infrastructure, while SSR introduces request-time latency, database load, deployment coupling, and potentially inconsistent responses across replicas. Incremental Static Regeneration sits between those models: it provides cacheable HTML while allowing controlled freshness after deployment.

This article examines Next.js SSG vs SSR performance using a reproducible benchmark model rather than a simplistic claim that one technique is always faster. The correct architecture depends on content volatility, request distribution, personalization, cache hit rate, regional topology, and the cost of the data dependencies behind the page.

The rendering models and their actual cost

Static Site Generation

SSG generates HTML during the build phase. In the App Router, a route can remain statically rendered when its data and APIs are compatible with static execution. The resulting artifacts are distributed through the CDN and can often be served without invoking a JavaScript runtime at request time.

The request path is approximately:

  1. The client requests a URL.
  2. The CDN finds the HTML and static assets in its cache.
  3. The CDN returns the response directly.
  4. React Server Components and client JavaScript hydrate or progressively enhance the page as required.

This is the shortest and most failure-resistant path. Origin CPU, database connections, and application memory are not consumed per request. SSG is particularly effective for documentation, marketing pages, product catalogs with controlled update frequency, and content that can be rebuilt or revalidated asynchronously.

The limitation is freshness. A fully static page is only as current as the last build. If a product price, inventory quantity, or compliance notice changes every few seconds, a pure build-time model is not sufficient without a separate client-side update path.

Server-Side Rendering

SSR executes the route during the request. In Next.js 15, dynamic APIs, uncached fetches, cookies, authorization state, or explicit dynamic configuration can cause a route to render dynamically. The approximate request path is:

  1. The request reaches a CDN, edge function, or regional application server.
  2. The server executes route code and resolves data dependencies.
  3. The application contacts databases or internal services.
  4. React renders the response, including the RSC payload where applicable.
  5. The result is returned to the client and may or may not be cached.

SSR is necessary when the response depends on request-specific identity, authorization, geolocation, rapidly changing data, or non-cacheable state. It is also a straightforward consistency model: every request can read the current source of truth.

The cost is multiplicative. If a page requires three sequential service calls and the database adds 80 milliseconds of latency, that latency appears in the critical path for every uncached request. At scale, SSR converts page views into infrastructure work. A traffic spike therefore becomes a database and connection-pool problem, not merely a bandwidth problem.

Incremental Static Regeneration

Next.js Incremental Static Regeneration combines cacheability with bounded staleness. A page is generated on demand or during a build, cached for a configured interval, and regenerated after the revalidation window expires. Depending on the cache implementation, the first request after expiry may receive stale content while regeneration occurs in the background, or it may wait for the new result.

In the App Router, a common pattern is:

export const revalidate = 60;

export default async function ProductPage({
  params,
}: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await params;
  const product = await getProduct(slug);

  if (!product) {
    notFound();
  }

  return <ProductView product={product} />;
}

ISR is not a database consistency mechanism. It is a cache policy. If inventory must never be overstated, the checkout API still needs an authoritative transactional check. The product detail page can tolerate a 60-second description delay; the purchase command cannot tolerate stale stock.

Benchmarking Next.js SSG vs SSR performance correctly

A useful benchmark separates delivery latency from rendering latency. Measuring only localhost response time hides CDN behavior, TLS negotiation, geographic distance, database variance, and cold starts.

The benchmark should include at least four variants:

  • SSG with a warm CDN cache.
  • ISR with a warm cache and a revalidation event.
  • SSR with a warm application process and warm database connections.
  • SSR with cold application instances or cold edge/serverless execution.

Use identical HTML, images, fonts, and client bundles. Otherwise, the benchmark measures asset weight rather than rendering architecture. Test from multiple regions, use representative URLs, and record p50, p75, p95, and p99 rather than only the mean.

A representative production-style test might use a page with one 20-millisecond read from a managed database, one 30-millisecond content-service request, and a 35-kilobyte HTML/RSC response. With a CDN positioned near the client, illustrative results may look like this:

| Rendering path | p50 TTFB | p95 TTFB | Origin requests per 10,000 page views | Freshness | | --- | ---: | ---: | ---: | --- | | SSG, warm CDN | 35 ms | 85 ms | Near zero | Build dependent | | ISR, warm CDN | 38 ms | 95 ms | Low | Bounded by TTL or tag invalidation | | ISR, regeneration request | 180 ms | 420 ms | Low plus regeneration | Fresh after regeneration | | SSR, regional runtime | 145 ms | 390 ms | 10,000 | Request time | | SSR, edge function with remote database | 110 ms | 500 ms | 10,000 | Request time |

These figures are not universal promises. They describe the shape of the result. A well-cached static response is usually an order of magnitude cheaper than SSR. An edge runtime does not automatically win when its database is centralized in another region. The edge can reduce client-to-runtime latency while increasing runtime-to-database latency.

Measure these additional metrics:

  • TTFB, time to first byte, for server and network behavior.
  • FCP and LCP for user-visible rendering.
  • INP for post-load interaction responsiveness.
  • Cache hit ratio and stale-while-revalidate frequency.
  • Origin CPU time, memory, and concurrent requests.
  • Database query latency, pool saturation, and read replica lag.
  • Error rate during revalidation and deploy transitions.
  • RSC payload size and client JavaScript transferred.

A page can have excellent TTFB and poor LCP if it blocks on a large client bundle or an unoptimized hero image. Conversely, SSR can have acceptable TTFB but still create poor interaction performance because hydration is expensive. Rendering strategy is one component of the performance budget, not the entire budget.

SPA versus server-rendered systems

The Single Page Application vs Server Rendered comparison is often framed as client-side navigation versus full-page rendering. That framing is incomplete for modern Next.js. The App Router uses React Server Components, streaming, route-level caching, and client components selectively. A page can be server-rendered initially and still provide SPA-like navigation after hydration.

A traditional SPA typically ships an application shell, downloads JavaScript, requests data from APIs, and renders the page in the browser. This can be effective for authenticated dashboards where SEO is irrelevant and interactions dominate. It also gives the client control over data refresh and optimistic updates.

The costs are front-loaded JavaScript, potentially delayed content visibility, larger memory use on low-end devices, and weaker behavior when JavaScript fails or networks are slow. The API becomes the primary rendering dependency, and authorization logic must be correctly enforced at every endpoint.

Server-rendered Next.js moves more work to the server and can send meaningful HTML earlier. With Server Components, server-only dependencies do not need to enter the browser bundle. This is particularly valuable for content-heavy pages and low-powered devices. The trade-off is increased server complexity and the requirement to model caching deliberately.

A practical split is:

  • Use static or ISR server components for public, cacheable content.
  • Use SSR for request-specific shells, authorization decisions, and rapidly changing summaries.
  • Use client components for high-interaction islands, not entire page trees by default.
  • Keep mutations in server actions or route handlers, but validate authorization and input independently of the UI.
  • Use client-side refresh for ephemeral state such as notifications, presence, and live operational data.

Edge execution, databases, and distributed-system failure modes

The phrase Vercel edge functions performance is frequently interpreted as a guarantee of lower latency. Edge execution only reduces the first network segment. It does not eliminate the latency of a centralized database, third-party API, cache miss, or cold initialization.

An edge function near a user in Singapore can still wait 180 milliseconds for a primary database in Virginia. If the function performs multiple serial reads, the savings from proximity can disappear. Edge runtimes also impose constraints around Node.js APIs, native modules, connection reuse, filesystem access, and observability tooling. Verify compatibility before moving a route from a Node.js runtime.

For low-latency APIs and SSR pages, design the dependency graph explicitly:

  • Place read-heavy data in a globally replicated cache or regional read model.
  • Keep writes close to the authoritative database and expose asynchronous projection updates.
  • Parallelize independent fetches with
    Promise.all
    .
  • Set explicit timeouts and fallback behavior for every remote dependency.
  • Avoid opening a new database connection for every serverless invocation.
  • Use request memoization and cache tags to prevent duplicate reads.
  • Treat third-party APIs as unreliable dependencies, not as part of the local process.

A static or ISR page also needs fault tolerance. Build failures can prevent new content from publishing. Revalidation failures can leave stale content in place. That is often preferable to returning an error page, but only if the business accepts bounded staleness. For regulated or transactional content, stale fallback must be paired with visible status, strict invalidation, or a dynamic authoritative endpoint.

Production protocols and implementation

Start with a route classification document. For every route, record volatility, personalization, SEO importance, maximum acceptable staleness, dependency cost, and failure behavior. Then implement the least dynamic model that satisfies the requirement.

Static and ISR configuration

Use time-based revalidation for predictable freshness:

export const revalidate = 300;

Use tag-based invalidation when a CMS or mutation knows exactly which content changed:

import { revalidateTag } from 'next/cache';

export async function POST(request: Request) {
  await requireWebhookSecret(request);
  const body = await request.json();
  await updateCatalog(body);
  revalidateTag('catalog');
  return Response.json({ ok: true });
}

The read path should attach the same tag:

const response = await fetch(`${process.env.CATALOG_URL}/products`, {
  next: { revalidate: 300, tags: ['catalog'] },
});

Do not call invalidation before the source-of-truth transaction commits. Otherwise, a regenerated page can observe the old value or a partially committed state. For distributed systems, publish an outbox event after commit and make invalidation idempotent.

Dynamic rendering with controlled dependencies

For a genuinely dynamic route, make the behavior explicit and bound the work:

import { unstable_cache } from 'next/cache';

const getRecommendations = unstable_cache(
  async (userId: string) => fetchRecommendations(userId),
  ['recommendations'],
  { revalidate: 30 }
);

export const dynamic = 'force-dynamic';

export default async function AccountPage() {
  const session = await requireSession();
  const [account, recommendations] = await Promise.all([
    getAccount(session.user.id),
    getRecommendations(session.user.id),
  ]);

  return <AccountView account={account} recommendations={recommendations} />;
}

The cache key must include every value that changes the result. Never share personalized data through a cache key that omits the user or tenant identity. For multi-tenant systems, include tenant boundaries in both authorization checks and cache keys.

Deployment and verification workflow

  • Establish a performance budget: for example, p95 TTFB below 200 milliseconds for cached public routes and below 500 milliseconds for dynamic routes.
  • Test cache-hit and cache-miss paths separately.
  • Run load tests against a production-like database, not a local mock.
  • Test cold starts, regional failover, dependency timeouts, and stale-cache behavior.
  • Inspect Next.js build output to identify routes that unexpectedly became dynamic.
  • Add tracing spans for rendering, cache lookup, database queries, and downstream calls.
  • Alert on cache-hit ratio, p95 render duration, revalidation errors, and database pool utilization.
  • Perform a deploy while traffic is active and verify that old and new artifacts coexist safely.

Next.js 15 makes caching behavior more explicit than older versions, but explicit configuration remains essential. Do not infer cache semantics from a route's apparent simplicity. A call to cookies, headers, authorization state, or an uncached fetch can change the rendering mode. Review framework upgrades with route-level integration tests and inspect response headers in each environment.

Conclusion

The strongest result from Next.js SSG vs SSR performance testing is architectural, not ideological: cacheable work should happen before the request, while request-specific work should remain dynamic and narrowly scoped.

Choose SSG when content changes with deployments. Choose ISR when content is public and can tolerate bounded staleness. Choose SSR when identity, authorization, or strict freshness belongs in the response. Use client components for interaction, not as a default replacement for server rendering.

The operational invariants are straightforward: measure cache hits and misses separately, keep database access out of the critical path whenever freshness permits, parallelize independent dependencies, make invalidation idempotent, and treat edge execution as a topology tool rather than a latency guarantee. Monitor TTFB, LCP, cache-hit ratio, render duration, revalidation failures, origin utilization, and database saturation. Those metrics reveal whether the selected rendering model is actually improving the system—or merely moving the bottleneck.

Leave a comment

Kanat Nazarov

Kanat Nazarov

Systems & Full-Stack Engineer
Kanat Nazarov is a product-minded Full-Stack Engineer. He is the co-founder of GetFusionChat, an enterprise-grade multi-tenant communication SaaS platform. Beyond architecting low-latency infrastructures and advanced AI systems, Kanat is a dedicated student of peak performance—optimizing his lifestyle through rigorous fitness, precise nutrition, and creative production in music. He operates on the core philosophy that breakthrough technical results stem from a high-functioning, deeply disciplined life.