1. Home
  2. Blog
  3. Multi-Tenant Ad Data Pipeline Architecture

Data Engineering

Multi-Tenant Ad Data Pipeline Architecture for SaaS Platforms

Multi-tenant ad data pipeline architecture for SaaS: tenancy models, fair Amazon Ads and Google Ads API quota scheduling, token isolation and backfills.

A multi-tenant ad data pipeline is the ingestion and modeling layer that pulls advertising data for many customers (tenants) through one codebase and one set of platform credentials, then keeps each customer's data separate, fresh and billable. Pulling Amazon Ads or Google Ads data for one account is a weekend project. Doing it for 400 accounts across three platforms, with each customer expecting yesterday's numbers by 8 a.m. in their own time zone, is a different system.

This guide is for founders, CTOs and engineering leads at ad-tech and ecommerce SaaS companies. It covers the data pipeline architecture decisions that matter once tenant count, not data volume, becomes the hard part: how to separate tenants in storage, how to share API quota fairly, how to isolate credentials, how to onboard a new account without starving everyone else, and how to see and price each tenant's footprint.

What changes when a multi-tenant ad data pipeline reaches hundreds of tenants

At five tenants, a cron job per platform and a shared database work. At hundreds, four things break at once.

  • Quota becomes a shared resource. Your application has one developer token, one Login with Amazon client or one Meta app. Limits are applied per account, per app, or both, and one tenant's backfill can throttle everyone's daily refresh.
  • Failure becomes partial. A run no longer simply succeeds or fails. It succeeds for 380 tenants, is throttled for 15 and fails authorization for 5. A single "pipeline OK" status hides the 20 customers who will email support tomorrow.
  • Onboarding competes with production. Every new customer wants 12 to 24 months of history on day one, which is often more API work than a week of incremental loads for everyone else combined.
  • Cost needs an owner. Warehouse compute, storage and API capacity are spent per tenant, but billed to you as one number. Without allocation, you cannot tell which plans are profitable.

None of this is exotic. It is the same set of problems agencies hit when they grow, which we covered in scaling Amazon agency data infrastructure. For a SaaS product the stakes are higher, because the pipeline is the product.

Tenancy models: shared tables, schema per tenant, warehouse per tenant

There are three common storage models. The AWS Well-Architected SaaS Lens calls the extremes "pool" (shared resources) and "silo" (dedicated resources), with mixes in between.

Shared tables with a tenant key

Every row carries a tenant_id, and every table is shared. This is the cheapest model to run and the easiest to evolve: one migration changes every tenant. The risk is a missing filter. Isolation must be enforced by the platform, not by developer discipline, using row-level security or secure views, and every query path must be tested for leakage.

-- Example: Snowflake-style row access policy on a shared fact table
CREATE ROW ACCESS POLICY tenant_isolation AS (row_tenant_id VARCHAR)
RETURNS BOOLEAN ->
  row_tenant_id = CURRENT_SESSION_TENANT();  -- resolved from the app's session context

ALTER TABLE fact_ad_performance_daily
  ADD ROW ACCESS POLICY tenant_isolation ON (tenant_id);

The function name above is illustrative: each warehouse exposes session context differently, so map it to your platform's mechanism.

Schema per tenant

Each tenant gets its own schema with identical tables. Isolation is easier to reason about, per-tenant deletion is a DROP SCHEMA, and some customers' security reviews prefer it. The cost is operational: 400 schemas means 400 copies of every migration, and cross-tenant analytics (benchmarks, model training) needs a union layer.

Warehouse or account per tenant

Each tenant gets a dedicated database, project or account, sometimes one the customer owns. This is the strongest isolation and the natural fit when customers demand that data lands in their own Snowflake or BigQuery. It is also the most expensive to operate, so reserve it for enterprise tiers.

Most products we see end up hybrid: raw landing and staging in shared, tenant-keyed tables, with a dedicated schema or account for the few customers whose contracts require it. Pick the model per layer, not once for the whole stack.

