Skip to main content
Kuldeep Singh
Kuldeep SinghDigital Architecture
WHITE PAPER · WEBASSEMBLY (RUST / C++) · SALESFORCE LWC · AWS S3 · NET-ZERO DBTier 1 Flagship

WebAssembly in Salesforce LWC: 500K Record Engine & Net-Zero DB

When enterprise SaaS platform limits cap data scale, move bare-metal systems execution into browser WebAssembly and eliminate database costs with immutable delta streaming.

Bridging bare-metal C++/Rust performance into Lightning Web Components: Streaming gzip decompression, AST query compilation over 500K+ telco pricing records, and zero-database delta reconciliation on AWS.

WEBASSEMBLYRUST / C++SALESFORCE LWCAWS S3AST QUERY COMPILERNET-ZERO DB
Executive BriefSystems
Domain / ScopeSystems Engineering & High-Throughput Salesforce Architecture
Architectural RolePrincipal Systems & Salesforce Technical Architect
Timeline & InitiativeR&D Architecture White Paper & Production Implementation · 2025 - 2026
Key Verified Invariant

Sub-30s Cold Ingestion: 500,000+ pricing records cold-loaded, decompressed, and indexed inside native Salesforce LWC in under 28 seconds

01 // The Constraint

What Made the Problem Difficult

Enterprise telecommunications CPQ and multi-site connectivity quoting across commercial office buildings, data centers, and carrier colocation facilities operate on enormous scale. A nationwide enterprise procurement involves evaluating Ethernet, DIA, Wavelengths, and Dark Fiber across thousands of site addresses against external supplier catalogs such as Connectbase (The Connected World platform). Each physical address maps to multiple building entrance facilities, local loop carriers, dynamic NRC/MRC rate matrixes, distance-based construction fees, and SLA tiers. Across a standard high-density RFP scenario, the unrolled matrix easily exceeds 500,000+ distinct pricing and route options—spanning over 120MB of raw hierarchical JSON. Sales executives, solutions engineers, and deal desks required this data to be available natively inside Salesforce Lightning Web Components (LWC) with instantaneous searching, multi-field filtering, and the ability to manually override pricing.

Core Platform Constraint

Systemic Friction

Delivering this capability inside standard Salesforce architecture collided with severe multi-dimensional barriers:

01
CRM Data Storage Cost Barrier

Ingesting 500k records into custom objects (e.g. Pricing_Record__c) consumes over 1GB per quoting scenario. For enterprise carriers processing hundreds of complex quotes monthly, this would cost hundreds of thousands of dollars in Salesforce data storage add-ons and quickly exceed platform storage limits.

02
Apex Governor Limit Ceilings

Apex enforces a strict 6MB synchronous / 12MB asynchronous heap ceiling and a 10-second CPU limit. A 120MB raw JSON payload cannot be deserialized, manipulated, or transferred by Apex without catastrophic System.LimitException failures.

03
Connectbase API Throttling

High concurrency during sales quarter-ends triggers HTTP 429 rate-limiting on external supplier endpoints.

04
Network Transit Lag

Fetching 120MB uncompressed JSON over standard enterprise networks creates 15-30+ second transfer latencies.

05
V8 JavaScript Thread Freezing

Parsing and rendering 500,000 JavaScript objects in the browser triggers multi-second V8 Garbage Collection (GC) pauses that freeze the browser UI and crash browser tabs.

06
Mutation Infrastructure Costs

The client required sales reps to manually override pricing and adjust margins. Building an external transactional database (AWS RDS PostgreSQL or DynamoDB) with API sync layers to store row edits would incur thousands in monthly cloud hosting, database connection pooling, and maintenance.

Boundary Invariants & Operational Limits:
  • !Native Salesforce LWC Experience: Quoting workflow must remain 100% native inside Lightning Experience under Lightning Web Security (LWS) without redirects to external portals
  • !Sub-30s Cold Ingestion: Must ingest, decompress, and index 500,000+ records in under 30 seconds from cold click to interactive grid
  • !Net-Zero Database Infrastructure Cost: Provide full database-like editing and pricing overrides without provisioning or paying for persistent external database clusters (RDS/PostgreSQL)
  • !Zero Salesforce Custom Object Storage Consumption: Neutralize multi-gigabyte data storage licensing costs by storing zero raw pricing rows in Salesforce database tables
  • !Zero Apex Heap Utilization: Stream massive payloads directly from cloud storage into browser memory without passing through Apex heap limits
  • !Sub-Millisecond In-Memory AST Queries: Deliver sub-millisecond Boolean search and multi-column sorting over 500K records with 60 FPS viewport rendering
  • !Eliminate Upstream API Rate Limits: Prevent concurrent quoting sessions from triggering Connectbase API 429 throttling exceptions
