Blog

LWC architecture for 500+ concurrent users

A service-layer and MVC-oriented Lightning Web Components approach I used when NBCUniversal experiences had to stay stable under 500+ concurrent users.

3 min readAwaiting author review

Lightning Web Components are fast by default, but enterprise pages fail in subtle ways when hundreds of users hit the same custom experience during quarter close or a major product launch. At NBCUniversal I leaned on a service-layer, MVC-minded LWC architecture when we had to support 500+ concurrent users on custom sales and operations surfaces without turning every interaction into a server stampede.

What “MVC” means on Lightning

Salesforce already gives you the view layer in LWC markup and CSS. I treat controllers as the @AuraEnabled or wire-backed Apex facades that translate UI intent into service calls. The model is not raw sObjects in components—it is the shaped DTOs and domain results that the service layer returns.

Components should not embed SOQL, business rules, or integration details. They bind to properties, fire events, and call imported Apex methods from a JavaScript service module that mirrors the Apex service boundary.

The JavaScript service layer

I create a *Service.js module per functional area (for example pipelineService.js). That module:

  • Imports Apex methods once and exports async functions the components call.
  • Normalizes errors into user-safe messages.
  • Caches short-lived client state that is safe to share across sibling components on the same page.

Illustrative structure:

// pipelineService.js
import getRollup from '@salesforce/apex/PipelineController.getRollup';

let rollupCache;
export async function fetchRollup(periodId, { force = false } = {}) {
    if (!force && rollupCache?.periodId === periodId) {
        return rollupCache.data;
    }
    const data = await getRollup({ periodId });
    rollupCache = { periodId, data };
    return data;
}

Components import fetchRollup, not Apex directly. When I refactor Apex signatures, I touch one module instead of twelve components.

Singleton controllers on the server

On the Apex side, I keep controllers thin and push logic into a singleton service class per domain (PipelineService.getInstance() style). The singleton is not about global mutable state—it is about a single entry point for rules, sharing enforcement, and bulk-safe queries that many UI methods reuse.

That pattern helped when dozens of LWCs on a console asked for related slices of the same dataset during heavy concurrent use. One service class owns the query plan; controllers expose narrow methods with @AuraEnabled(cacheable=true) where data is read-mostly.

Performance habits for concurrency

Several habits matter more than micro-optimizations:

  • cacheable=true for read paths that tolerate staleness of a few seconds during peak load.
  • Wire adapters where refresh semantics are clear; imperative calls when the user expects an explicit action.
  • Pagination and lazy child loads instead of returning huge graphs in one round trip.
  • Avoid per-row server calls in datatables; batch identifiers and return maps.
  • Debounce typeahead and filter changes on the client so 500 users typing does not become 500 Apex invocations per second.

Composition over monolith components

I split pages into a shell layout, filter region, data region, and detail drawer. Each region subscribes to a lightweight message channel or shared service module rather than prop-drilling ten levels. That keeps rerenders localized when one panel updates.

Testing and release discipline

LWCs get Jest tests for service-module behavior and component interactions that matter. Apex services get unit tests without Test.setCurrentPage gymnastics unless a controller truly needs it. CI runs ESLint and Jest alongside Apex tests so refactors do not slip through during high-velocity NBCUniversal releases.

Takeaway

500+ concurrent users is a reminder that LWC is a client-server system. Treat JavaScript modules and Apex services as one architecture: MVC separation, singleton domain services on the server, cacheable reads, and components that stay dumb. The UI feels faster because the server does less redundant work—and the codebase stays easier to extend when the next sales program lands on the same console.