出海数字营销宝典 Logo
出海数字营销宝典evaoo.com

Google Merchant API Concurrent Requests & gRPC Channel Pool Guide: Replacing custombatch, Configuring gRPC Channel Pools & Dynamic Quota Governance

2026-11-11Google Merchant Center Docs · Evaoo Feed Engineering Lab9 min read

Google Merchant API Concurrent Requests & gRPC Channel Pool Guide: Replacing custombatch, Configuring gRPC Channel Pools & Dynamic Quota GovernanceGoogle Merchant API Concurrent Requests & gRPC Channel Pool Guide: Replacing custombatch, Configuring gRPC Channel Pools & Dynamic Quota Governance

Migration Focus: Refactoring for gRPC Concurrency After custombatch Retirement

When migrating from Content API for Shopping to Merchant API, products.custombatch, productstatuses.custombatch, and inventory.custombatch have all been removed.

You do not need to fall back to sequential single-item calls. Built on HTTP/2 multiplexing and binary Protobuf serialization, Merchant API natively supports asynchronous gRPC concurrency with higher throughput and tighter tail latency than legacy JSON custombatch. However, there is one hard transport ceiling: each single gRPC connection allows at most 100 concurrent streams by default. Without configuring a client-side Channel Pool, excess async coroutines queue locally and stall.


Google Merchant API Migration Series Navigation

  1. Part 1 (Architecture & Sunset Timeline): Google Merchant API Architecture Guide: Replacing Content API for Shopping, 2026 Sunset Timeline & Modular Upgrade Plan
  2. Part 2 (Migration Order & Read/Write Split): Google Merchant API Start Your Migration SOP: Sub-API Priority Order, ProductInput Write/Read Split & Preventing "Offer Stealing"
  3. Part 3 (Authentication & GCP Architecture): Google Merchant API Authentication & GCP Project Guide: IAM Key Setup, registerGcp Registration & Zero-Downtime Cutover
  4. Part 4 (Current — High Concurrency & Quota Governance): Google Merchant API Concurrent Requests & gRPC Channel Pool Guide: Replacing custombatch, Configuring gRPC Channel Pools & Dynamic Quota Governance

Chapter 1: Why custombatch Was Retired & the 100-Stream-per-Channel Limit

1.1 Three Engineering Flaws of Legacy custombatch

Under HTTP/1.1, Content API introduced the application-level custombatch endpoint to amortize per-request TCP and TLS handshakes by packing up to 500 JSON product operations into a single multi-megabyte request body. In high-volume production systems, that model created three chronic bottlenecks:

  • Head-of-Line Blocking: If SKU #499 in a batch triggers slower backend validation, the 498 SKUs that already finished processing must wait for the entire HTTP response to complete.
  • Complex Partial-Failure Retries: When 480 items succeed, 15 hit 429 rate limits, and 5 fail schema validation, client code must parse nested batchId arrays, isolate only the 15 throttled entries, re-assemble a new batch payload, and schedule backoff.
  • Heavy JSON Serialization Overhead: Parsing multi-megabyte JSON request and response envelopes consumes excessive client heap memory and gateway CPU.

1.2 gRPC Multiplexing & the 100 Concurrent Streams Ceiling

Merchant API natively supports gRPC running over HTTP/2. Over HTTP/2, many asynchronous requests (Streams) share one persistent connection bidirectionally in parallel: each successful call resolves immediately, and each failed call runs independent exponential backoff.

When designing high-throughput clients, keep Google Front End's (GFE) connection limit in mind:

Connection Ceiling: A single underlying HTTP/2 (gRPC Channel) connection carries at most 100 in-flight concurrent streams at the same time (Max 100 Concurrent Streams per Connection).

If a flash-sale repricing job needs 1,500 concurrent in-flight requests, but your service initializes a default singleton client (backed by just 1 gRPC Channel), requests #101 through #1,500 queue in client memory and throughput collapses.


Chapter 2: Channel Pool Capacity Sizing & the poolSize = 30 Derivation

To saturate available concurrency while preserving headroom for network jitter, Google's Refactor code for concurrent requests specification defines a sizing formula targeting 50% channel pool utilization:

  1. Compute target requests per second (RPS): RPS = target updates per minute / 60
  2. Apply Little's Law to estimate peak concurrent in-flight streams: in-flight streams = RPS * average round-trip latency (seconds)
  3. Compute the minimum channels required at 100% capacity: min channels = in-flight streams / 100
  4. Scale to 50% target utilization for the recommended poolSize: recommended poolSize = ceil(min channels / 0.50)

Walking through the official benchmark example:

  • Target throughput is 60,000 SKU updates per minute, which equals 1,000 RPS.
  • Measured average end-to-end latency for productInputs:insert is 1.5 seconds.
  • Concurrent in-flight streams equal 1,000 * 1.5 = 1,500 streams.
  • At 100 streams per channel, full saturation requires 1,500 / 100 = 15 channels.
  • Applying the recommended 50% utilization headroom: 15 / 0.50 = 30, yielding poolSize = 30.