02 // The Architecture

What System Was Designed

Architected an end-to-end systems pipeline bridging low-level systems programming into the Salesforce ecosystem: 1. Asynchronous Ingestion & Columnar GZIP Compaction: MuleSoft and event-driven worker services ingest Connectbase rate cards asynchronously respecting upstream API rate limits. Raw payloads are restructured into a compact columnar schema and compressed with GZIP at maximum compression level, achieving a 97.3% to 98% compression ratio (compressing 120MB+ raw JSON into a ~3.2MB .gz binary stream) stored immutably in Amazon S3. 2. Zero-Heap Direct S3 Streaming: Salesforce Apex acts solely as an authorization gate, generating an AWS STS short-lived Pre-Signed URL. The LWC client initiates an asynchronous direct HTTP/2 stream from S3/CloudFront into browser client memory, completely bypassing Apex 6MB/12MB heap limits. 3. WebAssembly (Rust / C++) Decompression Engine: A compiled WebAssembly binary (with Pako JS stream decoder fallback) loaded via LWC static resources decompresses the binary stream directly into linear WebAssembly memory at bare-metal CPU speeds—avoiding V8 JavaScript heap allocation thrashing and completing full 500K record expansion in under 28 seconds. 4. In-Memory AST Query Compiler & Typed Array DSA: An Abstract Syntax Tree query engine compiles complex Boolean expressions into bytecode executed over contiguous typed arrays and inverted radix maps, executing sub-millisecond filtering and sorting. 5. Net-Zero Database Delta Reconciliation: User price edits generate a micro delta changeset (delta.json.gz, ~12KB) uploaded to S3. LWC executes an in-memory DSA hash merge that reconciles base catalog records with quote deltas at runtime in <15ms—delivering full database-like transactional capabilities with $0 database hosting cost. 6. Virtualized 60 FPS Viewport Grid: A custom virtualized LWC data grid maintains only ~40 DOM nodes in the visible window, guaranteeing smooth 60 FPS scrolling through half a million pricing items.

03 // The Key Decision

Pivotal Architectural Choices

Key Architectural Decisions

ADR // 01DETERMINISTIC CHOICE

WebAssembly (Rust / C++) Streaming Decompression vs. Pure JavaScript Main Thread vs. Server Decomposition

Context:

Decompressing a 3.2MB gzip stream into 500,000 JSON objects in standard JavaScript triggers intense garbage collector pressure, blocking the UI event loop for 4-8 seconds.

Alternatives Evaluated:
  • Server-side Apex micro-chunking
  • Client-side pure JS loop with setTimeout chunks
  • Web Worker with JSON.parse()
Chosen: Compiled WebAssembly module in Rust / C++ (with Pako JS fallback) executing byte-stream decompression directly into Wasm linear memory buffers.

WebAssembly runs at near-native CPU execution speeds with manual linear memory allocation, completely isolating decompression memory from the V8 garbage-collected heap. This enabled unpacking 500k rows in under 28 seconds with zero UI frame drops.

ADR // 02DETERMINISTIC CHOICE

Direct S3 Pre-Signed URL Streaming vs. Apex HTTP Callout Relay

Context:

Passing a 120MB or even compressed 3.2MB payload through Apex triggers synchronous heap allocation spikes that violate Salesforce governor limits.

Alternatives Evaluated:
  • Apex REST callout buffering binary chunks into ContentVersion
  • Streaming via MuleSoft API gateway proxy
  • Off-platform external quoting portal
Chosen: Apex mints an ephemeral 60-second AWS S3 Pre-Signed URL; LWC fetches the binary stream directly over HTTP/2 via browser fetch().

The binary payload never touches Salesforce application servers or Apex memory, achieving zero heap consumption while leveraging AWS global edge CDN caching.

ADR // 03DETERMINISTIC CHOICE

Net-Zero Database Micro-Delta Architecture vs. Provisioned AWS RDS / PostgreSQL Instance

Context:

Sales engineers needed to edit prices, override margins, and persist quote adjustments. Provisioning an external relational database (RDS) would incur ongoing server costs, connection pool limits, and synchronization maintenance.

Alternatives Evaluated:
  • AWS RDS PostgreSQL cluster with REST synchronization
  • DynamoDB document store with write throughput provisioning
  • Writing overrides into Salesforce custom objects
Chosen: Immutable S3 base catalog paired with micro-delta S3 uploads (delta.json.gz) merged dynamically at runtime via in-memory DSA hash algorithms.

Delivers full database-like CRUD capability with NET-ZERO database infrastructure cost. S3 storage costs pennies, deltas are 98% compressed (~12KB), and runtime in-memory hash merging executes in under 15ms.

