Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Roadmap
  1. 1.HTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC)
  2. 2.TCP and TLS Handshakes: Connection Setup Costs
  3. 3.Browser Network Stack and Connection Pooling
  4. 4.GET vs POST and Idempotency in HTTP
  5. 5.The Critical Rendering Path (CRP)
  6. 6.DOM, CSSOM and the Render Tree
  7. 7.Layout, Paint and Compositing
  8. 8.Reflows and Repaints Explained
  9. 9.Event Loop: Call Stack, Task and Microtask Queues
  10. 10.Async JavaScript: Promises and async/await
  11. 11.Web Workers: Multi-threading in the Browser
  12. 12.Browser Storage: Cookies, Web Storage, IndexedDB
  13. 13.Client-Side Storage: Limits and Security Risks
  14. 14.Choosing the Right Client-Side Storage
  15. 15.HTTP Caching: Cache-Control, ETag, Last-Modified
  16. 16.Browser-Level Caching Mechanisms
  17. 17.Cache Invalidation for Frontend Apps
  18. 18.Structuring a Large Single-Page App
  19. 19.Component-Based Architecture Principles
  20. 20.Props, State and Component Lifecycle
  21. 21.Module Bundling Basics
  22. 22.Core Web Vitals: LCP, INP and CLS
  23. 23.FCP and Time to Interactive (TTI) Explained
  24. 24.Measuring Performance: Lighthouse and WebPageTest
  25. 25.Asset Compression and Minification Basics
  26. 26.What Is a CDN and How Does It Work?
  27. 27.CDN Benefits: Latency, Availability, Offload
  28. 28.CDN Cache Behavior and Invalidation
  29. 29.Global State vs Local Component State
  30. 30.State Patterns: Redux, Zustand and Context
  31. 31.Data Fetching: React Query and SWR
  32. 32.Immutable Data in Frontend State
  33. 33.SSR vs CSR: Rendering Trade-offs
  34. 34.Hydration and Time to First Byte (TTFB)
  35. 35.Static Site Generation (SSG) for Speed and SEO
  36. 36.Incremental Static Regeneration (ISR)
  37. 37.Micro-Frontends: Core Principles
  38. 38.Micro-Frontend Integration Strategies
  39. 39.Communication Between Micro-Frontends
  40. 40.Micro-Frontends: Pros and Cons for Large Teams
  41. 41.Real-Time: Polling, SSE and WebSockets
  42. 42.Real-Time Use Cases: Chat, Alerts, Live Data
  43. 43.Designing a Real-Time Data Flow
  44. 44.Scaling WebSocket Connections
  45. 45.Responsive Images: srcset, sizes and picture
  46. 46.Modern Image Formats: WebP, AVIF, JPEG XL
  47. 47.Lazy Loading Images and Videos
  48. 48.Video Streaming: HLS, DASH, Adaptive Bitrate
  49. 49.REST and GraphQL for Frontend Engineers
  50. 50.Batching, Throttling and Debouncing API Calls
  51. 51.Handling API Errors in the Frontend
  52. 52.Authentication Flows: OAuth and JWT
  53. 53.Global Error Boundaries in React
  54. 54.Error Reporting: Sentry and LogRocket
  55. 55.Graceful Degradation and Fallback UIs
  56. 56.Real User Monitoring (RUM)
  57. 57.CORS: Cross-Origin Resource Sharing
  58. 58.Preventing XSS (Cross-Site Scripting)
  59. 59.CSRF Protection for Frontend Apps
  60. 60.Content Security Policy (CSP)
  61. 61.Storing Auth Tokens: Cookies vs localStorage
  62. 62.PWA Manifest and Installability
  63. 63.Service Workers: Lifecycle and Caching Strategies
  64. 64.Offline Support and Background Sync
  65. 65.Push Notifications for Web Apps
  66. 66.Webpack vs Vite vs Parcel
  67. 67.Code Splitting, Tree Shaking, Asset Optimization
  68. 68.Module Resolution and Hot Module Replacement
  69. 69.Monorepo Tooling: Nx and Lerna
  70. 70.Atomic Design for Component Libraries
  71. 71.Theming and Customization in Design Systems
  72. 72.Accessibility in Component Libraries
  73. 73.Component Library Docs, Testing and Versioning
  74. 74.Publishing and Consuming a Component Library
  75. 75.Full-Text Search: Levenshtein and Fuzzy Matching
  76. 76.Indexing Large Datasets in the Browser
  77. 77.Search Performance: Debouncing and Web Workers
  78. 78.Integrating Backend Search Services
  79. 79.Choosing a Chart Library: D3, Chart.js, Recharts
  80. 80.Rendering Large Datasets: Canvas vs SVG
  81. 81.Interactive, Responsive Data Visualizations
  82. 82.Data Fetching and Aggregation for Dashboards
  83. 83.A/B Test Design and Rollout Strategies
  84. 84.Client-Side vs Server-Side A/B Testing
  85. 85.Feature Flags and Remote Configuration
  86. 86.Experiment Data Collection and Analytics