Use the gRPC Channel Pool & 2x Dynamic Quota Calculator below to input your catalog size, peak updates per minute, and measured latency, calculate your exact poolSize, and copy production-ready Node.js, Python, Java, or HTTP Multipart code:

Merchant API Channel Pool Calculator

Chapter 3: Async Concurrency Code Patterns Across Backend Languages

Whether your commerce backend runs on Java, Node.js, Python, or PHP, Google recommends using the official Google Cloud Merchant API client libraries (which default to gRPC), explicitly configuring a channel pool, and bounding in-flight concurrency with semaphores or async queues.

3.1 Java: Configuring setPoolSize(30) with InstantiatingGrpcChannelProvider

The official Java client library supports multi-channel pooling natively. By configuring poolSize on InstantiatingGrpcChannelProvider, you can fan out thousands of non-blocking ApiFuture calls in parallel:

JAVA35 lines
1import com.google.api.core.ApiFuture;
2import com.google.api.core.ApiFutures;
3import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
4import com.google.shopping.merchant.products.v1.InsertProductInputRequest;
5import com.google.shopping.merchant.products.v1.ProductInput;
6import com.google.shopping.merchant.products.v1.ProductInputsServiceClient;
7import com.google.shopping.merchant.products.v1.ProductInputsServiceSettings;
8import java.util.ArrayList;
9import java.util.List;
10
11public class MerchantHighThroughputSync {
12 public static List<ProductInput> syncBatchConcurrently(
13 List<InsertProductInputRequest> requests, int poolSize) throws Exception {
14 // 1. Configure gRPC Channel Pool at 50% target utilization (e.g., 30 for 60,000 updates/min)
15 InstantiatingGrpcChannelProvider channelProvider =
16 ProductInputsServiceSettings.defaultGrpcTransportProviderBuilder()
17 .setPoolSize(poolSize)
18 .build();
19
20 ProductInputsServiceSettings settings =
21 ProductInputsServiceSettings.newBuilder()
22 .setTransportChannelProvider(channelProvider)
23 .build();
24
25 // 2. Reuse a long-lived Client instance (never recreate Client inside a loop)
26 try (ProductInputsServiceClient client = ProductInputsServiceClient.create(settings)) {
27 List<ApiFuture<ProductInput>> futures = new ArrayList<>(requests.size());
28 for (InsertProductInputRequest req : requests) {
29 futures.add(client.insertProductInputCallable().futureCall(req));
30 }
31 // 3. Aggregate all async responses non-blockingly
32 return ApiFutures.allAsList(futures).get();
33 }
34 }
35}

3.2 Python: Concurrency Control with ProductInputsServiceAsyncClient & asyncio.Semaphore

In Python, use the AsyncClient class (backed by grpc.aio), shard requests across a pool of client instances to bypass the 100-stream ceiling per channel, and cap client-side in-flight coroutines using asyncio.Semaphore:

PYTHON35 lines
1import asyncio
2from google.shopping.merchant_products_v1 import (
3 InsertProductInputRequest,
4 ProductInput,
5 ProductInputsServiceAsyncClient,
6)
7
8async def sync_products_async(
9 account_id: str,
10 datasource_id: str,
11 items: list[ProductInput],
12 pool_size: int = 8,
13 max_in_flight: int = 400,
14):
15 # Build a multi-channel client pool to bypass the 100-stream limit per channel
16 clients = [ProductInputsServiceAsyncClient() for _ in range(pool_size)]
17 semaphore = asyncio.Semaphore(max_in_flight)
18 parent = f"accounts/{account_id}"
19 data_source = f"accounts/{account_id}/dataSources/{datasource_id}"
20
21 async def _push_one(idx: int, product_input: ProductInput):
22 client = clients[idx % pool_size]
23 async with semaphore:
24 req = InsertProductInputRequest(
25 parent=parent,
26 data_source=data_source,
27 product_input=product_input,
28 )
29 return await client.insert_product_input(request=req)
30
31 try:
32 tasks = [_push_one(i, item) for i, item in enumerate(items)]
33 return await asyncio.gather(*tasks, return_exceptions=True)
34 finally:
35 await asyncio.gather(*(c.transport.close() for c in clients), return_exceptions=True)

