Questions
15 of 33
1Explain server-side rendering (SSR) in Next.js.
2List the benefits of Server-Side Rendering in Next.js.
3What are server components?
4How to use server components in next js?
5What is the React Server Component Payload (RSC)?
6Describe how server components are rendered.
7Describe server rendering strategies
8How can you keep Server-only Code out of the Client Environment
9What are the issues of using context provider at the root of the application?
10List dynamic functions available to server components.
11List all Dynamic APIs.
12How do we opt for Static Rendering, Dynamic Rendering and Streaming?
13Explain the difference between SSR, SSG, ISR, and CSR in Next.js. When would you choose each?
14How does getServerSideProps work internally? What is its execution context?
15What are the performance trade-offs of SSR vs SSG in a high-traffic production app?
16How does Next.js handle hydration? What is a hydration mismatch, and how do you debug it?
17What happens when getServerSideProps throws an error? How do you handle it gracefully?
18How would you architect a Next.js app that needs both personalised (SSR) and cacheable (SSG) pages at scale?
19Explain the App Router vs Pages Router SSR model differences. How does React Server Components change the SSR paradigm?
20How do React Server Components (RSC) differ from traditional SSR? Can they be used together?
21How does streaming SSR work in Next.js 13+? What role does Suspense play?
22How would you implement partial hydration or Islands Architecture in Next.js?
23Explain how Next.js handles data fetching waterfall problems in SSR and how you'd mitigate them.
24How would you implement partial hydration or Islands Architecture in Next.js?
25How do you implement caching strategies for SSR responses in Next.js? (CDN, Cache-Control, stale-while-revalidate)
26How would you reduce TTFB (Time to First Byte) in an SSR-heavy Next.js app?
27What's the difference between fetch caching in the App Router vs traditional getServerSideProps?
28How do you avoid redundant database/API calls across multiple server components on the same page?
29How do you securely handle authentication in SSR? What are the risks of passing tokens via cookies vs headers?
30How do you prevent sensitive server-side data from leaking to the client bundle?
31How would you implement role-based rendering on the server without exposing protected routes to the client?
32How do you debug SSR-only issues that don't appear in local development?
33How can we control dynamic rendering behaviour in next js?
15 / 33

What are the performance trade-offs of SSR vs SSG in a high-traffic production app?

SSR trades higher server load and latency for perfect data freshness, while SSG trades build complexity and potential staleness for CDN-level performance and minimal server costs

In high-traffic production applications, the choice between SSR and SSG fundamentally impacts infrastructure costs, user experience, and architectural complexity. SSR shifts the rendering workload to your servers for every request, providing perfect data freshness but requiring significant compute resources and introducing per-request latency. SSG pre-renders content at build time, serving static files from the CDN edge with minimal latency and near-zero server load, but at the cost of potential data staleness and complex update strategies. Modern high-traffic apps often use ISR as a hybrid approach, but understanding the raw trade-offs helps in making informed architectural decisions.

Core Performance Metrics Comparison
  1. 1

    Time to First Byte (TTFB): SSG delivers 10-100ms from CDN edge; SSR averages 200-600ms (plus backend processing time).

  2. 2

    Requests per second: A single SSR server instance might handle 50-200 req/s; SSG can handle millions through CDN.

  3. 3

    Infrastructure costs: SSR requires provisioned servers or auto-scaling groups; SSG can run on static hosting at minimal cost.

  4. 4

    Cache hit ratio: SSG approaches 100% at CDN edge; SSR caching is complex and often bypassed for personalized content.

  5. 5

    Cold start impact: SSR functions (serverless) suffer cold starts (500ms-2s); SSG has zero cold start penalty.

When traffic spikes, SSR systems face proportional increases in server load. Each request consumes CPU and memory to render the page, potentially leading to a death spiral as servers become overloaded and response times increase. With auto-scaling, this means provisioning enough capacity for peak traffic—often 2-3x average load. Database connections multiply with each request, requiring connection pooling and careful resource management. Even with aggressive caching at the CDN or application layer, personalized SSR often bypasses caches, making it vulnerable to traffic surges. High-traffic SSR apps typically require sophisticated load balancing, distributed caching, and database read replicas to maintain performance.