Fair scheduling: per-tenant and per-platform quotas

Each platform limits you differently, and the scheduler has to respect all of them at once.

  • Amazon Ads API: rate limits are dynamic and based on system load. A throttled call returns HTTP 429 with a Retry-After header in seconds, and Amazon recommends spreading report requests through the day. The newer reporting API in Amazon Ads API v1 applies its rate and concurrency limits per client ID, not per advertiser, so every tenant draws on one shared reporting budget.
  • Amazon SP-API: a token bucket per operation, mostly tracked per selling partner and application pair, so each seller account has its own bucket.
  • Google Ads API: queries per second are limited per customer ID and per Google Cloud project, and your access level sets a daily operations quota (currently 2,880 operations a day against production accounts at Explorer access, 15,000 at Basic, unlimited at Standard).
  • Meta Marketing API: Business Use Case limits are computed per ad account and scale with active ads.

The practical design is a two-level limiter. The outer level caps concurrency per platform and per credential (your app's global ceiling). The inner level gives each tenant a fair share, so one tenant cannot take more than its slice while others wait.

# Example scheduler config (illustrative)
platforms:
  amazon_ads:
    max_concurrent_requests: 40      # across all tenants, per region
    per_tenant_max_concurrent: 4
    honor_retry_after: true
  google_ads:
    max_concurrent_requests: 25
    per_tenant_max_concurrent: 3
    daily_operation_budget: 15000    # match your developer token's access level
priorities:
  - incremental_daily      # yesterday and the restatement window
  - onboarding_backfill    # new tenants, chunked
  - historical_repair      # reprocessing, lowest priority

Queue work as small, independent units (one tenant, one platform, one report, one date range) so a throttled unit can be retried without redoing the rest. Our ad platform integrations and Amazon Ads API development work is built on this pattern.

Credential and token isolation

Credentials are the most sensitive data a multi-tenant system holds: a leaked refresh token can read or change a customer's campaigns.

  • Encrypt per tenant. Store refresh tokens encrypted at rest with envelope encryption, ideally with a key per tenant or per tenant group, so one compromised key does not expose everyone.
  • Never log them. Scrub Authorization headers and token fields from logs, traces and error reports.
  • Scope workers. The worker running tenant A's job should only be able to decrypt tenant A's credentials for the duration of the job.
  • Track expiry. Amazon Ads now issues refresh tokens that expire 365 days after advertiser consent (for consents on or after July 30, 2026), so you need a per-tenant expiry date and a re-consent reminder before it lapses.

The SP-API vs Ads API guide covers why Amazon integrations typically need two authorization flows per customer, which doubles the tokens you manage.

Onboarding backfills and late data

A new tenant's history is the largest job you will run for them, so treat it as a separate, lower-priority workload.

  • Chunk the backfill. Split it into small date ranges (for example, 7 or 14 days per report request) and run them off-peak. Amazon's own guidance for its reporting endpoints is to request older data in smaller increments throughout the day rather than in large batches.
  • Show progress. Give the customer a status page: which months are loaded, which are queued. It prevents support tickets and sets expectations honestly.
  • Respect platform retention. Each API only serves a limited window of history, and that window differs by platform and report type. Check the current docs before promising a backfill length in sales conversations.
  • Re-pull the restatement window. Attributed conversions keep changing for days after the click. Every daily run should reload a trailing window (often 14 to 30 days, depending on the platform's attribution windows) and merge it, not just append yesterday.

Observability per tenant: freshness, row counts, failures

Global pipeline metrics hide tenant-level problems. Track health per tenant, per platform, per day.

-- Example: tenants whose Amazon Ads data is stale or suspiciously thin
SELECT
  t.tenant_id,
  MAX(f.report_date)                         AS latest_date,
  SUM(CASE WHEN f.report_date = CURRENT_DATE - 1 THEN 1 ELSE 0 END) AS rows_yesterday,
  AVG(r.rows_daily_avg_28d)                  AS rows_typical
FROM tenants t
LEFT JOIN fact_ad_performance_daily f
  ON f.tenant_id = t.tenant_id AND f.platform = 'amazon_ads'
LEFT JOIN tenant_row_baselines r
  ON r.tenant_id = t.tenant_id AND r.platform = 'amazon_ads'
WHERE t.status = 'active'
GROUP BY t.tenant_id
HAVING MAX(f.report_date) < CURRENT_DATE - 1
    OR SUM(CASE WHEN f.report_date = CURRENT_DATE - 1 THEN 1 ELSE 0 END)
       < 0.5 * AVG(r.rows_daily_avg_28d);

Alongside freshness and volume, record every failure with a reason class: throttled, auth revoked, platform error, schema change. Auth failures need a customer action (reconnect); throttling needs you to change scheduling. Our pipeline reliability practice treats these as separate alerts with separate owners.

Cost allocation per tenant

To price plans sensibly, measure what each tenant costs.

  • API work: count requests and report jobs per tenant and platform. This also tells you which tenants consume the most quota.
  • Warehouse compute: tag queries with the tenant ID (query tags or labels, depending on the warehouse) and roll up credits or bytes processed per tenant.
  • Storage: partition or cluster by tenant so per-tenant storage is measurable and deletion is cheap.

Compare the result against plan revenue each month. Tenants with many ad accounts and long histories are usually where margin disappears.

Build vs buy for the ingestion layer

Off-the-shelf connectors are fast to start with, but most were designed for one company syncing its own accounts, not for a product syncing thousands of customers' accounts under one app. The questions to ask: can it run under your own developer credentials, can you control scheduling per tenant, can you see per-tenant failures, and can you deploy it where your data must live?

When the answers are no, a custom ingestion layer usually pays off. For Protego, an Amazon enforcement-risk SaaS, we built the SP-API ingestion on AWS Lambda, SQS, S3, PostgreSQL and EventBridge: 30+ seller accounts connected, 20+ enforcement risk signals normalized across Amazon reports, and about 5 minutes from signal ingestion to risk score update. At agency scale, the pipelines and automation engine we built for Tinuiti kept pace as they grew from 35 to 3,500+ brands, with no second rebuild needed.

If you are building an ad-tech product on Amazon, Google or Meta data, see how we work with ad-tech and SaaS teams, or look at our Amazon Ads data pipelines. If you would rather keep the build in-house, you can hire data engineers who have run these pipelines. To talk through your tenancy model and quotas, book a free 30-minute ad data review.

Frequently asked questions

How long does onboarding a new ad account take?

Connecting the account and loading recent data is usually quick once the customer completes the OAuth consent. The historical backfill is what takes time, because it competes for the same API quota as every other tenant and has to respect each platform's report limits and retention window. Plan for the backfill to run in the background over hours or days, and show customers its progress rather than promising a fixed time.

Do we need a separate developer app or token for each customer?

No. The normal pattern is one approved application per platform (a Login with Amazon client for Amazon Ads, a developer token for Google Ads, a Meta app for the Marketing API), and each customer authorizes that application to access their accounts through OAuth. You then store one set of tenant credentials per customer, encrypted and isolated, while the application credentials stay with you.

Can each customer get their data in a warehouse they own?

Yes, and enterprise customers increasingly ask for it. You can either load directly into the customer's own Snowflake, BigQuery, Redshift or Databricks account, or keep a shared model internally and publish each tenant's tables to them through the warehouse's native sharing features. Price the dedicated option as a higher tier, because it adds deployment and monitoring work per customer.

Can you build the Amazon Ads API integration for our SaaS product?

Yes. We build Amazon Ads API and SP-API integrations for ad-tech and SaaS teams under your own developer application: OAuth onboarding, report scheduling within rate limits, token storage and the warehouse model, with the code and documentation handed over to you. See Amazon Ads API development.

Sources

Want this built for you?

See how we approach it in ad data for ad-tech & SaaS, or talk to an engineer about your accounts.

Talk to an engineer