3.3 PHP & SDK-Free Runtimes: GuzzleHttp\Promise & HTTP multipart/mixed Batching

  • PHP Async Concurrency: Use the async methods on the official google/shopping-merchant-products client together with GuzzleHttp\Promise\Utils::settle($promises)->wait() to dispatch requests concurrently.
  • Clientless REST Environments (HTTP Batching): If lightweight serverless edge functions cannot bundle gRPC dependencies, Merchant API still supports standard Google Cloud HTTP multipart/mixed batch endpoints (POST https://merchantapi.googleapis.com/batch/{SUB_API}/{VERSION}, with an outer header Content-Type: multipart/mixed; boundary=batch_evaoo and Content-Type: application/http on each inner part).
  • Quota Billing Caveat: HTTP multipart/mixed reduces outer TCP round trips only—it does not save API quota. A single HTTP batch envelope containing 50 productInputs:insert sub-requests still deducts 50 quota units on the server.

Chapter 4: Quota API Dynamic Limits, Automatic 2x Scaling & 429 Backoff

Before load-testing your channel pool, review Google's Quotas and limits specification to align with quota accounting and rate-limit enforcement:

Quota ItemOfficial Mechanism & Reset WindowEngineering Best Practice
Daily Total Quota (quotaLimit)Tracked independently per method group (QuotaGroup, such as the productInputs write group or products read group); resets daily at 12:00 PM UTC (20:00 Beijing Time).Schedule full catalog reconciliation jobs after 12:00 PM UTC (20:15 Beijing Time) and send incremental diff updates for price/inventory changes during peak hours. Compare legacy and new schemas with the Side-by-Side Document & API Schema Diff Workbench.
Per-Minute Burst Cap (quotaMinuteLimit)Enforced in real time over a rolling 60-second window rather than resetting on fixed minute boundaries.Avoid exhausting an entire minute's allowance at second 0; smooth consumer traffic in your message queue using a Token Bucket rate limiter.
Automatic 2x Daily Offer Quota ScalingFor product and inventory writes, the system dynamically scales daily capacity based on the account's approved, active Published Offers—granting up to roughly 2x your active offer count per day.Important: Only approved, live offers contribute to 2x capacity scaling. Repeatedly pushing incomplete or disapproved SKUs does not raise quota and harms account health.
Dedicated Batch Method Billing ExceptionsStandard HTTP multipart/mixed charges 1 quota unit per inner sub-request; dedicated native batch endpoints (such as regions:batchCreate, regions:batchUpdate, and regions:batchDelete) count as only 1 quota call per invocation.When maintaining multi-ZIP regional delivery zones (Regions), prefer native :batch* endpoints to conserve quota.
MCA Parent / Sub-Account Quota IsolationStandalone accounts maintain independent quota pools; under an MCA hierarchy, calls targeting a sub-account draw from that sub-account's quota, inspectable in real time via GET .../quota/v1/accounts/{ID}/quotas.Have distributed workers poll quotas.list before starting. When quotaUsage / quotaLimit > 85%, automatically shed low-priority audit jobs to protect inventory de-listing and repricing queues.

4.1 Exponential Backoff Strategy for 429 RESOURCE_EXHAUSTED

When burst traffic hits quotaMinuteLimit and returns HTTP 429 (with error detail QUOTA_REQUEST_RATE_TOO_HIGH), never retry in a tight unthrottled loop. Implement Exponential Backoff with Full Jitter:

  • Wait duration on retry attempt n: sleep_ms = random(0, min(60000, 1000 * 2^n)).
  • Attach clean ValueTrack tracking parameters to landing page URLs synced to GMC (generated via our Google Ads & PMax Dynamic Macro UTM Builder) so high-frequency catalog updates preserve accurate attribution across Google Ads and GA4.

6-Step Pre-Sunset Checklist Before August 18, 2026

Before cutting over to production, engineering and acquisition teams should verify all 6 steps below:

  1. Enable API & Register GCP: Enable merchantapi.googleapis.com in the Google Cloud Console, run developerRegistration:registerGcp once, and verify the human alert email invitation (see Part 3).
  2. Audit DataSources to Prevent Stealing: Call datasources/v1 to list all existing Primary and Supplemental data sources and backfill offerId -> dataSource mappings into your local database to avoid Offer Stealing (see Part 2).
  3. Upgrade Key Encoding & Micros: Update composite product key builders to use ~ delimiters (with unpadded base64url encoding across the full key when reserved characters appear) and convert prices to amountMicros (see Part 1).
  4. Switch to CQRS & Load-Test Channel Pools: Route catalog writes to productInputs, move disapproval monitoring to embedded Product.productStatus and notifications push events, and size gRPC poolSize at 50% target utilization.
  5. Migrate MCQL Report Views: Rewrite queries to prefix-free snake_case views and adopt ucp_agentic_performance_view where needed to monitor AI shopping agent traffic.
  6. Drain Legacy Endpoint Traffic: Monitor GCP API metrics and drive shoppingcontent.googleapis.com request volume to zero before August 18, 2026.

Further Reading: Explore additional Google Ads and product feed engineering playbooks in the Evaoo Digital Marketing · Google Hub.

Merchant APIgRPCHigh-Concurrency ArchitectureGoogle Merchant CenterPerformance OptimizationQuota GovernanceNode.jsPython

Found this actionable? Copy standard citation & summary

Formatted with canonical attribution link and executive summary—ready for Slack, Notion, or LLM context.