ADR // 04DETERMINISTIC CHOICE

In-Memory AST Query Compiler on Typed Arrays vs. Naive Array.filter() Iteration

Context:

Executing complex multi-condition Boolean queries across 500,000 records using standard JavaScript Array.filter() and regex takes 250-450ms per keystroke, causing noticeable input lag.

Alternatives Evaluated:
  • Standard JavaScript Array.prototype.filter() with string matching
  • IndexedDB querying on client
  • WebSQL / embedded SQLite in Wasm
Chosen: Custom Lexer, Parser, and AST Bytecode Engine scanning contiguous typed arrays (Float64Array, Uint32Array) with inverted radix indexes.

Compiling query criteria into a byte-stream evaluator over pre-allocated contiguous memory delivers sub-millisecond query evaluation, allowing instant filtering across 500K records on every keystroke.

04 // The Engineering

What Was Actually Built

01

Engineered a zero-copy WebAssembly memory bridge: Compiled Rust (via wasm-bindgen and flate2) and C++ (zlib-ng via Emscripten) into a standalone Wasm artifact compliant with Salesforce Lightning Web Security (LWS) memory constraints, with automatic runtime fallback to Pako JS.

02

Constructed an ephemeral S3 authorization pipeline: Apex controller signs an AWS SigV4 authorization token valid for 60 seconds with strictly scoped bucket read/write permissions, keeping CRM credentials isolated from the client.

03

Optimized data schema with columnar compression: Transformed raw row-oriented JSON into columnar primitive arrays, eliminating repetitive JSON keys and enabling sliding-window deflate algorithms to achieve an astonishing 97.3% to 98% compression ratio (120MB raw JSON reduced to 3.2MB .gz).

04

Built an in-engine AST query compiler in TypeScript/Rust: Lexical scanner and recursive-descent parser translate user query inputs (e.g., '(bandwidth >= 1000 AND latency < 15) OR (carrier == "Lumen" AND mrc <= 450)') into bytecode executed across typed array indices in sub-millisecond cycles.

05

Engineered the Net-Zero DB runtime delta merge algorithm: Captured user price overrides into micro-delta files (~12KB) uploaded to S3. At runtime, LWC executes a high-speed DSA hash map reconciliation between base records and quote deltas in <15ms before rendering.

06

Constructed a sub-frame virtualized LWC viewport: Implemented a sliding DOM window rendering only ~40 active table row elements mapped via CSS transform translate3d, maintaining buttery 60 FPS scrolling and instantaneous sorting across 500,000 records.

05 // The Trade-offs

Deliberate Architectural Compromises

Trade-offs & Mitigations

Client-Side Browser Memory Footprint vs. Server Infrastructure Costs

Architectural Benefit:

Zero server compute costs, zero database infrastructure costs, and instant sub-millisecond query responsiveness.

Associated Cost:

Client browser consumes ~160MB - 180MB of memory while retaining the 500,000-record dataset.

Mitigation Strategy:

Engineered compact typed array representations (storing strings as integer lookup IDs and prices as Uint32 pennies) and garbage-collected transient parse buffers immediately upon indexing.

WebAssembly Sandbox Governance vs. Native JavaScript Fluidity

Architectural Benefit:

Near-native CPU instruction execution speed and immunity to V8 major garbage collection freezes.

Associated Cost:

Must adhere strictly to Salesforce Lightning Web Security (LWS) restrictions on WebAssembly.instantiate and SharedArrayBuffer.

Mitigation Strategy:

Built a dual-pipeline loading strategy: instantiates Wasm within allowed LWS parameters and provides a seamless, zero-config Pako JS fallback for restricted browser profiles.

S3 Delta Eventual Consistency vs. Heavy Relational ACID Locking

Architectural Benefit:

Eliminates database deadlocks, connection exhaustion, and ongoing RDS server expenses.

Associated Cost:

Concurrent edits to the same quote require optimistic concurrency control rather than row-level database locks.

Mitigation Strategy:

Embedded version-stamped delta files with cryptographic hash verification and client-side three-way merge resolution for concurrent quoting sessions.

06 // The Result

Verified Outcomes

✓ VERIFIED RESULT

Sub-30s Cold Ingestion: 500,000+ pricing records cold-loaded, decompressed, and indexed inside native Salesforce LWC in under 28 seconds

✓ VERIFIED RESULT

98% Cloud Storage Reduction: 120MB+ raw JSON reduced to 3.2MB gzip stream on Amazon S3

✓ VERIFIED RESULT

Net-Zero Database Costs: $0 ongoing database infrastructure spend achieved via immutable S3 base + delta reconciliation

✓ VERIFIED RESULT

