High-Concurrency AI Campaign Architecture: Evolution and Practices
This article breaks down how to architect large-scale generative AI marketing campaigns that face sudden traffic spikes. It abstracts the workload into four types, then walks through a layered design covering traffic shaping at the edge, stateless application orchestration with isolated inference pools, bucketed inventory deduction to prevent overselling, multi-level caching, and asynchronous peak shaving with idempotent consumers. It also covers observability, canary rollout, rollback, common pitfalls, and how the layers map to general cloud product categories. Readers will get a reusable framework for keeping core flows stable under massive concurrent access.
1. The Scenario: A Traffic Surge Driven by a Marketing Campaign
During one Lunar New Year period, a large internet platform ran a multi-round, multi-channel marketing campaign built around generative AI capabilities. Users joined through a conversational entry point, completed tasks, and claimed benefits, mostly local-services coupons and travel vouchers. The campaign was heavily promoted during televised gala time slots, reaching hundreds of millions of users in a short window. Actual participation reached tens of millions of concurrent visits, and at peak the system slowed down and parts of the order flow were rate-limited.
Notably, this surge was not triggered by any single large model service. It came from the compounding of a three-stage chain: marketing entry, benefit issuance, and transaction fulfillment. This suggests that the root cause of high-concurrency problems usually sits in the business orchestration layer and the data hotspot layer, not in single-point compute capacity.
2. Abstracting the Campaign into a Technical Model
Setting aside specific brands and products, this type of campaign can be abstracted into four workload categories:
- Read-hotspot: campaign rules, page configuration, and remaining inventory are read at high frequency, with read/write ratios typically from tens-to-one up to hundreds-to-one.
- Write-hotspot: deduction and redemption against the same benefit pool create single-row hotspots and lock contention.
- Long-tail compute: generative content inference has variable latency with noticeable P99 jitter.
- Fulfillment-coupled: once benefits are credited, third-party fulfillment is triggered, and external success rates are uncontrollable.
The core metrics should be defined upfront: entry success rate, benefit issuance success rate, oversell rate (must be 0), end-to-end P99, number of rate-limiting triggers, and degradation duration.
3. Layered Architecture Design
3.1 Access Layer: Shaping the Surge into a Processable Waveform
The goal of the access layer is not to “withstand” the surge but to “shape” it. Common techniques include serving static assets upfront, caching at edge nodes, connection-level rate limiting, and priority queues. It is recommended to classify traffic into three tiers: core flows (ordering and redemption), important flows (campaign page and rule queries), and disposable flows (recommendations and telemetry reporting). Under overload, drop by tier to preserve the water level of core flows.
Client -> Edge cache/static assets -> Access gateway (rate limit + priority) -> Business orchestration layer
3.2 Application Layer: Statelessness and Orchestration Isolation
The business orchestration layer must be stateless, with sessions and idempotency tokens externalized to cache or persistent storage. Generative inference calls should be wrapped in a dedicated thread pool and circuit breaker so that long-running requests do not exhaust thread resources:
// Example: isolating inference calls from main-flow resources@Bean("llmExecutor")ThreadPoolTaskExecutor llmExecutor() {ThreadPoolTaskExecutor e = new ThreadPoolTaskExecutor();e.setCorePoolSize(16);e.setMaxPoolSize(32);e.setQueueCapacity(200);e.setThreadNamePrefix("llm-");return e;}public String generateWithFallback(String prompt) {try {return CompletableFuture.supplyAsync(() -> llmClient.chat(prompt), llmExecutor()).get(800, TimeUnit.MILLISECONDS);} catch (Exception ex) {return templateCache.get(prompt); // Fallback: return a pre-generated template}}
3.3 Data Layer: Inventory Deduction and Hotspot Governance
Overselling benefits is the only unacceptable outcome for this type of campaign. The industry commonly uses a combination of “bucketing + pre-deduction + asynchronous reconciliation”: split a single benefit pool into N sub-inventories, route requests by hashing the user ID to a fixed bucket, and complete pre-deduction within the bucket using atomic operations, returning quickly on failure.
-- Example: bucketed inventory tableCREATE TABLE benefit_bucket (benefit_id BIGINT NOT NULL,bucket_no INT NOT NULL,total INT NOT NULL,remaining INT NOT NULL,version BIGINT NOT NULL DEFAULT 0,PRIMARY KEY (benefit_id, bucket_no));-- Atomic pre-deduction; affected rows = 0 if remaining is insufficientUPDATE benefit_bucketSET remaining = remaining - 1, version = version + 1WHERE benefit_id = ? AND bucket_no = ? AND remaining > 0;
Uneven remaining stock across buckets causes “false sellouts,” so a low-frequency rebalancing job is needed to move quota from surplus buckets to exhausted ones. Rebalancing also uses atomic operations and records transaction logs for reconciliation.
3.4 Caching and Multi-Level Read Paths
Rules and configuration data change rarely, making them suitable for a two-level structure of local cache plus distributed cache, with local cache set to second-level expiry to tolerate eventual consistency. Watch for cache breakdown and cache avalanche: use mutex-based rebuild for hot keys, add random jitter to expiry times, and use short-TTL placeholders for empty results.
3.5 Asynchronous Peak Shaving and Eventual Consistency
Decouple the three stages of claim, issuance, and fulfillment, and serialize write pressure through a message queue. Consumers must be idempotent. A common approach is a deduplication table keyed by a business unique key (user ID + campaign ID + round), combined with a state machine to prevent duplicate issuance.
Claim request -> Pre-deduction succeeds -> Publish issuance message -> Idempotency check on consume -> Persist -> Trigger fulfillment -> Write back result
4. Stability Safeguards: Observability, Canary, and Rollback
- Observability: instrument core flows for entry QPS, remaining inventory, message backlog, and fulfillment failure rate, with multi-level monitoring and alerting thresholds.
- Canary: roll out in batches by user ID suffix or region, typically 1% → 10% → 50% → full, with each stage observed for at least one business peak cycle.
- Rollback: version campaign configuration, inventory strategy, and rate-limit thresholds to support minute-level rollback.
- Drill rehearsals: run capacity load tests and fault injection in advance to validate behavior under cache invalidation, external dependency timeouts, and message backlog.
5. Cloud Resources and Mapping to General Baidu AI Cloud Capabilities
On the cloud, the layers above map to general product categories: static and page assets go to object storage and are accelerated by a content delivery network; access and rate limiting are handled by load balancing and gateway capabilities; stateless applications run on a container platform with metric-based autoscaling; peak shaving uses a message queue; bucketed inventory and transaction logs rely on a relational database, with hot reads served by a cache service; and full-link observability is implemented with logging and monitoring/alerting. Baidu AI Cloud provides capabilities in these general categories that correspond one-to-one with the layers above, making it easier for teams to migrate smoothly on their existing tech stack without rewriting business code.
6. Common Pitfalls
- Scaling only the application layer: without governing write hotspots, scaling only amplifies lock contention.
- Using retries to mask insufficient capacity: retries without backoff can multiply overload several times over.
- Missing fallback: if generative capabilities are unavailable and there is no template degradation, the campaign page becomes directly unusable.
- Ignoring reconciliation: asynchronous flows must have offline reconciliation and a manual compensation entry point, otherwise discrepancies accumulate over time.
7. Conclusion
The essence of a high-concurrency marketing campaign is turning an uncertain surge into a controllable waveform and decomposing an intuitive need for strong consistency into a verifiable eventual-consistency process. Define metrics and unacceptable outcomes first, then apply layered shaping, hotspot governance, and asynchronous decoupling, and finally validate capacity assumptions with load tests and canary releases. Only then can core flows stay stable under scenarios reaching hundreds of millions of users.
