Salesforce Decode
Salesforcedecode
Back to questions
LWCArchitect (Hardest)lmspub-subarchitecture

Compare LMS versus pub-sub for sibling LWC communication at scale

Real World Scenario

Record page has 12 sibling LWCs; team debates Lightning Message Service vs custom pub-sub module for filter state broadcast.

Expected Answer

• LMS is platform-supported, documented, works across DOM boundaries and some namespace scenarios • Custom pub-sub breaks when components not in same document or after navigation • LMS requires message channel metadata — governance and discoverability advantage • Define message schema version and payload typing in shared module • Avoid high-frequency LMS messages — throttle or batch filter updates • Document subscribers in architecture diagram for onboarding • Fallback when LMS unavailable in certain contexts — document exceptions

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Stay within limits by: LMS is platform-supported, documented, works across DOM boundaries and some namespace scenarios. Bulkify everything — never query or DML in loops. LMS requires message channel metadata — governance and discoverability advantage. At scale, communication patterns must be governable — LMS beats anonymous pub-sub for enterprise maintenance. Document the decision in an ADR and align with enterprise standards.

Architect Perspective

At scale, communication patterns must be governable — LMS beats anonymous pub-sub for enterprise maintenance.