Frontend System Design Roadmap
84

Frontend System Design · Lesson 84 of 86 · 4 min

Client-Side vs Server-Side A/B Testing

This is a classic trade-off question. Your answer shows if you think about user experience, performance, and engineering cost.

When an interviewer asks you to design a system that involves A/B testing, they're listening for your default choice and your reasoning. Your ability to articulate the trade-offs between client-side and server-side execution is a strong signal of seniority. This lesson gives you a clear framework for that discussion.

How client-side testing works (and where it breaks)

In a client-side test, the server sends the same default page to every user. Then, a JavaScript SDK from a service like Optimizely or VWO runs in the browser, determines if the user is in an experiment, and manipulates the DOM to show the variant.

This approach is popular with marketing and growth teams because it lets them change copy, colors, or simple layouts without a full engineering deployment cycle.

The trap: The user pays the price in performance and experience. The browser renders the original page first, and then the script modifies it. This causes a "flicker" or Flash of Original Content (FOOC), where users see the old content for a moment before it changes. It looks broken and can invalidate your test results.

The only way to manage this is to hide the content until the test logic runs. This trades one problem for another: you're now intentionally delaying when the user sees content, which can hurt your Largest Contentful Paint (LCP).

This code shows the basic flicker mitigation pattern. You hide the element with CSS, apply the variant with JS, and then unhide it.

// A/B SDK function (simplified)
function getVariant(experimentName: string): 'control' | 'variant' {
    // In a real system, this is deterministic based on a stable user ID.
    return Math.random() < 0.5 ? 'control' : 'variant';
}

const element = document.getElementById('hero-section');

if (element) {
    // 1. Hide the element immediately to prevent flicker.
    // This class should be in your stylesheet to apply instantly.
    element.classList.add('experiment-loading');

    const variant = getVariant('hero-redesign');

    if (variant === 'variant') {
        const title = element.querySelector('h1');
        if (title) {
            title.textContent = 'A Brand New Headline';
        }
    }
    // For the control group, we do nothing to the content.

    // 2. Unhide the element after changes are applied.
    element.classList.remove('experiment-loading');
}
/* In your CSS, loaded in the <head> */
.experiment-loading {
  visibility: hidden;
}

Why server-side is the robust default

In a server-side test, the decision happens before the page is ever sent to the browser.

The server receives a request, identifies the user, determines their experiment variant, and renders the correct HTML from the start. The browser receives a page that is already finalized.

There is no flicker. There are no layout shifts from post-load DOM manipulation. The page works perfectly even if JavaScript fails. It's faster for the user because there's no extra client-side script to download and execute during the critical rendering path.

Server-side is the only acceptable choice for testing anything significant:

  • Changes to a checkout flow or business logic.
  • Different pricing models.
  • New API response structures.
  • Search algorithm changes.

It's also better for SEO, as crawlers always see the final, fully-rendered content.

How to frame the decision in an interview

Start your answer by establishing server-side testing as your professional default. This shows you prioritize a robust, performant user experience.

"I'd advocate for server-side testing as the default for any significant experiment. It provides a flicker-free, performant experience and is the only way to reliably test changes to business logic or critical user flows. The engineering cost is higher upfront but pays off in data quality and user trust."

Then, show your pragmatism by explaining when client-side is an acceptable trade-off.

"However, for purely cosmetic changes driven by a marketing team—like changing button copy or a hero image—client-side testing can be a practical tool. It allows for faster iteration without a full backend deployment for every tweak, provided we aggressively mitigate flicker and monitor the performance impact."

A more advanced answer introduces a hybrid approach. The server determines the variant and sends a flag down with the initial page load (e.g., in a JSON object). A client-side framework like React reads this flag and renders the correct component tree from the start. This avoids both heavy DOM manipulation and the need for the server to maintain completely separate render paths. It combines server authority with client-side rendering flexibility.

The consistency trap

An A/B test is useless if a user sees the control version on one page load and the variant on the next. This contaminates your data and creates a jarring user experience.

Assignment must be deterministic and sticky. Given the same user and the same experiment, the assignment logic must always return the same variant.

This is done by bucketing the user based on a stable identifier. For logged-in users, this is their user ID. For anonymous users, it's a unique ID stored in a long-lived cookie. You hash this ID against an experiment ID to consistently place the user into a bucket (e.g., "control" or "variant").

Using Math.random() for variant assignment is a classic junior mistake. It proves you haven't considered the data integrity required to get meaningful results.

Try it

Open a major e-commerce or media site in your browser. Use the developer tools' network tab to block requests containing "optimizely", "vwo", or "adobe". Reload the page a few times. Can you spot content that flickers or shifts? That's client-side testing in action.

Next: Learn how the underlying infrastructure for both A/B testing and safe rollouts works in Feature Flags and Remote Configuration.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

A/B Test Design and Rollout Strategies

Next

Feature Flags and Remote Configuration