100% Salesforce CRM Data Storage Saved: Zero custom object records consumed, saving hundreds of thousands in licensing

✓ VERIFIED RESULT

Sub-Millisecond Query Response: Instantaneous multi-field AST search and sorting across 500K records without server latency

✓ VERIFIED RESULT

Zero Upstream Rate-Limit Failures: Asynchronous middleware caching eliminated 100% of Connectbase 429 throttling collisions

07 // Architecture Blueprint

System Schematic & Data Flow

System Topology Blueprint
WebAssembly in Salesforce LWC: 500K+ Record Engine & Net-Zero DB Architecture
INTERACTIVE SCHEMATIC
STAGE 01 · ASYNC INGESTION, GZIP COMPACTION & AWS S3 NET-ZERO DATA STORAGEConnectbase CPQ API500K+ Pricing RowsRaw JSON: ~120MB+Rate-Limited Endpointasync pollMuleSoft / Async WorkerColumnar Schema CompactionGZIP Compression Engine98% Compression: 120MB ? 3.2MBstream .gzAmazon S3 · Net-Zero DB Bucketpricing_base.json.gz500K Base Records3.2MB (98% storage saved)quote_delta.json.gzOverrides Only (~12KB)RDS Database CostDIRECT HTTP/2 STREAM VIA S3 PRE-SIGNED URL (ZERO APEX HEAP OVERHEAD)Salesforce Apex ControllerMints 60s AWS S3 Pre-signed URL (0 KB payload in heap)STAGE 02 · SALESFORCE LIGHTNING WEB COMPONENT (LWC) · WEBASSEMBLY IN-MEMORY RUNTIME01 · BARE-METAL DECOMPRESSIONWebAssembly (Rust / C++) Core• Loaded via LWC Static Resource• Fallback: Pako JS Stream Decoder• Zero V8 Garbage Collection PausesSUB-30s DECOMPRESSION500,000+ records unpacked into linear memory02 · AST QUERY & DSA ENGINEIn-Memory AST Query Engine• Lexer, Parser & AST Bytecode Core• Complex Multi-Field Boolean Filter• Radix / Typed Array Index ScansSUB-MILLISECOND RETRIEVALInstant search & sort over 500K records03 · RUNTIME DELTA MERGE & GRIDDelta Reconciler & 60 FPS Grid• Manual Price / Margin Overrides• Runtime DSA Hash Merge (Base + Delta)• Virtualized Viewport (~40 DOM nodes)NET-ZERO DB MUTATIONOverrides save to S3 delta; 0 DB costMicro Delta Upload (delta.json.gz ~12KB)
SUB-30s COLD LOAD500,000+ records decompressed and indexed inside native LWC in under 30 seconds.
98% STORAGE REDUCTION120MB raw JSON collapsed to 3.2MB gzip stream stored on AWS S3.
NET-ZERO DATABASE COSTrelational database overhead: runtime DSA hash merge of immutable base + S3 delta.
ZERO APEX HEAP IMPACTPre-signed URLs stream binary data straight into browser memory, bypassing 6MB/12MB caps.

End-to-end systems architecture illustrating asynchronous Connectbase ingestion, GZIP compaction (98% storage saved), S3 Pre-Signed streaming (zero Apex heap), bare-metal WebAssembly decompression, in-memory AST search, and Net-Zero DB delta merge.

Text alternative for screen readers: Architecture flow: Connectbase API (Rate Limited) to Middleware GZIP Compactor via Async Ingest & Schema Flattening; AWS S3 Base Store (3.2MB) to LWC via Pre-Signed URL via Direct HTTP/2 Streaming (0 Apex Heap); WebAssembly Core (Rust/C++) to AST Query & Typed Array DSA via Sub-30s Decompress & Sub-ms Search; S3 Micro Delta (~12KB) to Runtime DSA Hash Merge via Net-Zero DB Mutation Engine

08 // Why It Matters

Architectural Conclusion

A platform's governor limits define where default conventions stop—not where engineering possibility ends. By compiling systems languages into browser WebAssembly and treating cloud storage as an immutable streaming substrate, we can push enterprise SaaS into computational regimes previously thought impossible.

Key Lessons for Platform Scale:
  • SaaS governor limits define where default conventions stop, not where architectural innovation ends.
  • WebAssembly enables browser-native execution speeds previously restricted to desktop C++ applications, unlocking high-density data processing inside enterprise web clients.
  • Net-Zero Database architectures (immutable compressed base + micro-delta reconciliation) can eliminate thousands in recurring cloud database costs while providing superior auditability and speed.
  • Direct-to-browser streaming via S3 pre-signed URLs liberates enterprise applications from middle-tier serialization bottlenecks and server memory caps.