SSR Load Impact Simulation
SSG Performance Advantages at Scale
  1. 1

    Zero origin load: Static files are served entirely from CDN edge, with requests never reaching your origin servers for cached pages.

  2. 2

    Global distribution: CDNs serve content from locations closest to users, achieving sub-50ms TTFB worldwide.

  3. 3

    Infinite scaling: CDNs handle traffic spikes automatically—no auto-scaling delays, no capacity planning.

  4. 4

    DDoS resilience: Static sites on CDN absorb massive traffic without impacting origin infrastructure.

  5. 5

    Consistent performance: Response times remain stable regardless of concurrent users; no contention for server resources.

The primary performance trade-off for SSG is the complexity of keeping content fresh. With pure SSG, content updates require full site rebuilds—impractical for large sites at high-traffic scale. ISR solves this but introduces its own performance considerations: background regeneration consumes server resources, and the first request after a revalidate window experiences a slight delay while the page regenerates. On-demand ISR via webhooks can trigger updates instantly but requires additional infrastructure. For sites with millions of pages, you must carefully balance pre-rendering (fast but costly builds) with on-demand generation (slower first visits but efficient builds).

SSG with ISR: The Hybrid Performance Profile
Cost Analysis: SSR vs SSG at Scale
  1. 1

    SSR server costs: For 10M monthly pageviews with 200ms render time, you need approximately 60-80 concurrent servers (or equivalent serverless functions), costing $2,000-10,000/month depending on provider.

  2. 2

    SSG hosting costs: Same traffic on static hosting (Cloudflare Pages, Vercel, AWS S3+CloudFront) typically costs $20-200/month, with the $200 tier handling unlimited requests on most platforms.

  3. 3

    Database costs: SSR requires database connections per request, often needing read replicas ($200-2000/month each). SSG/ISR reduces database load to build-time only or minimal regeneration requests.

  4. 4

    Development complexity: SSR simpler initially but becomes complex with caching strategies; SSG simpler at small scale but requires sophisticated ISR/webhook infrastructure at large scale.

  5. 5

    Hidden costs: SSR auto-scaling delays during traffic spikes can cause timeouts and lost revenue; SSG rebuild pipelines require CI/CD infrastructure but scale predictably.

Consider a large e-commerce platform with 500,000 products and 50 million monthly pageviews. With SSR, each product page view consumes server resources, requiring massive auto-scaling during sales events (Black Friday traffic 10x normal). Database load would necessitate dozens of read replicas, and response times would degrade under peak load. With SSG/ISR, the site pre-renders 50,000 popular products at build time, generating the rest on-demand. During a sales event, 95% of traffic hits pre-rendered pages served from CDN, with zero origin impact. The remaining 5% trigger on-demand generation, easily handled by minimal server capacity. Infrastructure costs drop by 80-90%, and page load times improve from 600ms to under 100ms.

When SSR Still Makes Sense (Even at High Traffic)
  1. 1

    Personalized content: Dashboards, user profiles, and authenticated pages where content is unique per user.

  2. 2

    Real-time data: Stock tickers, live scores, auction sites where milliseconds matter.

  3. 3

    SEO-critical dynamic pages: Pages that need fresh content for every crawler visit and can't use ISR staleness.

  4. 4

    Complex user interactions: Pages that depend on session state, cookies, or request headers for core content.

  5. 5

    Low-traffic internal tools: Admin panels, internal dashboards where scaling isn't a concern.

Optimizing SSR for High Traffic

ISR has emerged as the preferred approach for high-traffic production apps because it bridges the performance gap. By pre-rendering pages at build time and updating them in the background, ISR achieves SSG-level performance for most requests while maintaining near real-time freshness for content updates. The key insight is that most traffic goes to a subset of pages—the Pareto principle applies. Pre-render the 20% of pages that get 80% of traffic, generate the rest on-demand, and use webhooks to update critical pages instantly. This gives you the best of both worlds: CDN performance with server-generated freshness when needed.