Samsung Cut Pricing Latency 90x With Lambda Response Streaming

Samsung Cut Pricing Latency 90x With Lambda Response Streaming

Cloud Platform Engineering

Flash sale price discrepancies aren’t a UX annoyance — they’re a trust problem at scale. Samsung.com needed to display real-time prices for 30+ product variants simultaneously on listing pages with sub-100ms latency. Their legacy system delivered 4,500ms P90 and prices that lagged reality by an hour. The solution is a Lambda Response Streaming architecture worth replicating.

The Number

90x
improvement in P90 latency — from 4,500ms to 50ms

The 90x latency gain wasn’t achieved in one step. Samsung’s team worked through four optimization phases: eliminating the VPC overhead brought P90 from 4,500ms to 1,000ms. Adding HTTP/2 to CloudFront dropped it to 218ms. The final phase — CloudFront caching with a 95% hit ratio — reached 50ms at P90 and 150ms at P99.

How the Legacy Architecture Failed

The old system maintained a “Data Aggregation” middleware layer that precomputed every possible product combination — 30 products multiplied by variants, offers, and add-ons produced thousands of records per page that were mostly never requested. A cron job synchronized this to customer-facing pages hourly, creating a structural 1-hour gap between the authoritative pricing engine and what customers saw. Flash sales launched with the wrong prices, and the fix required waiting for the next scheduled sync.

This is a common architectural smell in high-traffic e-commerce: stateful caches that trade correctness for throughput end up trading both once traffic patterns change.

The Streaming Architecture

Samsung dismantled the aggregation layer and replaced it with a stateless streaming pattern using three AWS components:

AWS Lambda Response Streaming fans out 30 parallel requests to the pricing backend without buffering the complete response. Data streams immediately as the pricing engine returns it, using NDJSON (newline-delimited JSON) format that clients can parse incrementally rather than waiting for a complete payload.

GZIP compression at Level 1 reduces response size by 76% without meaningful CPU overhead — the tradeoff of speed versus compression ratio favoring speed at this scale.

Amazon CloudFront serves as the edge caching layer. The key implementation detail: instead of non-cacheable POST requests, the team developed a dense query string format (g=group1(p=SKU-A:1:p=SKU-B:2)) that fits complex request data within ~800 bytes, keeping requests GET-compatible and therefore cacheable. A 5-minute default TTL, with headers allowlisted for custom pricing variants, produces the 95% cache hit ratio.

The infrastructure impact was dramatic: the compute fleet shrank from 100+ auto-scaled instances during peak events to 5–10 Lambda functions. Maintenance complexity dropped proportionally.

What It Signals for Platform Teams

The architectural insight generalizes: stateful middleware caches that aggregate from authoritative sources inevitably drift. The better pattern is a stateless orchestration layer that queries sources on-demand and offloads caching to a purpose-built edge layer (CloudFront, Fastly, or equivalent). The streaming component solves the latency problem that usually makes on-demand aggregation too slow.

The pattern applies directly to product catalogs, inventory systems, recommendation engines, and any service aggregating multiple backend responses in real time. The Amazon AWS architecture blog post includes the Lambda streaming handler code patterns and CloudFront cache policy configuration, making this replicable without a full architectural redesign.

The So What

If your team runs a stateful caching layer between your authoritative data and customers, this architecture is worth stress-testing. The 90x latency improvement came not from raw hardware investment but from removing a structural bottleneck — the hourly sync — that made every other optimization harder. Teams with CloudFront already in place can implement the streaming Lambda pattern incrementally. The cache compression and request format work are the nuanced implementation details; the CloudFront TTL policy is the part that produces the 95% hit ratio.

Source: AWS Architecture Blog

Content created with AI assistance and reviewed for accuracy.

💬

Join the conversation

Stack Insiders is our free community for readers who want to go deeper — share resources, ask questions, and connect with others across every vertical we cover.

Join Stack Insiders →

Newsletter coming soon.

Curated digests across AI, biohacking, photography, travel, and more. Be the first to know when we launch.