Dev guide :: System Design - Data Scraping Service

System Design — Data Scraping Service

1. Requirements and scope

Design an API that lets clients submit a public URL, obtain a jobId, track processing, and retrieve structured data (for example, a product's name, price, currency, availability, and description).

Discussed constraints: asynchronous processing, HTML and JavaScript pages, potentially large results, a peak of 10,000 jobs/minute, an illustrative average duration of 8 s/job, a P95 target below 60 s under normal load, per-domain limits, SSRF security, crash recovery, and control of LLM costs.

Assumptions to confirm during the interview: client authentication and quotas, output formats and schemas, expected SLA and freshness, daily volume, retention, legal and geographical constraints, target cost, authorization to access sites, privacy requirements.

2. Overall architecture

flowchart TD
    Client[API clients] --> LB[Load Balancer]
    LB --> API[Stateless API]
    API --> Auth[Auth / quotas / URL validation]
    Auth --> DB[(PostgreSQL: jobs and leases)]
    Auth --> Cache[(Snapshot and active job cache)]
    Auth --> Q[(Durable queue)]
    Q --> Scheduler[HA domain-aware schedulers]
    Scheduler <--> Limits[(Shared state: quotas / cooldowns)]
    Scheduler --> H[HTTP worker pool]
    Scheduler --> B[Browser worker pool]
    H --> Egress[Egress proxy / SSRF filtering]
    B --> Egress
    Egress --> Internet[Public sites]
    H --> Extract[JSON-LD / DOM / LLM extraction]
    B --> Extract
    Extract --> Validate[Validation + provenance]
    Validate --> Store[(Object storage: snapshots / results)]
    Validate --> DB
    DB --> API
    Store --> API
    API --> Client
    API -.-> Telemetry[Logs / metrics / traces]
    Scheduler -.-> Telemetry
    H -.-> Telemetry
    B -.-> Telemetry
    Extract -.-> Telemetry

Clarification: workers must not have unrestricted access to PostgreSQL or the internal network. Necessary access is segmented and restricted. The diagram is logical, not an exhaustive network diagram.

3. API and first asynchronous version

Proposal: the client submits a URL; the server creates a durable job, returns 202 Accepted, and the client then polls. The API does not block while scraping takes place.

http
POST /scrapings
Content-Type: application/json

{"url":"https://example.com/product/123","fields":["name","price"]}

HTTP/1.1 202 Accepted
{"jobId":"J123","status":"pending"}
http
GET /scrapings/J123
GET /scrapings/J123/result

GET /scrapings/{id} returns a state (pending, working, completed, failed, optionally expired), timestamps, and non-sensitive error information. GET .../result returns the result only when it is ready, or an explicit unavailable state.

sequenceDiagram
    participant C as Client
    participant A as API
    participant D as DB
    participant Q as Queue
    participant W as Worker
    participant O as Object Storage
    C->>A: POST /scrapings
    A->>D: Create pending job
    A->>Q: Publish work reliably
    A-->>C: 202 + jobId
    Q->>W: Dispatch job
    W->>O: Write result
    W->>D: Set completed + result_key
    W->>Q: ACK
    C->>A: GET /scrapings/J123
    A->>D: Read state
    A-->>C: completed
    C->>A: GET /scrapings/J123/result
    A->>O: Read result
    A-->>C: JSON

Reliability point: creating the job in the DB and publishing to the queue is not automatically an atomic operation. Solutions: a transactional outbox at creation time, or periodic reconciliation of unpublished pending jobs. Do not return a job as accepted unless durable handling is guaranteed.

4. Queue, workers, and recovery

A queue stores jobs; it does not “spawn” workers. An orchestrator/autoscaler adjusts a bounded pool. Jobs must be persisted and replayable. Monitoring distinguishes slow jobs from abandoned jobs using a lease renewed by heartbeat.

flowchart TD
    API[API] --> Q[(Durable queue)]
    Q --> W[Worker pool]
    Q -.-> M[Autoscaler]
    M -->|Scale min / max| W
    W --> DB[(Jobs: lease / heartbeat / attempts)]
    R[Reconciler] --> DB
    R -->|Expired lease: retry| Q

Checkpointing ≠ idempotence: checkpointing saves reusable stages (HTML, rendered DOM, extraction); idempotence allows re-execution without unwanted side effects. Not every small operation needs a checkpoint: each write has a cost.

5. Capacity planning and scaling

For 10,000 jobs in 60 s, the incoming rate is 10,000 / 60 ≈ 166.7 jobs/s. If each job occupies a processing slot for 8 s, the theoretical average concurrency needed to keep up is 166.7 × 8 ≈ 1,334 slots (Little's law in steady state).

This figure is not a machine count: a process can run multiple concurrent I/O operations, while Chromium can consume a lot of RAM. P95 latency, variance, and domain constraints require headroom and load testing. A temporary backlog may be acceptable depending on the SLA.

Separate the pools:

flowchart LR
    Q[(Jobs)] --> R{Is fetch sufficient?}
    R -->|Yes| H[HTTP pool: I/O intensive]
    R -->|No / JS required| B[Browser pool: CPU/RAM intensive]
    H --> E[Extraction]
    B --> C[Reused Chromium + isolated context]
    C --> E
    E --> S[(Results)]

Reusing browser processes can reduce startup costs; create isolated contexts per job, clear cookies and local storage, set time/memory limits, and recycle processes.

Autoscaling: queue depth and age, P95 waiting time, arrival/departure rates, active jobs, CPU/RAM, browser saturation, errors, and timeouts. Bottlenecks: DB (I/O, locks, connections), queue, network, remote sites, browsers, LLM, object storage. The target covers waiting + execution, not just worker duration.

6. Extraction and structuring

Prefer inexpensive deterministic methods and merge fields rather than discarding a partial extraction.

flowchart TD
    HTML[HTML / rendered DOM] --> JL[JSON-LD / Schema.org]
    HTML --> META[Open Graph / metadata]
    HTML --> DOM[DOM: CSS / XPath / heuristics]
    JL --> Merge[Merge candidates + provenance]
    META --> Merge
    DOM --> Merge
    Merge --> Missing{Required fields missing?}
    Missing -->|No| V[Validation]
    Missing -->|Yes| LLM[LLM on relevant fragments]
    LLM --> V
    V --> Out[Structured JSON + quality]

JSON-LD: HTML blocks <script type="application/ld+json"> that can expose Product, Offer, Article, etc. objects. They are useful but sometimes absent, incomplete, or outdated.

Possible tools: Cheerio (Node.js), Beautiful Soup and lxml (Python), Playwright for JS pages, Readability for articles. They help parse and select content, but do not necessarily infer business semantics.

LLM as a last resort: send only relevant fragments, request schema-constrained JSON and field provenance, and limit tokens and the number of attempts.

7. Data accuracy and validation

Example: a page displaying a current price of €129.99, a crossed-out previous price of €179.99, and “out of stock.” An LLM may return syntactically valid but semantically incorrect JSON (179.99, in_stock).

flowchart TD
    X[Candidate fields] --> Schema[JSON / type / schema validation]
    Schema --> Evidence[Evidence present in source]
    Evidence --> Context[DOM context: crossed-out price / stock]
    Context --> Cross[Compare sources]
    Cross --> Score[Quality score and ambiguities]
    Score --> Decision{Sufficient confidence?}
    Decision -->|Yes| OK[Accept + provenance]
    Decision -->|No| Retry[Targeted extraction if useful]
    Retry --> Schema
    Decision -->|No, budget exhausted| Partial[null / partial / explicit error]

Checking that a quotation appears in the document is necessary but insufficient: the old price appears there too. Context must be interpreted. Confidence scores are not reliable probabilities without empirical calibration. Avoid invented values; return explicit uncertainty.

8. SSRF security

Scraping user-supplied URLs creates a risk of Server-Side Request Forgery: access to localhost, private networks, or cloud metadata endpoints (e.g. 169.254.169.254).

Defense in depth: robust URL parser; http/https schemes only; allowed ports; destination IP resolution and validation (including IPv4/IPv6, private, link-local, loopback, and special ranges); checks on every redirect and connection; DNS rebinding protection; egress proxy/firewall; network isolation and browser sandboxing, including subresources and iframes; timeouts, maximum sizes, and resource limits.

flowchart LR
    U[Client URL] --> V[URL validation]
    V --> W[Isolated worker]
    W --> P[Egress proxy / firewall]
    P -->|Public allowed| I[Internet]
    P -->|Blocked| X[Local / private / metadata]

A reverse proxy primarily handles incoming requests; an egress proxy controls outbound traffic. Initial validation alone is not enough.

9. Per-domain rate limiting and HTTP 429

A physical queue per domain can become unmanageable at high cardinality. Prefer a shared queue with a domain-aware scheduler, shared quotas, and per-domain cooldowns.

flowchart TD
    Q[(Pending jobs)] --> S[Domain-aware scheduler]
    S <--> R[(Redis / DB: tokens, permits, cooldown)]
    S -->|Eligible domain| W[Workers]
    W --> Site[Remote site]
    Site -->|200| W
    Site -->|429 / Retry-After| W
    W -->|Defer next_eligible_at| R
    W -->|Delayed retry| Q

Coordinate workers globally with a token bucket or an atomic reservation; limit throughput AND simultaneous concurrency. Respect Retry-After (seconds or an HTTP date); otherwise use exponential backoff with jitter. Do not occupy a worker while waiting. Avoid starving other domains. Respect robots.txt, applicable terms, and legal restrictions: robots.txt is not general authorization to collect data.

10. Highly available scheduler

Active/passive: leader elected through a lease; failover after expiry, simple but with a short interruption. Active/active: multiple active schedulers; atomic coordination is essential to reserve jobs and quotas.

flowchart TD
    Q[(Pending jobs)] --> A[Scheduler A]
    Q --> B[Scheduler B]
    A --> DB[(Transactional shared state)]
    B --> DB
    DB --> W[Workers]

The liveness probe/heartbeat triggers a restart, but does not prove that the scheduler is making progress. Also monitor the age of eligible jobs. The queue and durable state must survive schedulers.

11. Atomicity, quotas, and zombie workers

A unique constraint on (job_id, domain) prevents two identical reservations, but does not prevent two different jobs from exceeding the concurrency limit for the same domain. Both the job and the domain permit must be reserved, ideally in the same transaction if both states are in PostgreSQL; otherwise design a consistent protocol with compensation/recovery.

Simplified example of an atomic job claim (without reserving the domain permit):

sql
UPDATE scraping_jobs
SET status = 'working',
    worker_id = 'worker-A',
    lease_until = NOW() + INTERVAL '30 seconds',
    attempt = attempt + 1
WHERE id = 123
  AND (status = 'pending'
       OR (status = 'working' AND lease_until < NOW()))
RETURNING id, attempt;

The worker renews its lease. On expiry, the reconciler reassigns the job. Caution: a missing heartbeat does not prove the worker is dead (long pause, network partition).

sequenceDiagram
    participant A as Worker A
    participant D as DB / lease
    participant S as Scheduler
    participant B as Worker B
    A->>D: Claim J123, generation 1
    Note over A: Pause / network partition
    Note over D: Lease expired
    S->>D: Claim J123, generation 2
    S->>B: Execute J123
    Note over A: A resumes
    A->>D: Publish generation 1 result
    D-->>A: Rejected - stale fencing token

The fencing token protects internal writes from previous owners. It does not by itself block an external HTTP request already in progress. To strictly protect the site's quota, control request departures through a coordinated egress point and account for requests still in flight before reassigning permits.

12. Object Storage, PostgreSQL, and ACK consistency

Finalization order: write the result, confirm success, conditionally update PostgreSQL (completed, object key) with a valid generation, then acknowledge the queue.

sequenceDiagram
    participant W as Worker
    participant O as Object Storage
    participant D as PostgreSQL
    participant Q as Queue
    W->>O: PUT result - versioned key
    O-->>W: Success
    W->>D: UPDATE completed + result_key if generation valid
    D-->>W: Commit
    W->>Q: ACK
Crash pointPossible stateRecovery action
Before PUTNo resultReplay
After PUT, before UPDATEOrphaned / unreferenced objectReuse or clean up; finalize if generation valid
After UPDATE, before ACKJob completed, message redeliveredObserve completed, ACK without reprocessing
After ACKJob finishedNothing to do

Invariant: completed references only an object that has been written and is accessible. Use immutable/versioned keys, an appropriate retention policy, conditional updates, and orphan cleanup. Queue redelivery requires idempotent processing.

Transactional Outbox: useful for coupling a PostgreSQL transaction with the intent to publish an event (ScrapingCompleted) or a job; it does not make PostgreSQL and object storage atomic.

13. Caching, freshness, and deduplication

A key based only on the product ID is insufficient for a generic service. Use a canonical URL and the parameters that change content: language, authentication context, rendering options, schema version, and possibly the set of fields.

Distinguish between:

  1. Source snapshot cache (HTML / rendered DOM, fetched_at);
  2. Extraction cache (schema, fields, provenance, extractor version).

If a client requests a subset that has already been extracted and is fresh enough, return it. If fields are missing, try additional extraction from the still-valid snapshot. Do not treat fields extracted at 10:00 as refreshed at 10:15 because another field was added: prefer a shared fetched_at per snapshot or per-field timestamps.

flowchart TD
    A[Client request] --> K[Canonical key + options]
    K --> C{Fresh and complete result?}
    C -->|Yes| R[Return subset]
    C -->|No| D{Equivalent active job?}
    D -->|Yes| Join[Reuse job / polling]
    D -->|No| Claim[Atomic single-flight creation]
    Claim --> Q[(Queue)]
    Q --> W[Worker]
    W --> Cache[(Snapshot + extraction cache)]

Deduplication must be atomic across multiple API servers. “Identical” requests must share a precise definition (URL, options, freshness, security/tenant). A completion event can be published, but existing polling is enough for V1.

14. Observability and diagnosis

Service metrics:

Service componentKey indicators
Job queuedepth, oldest job age, incoming/outgoing per second, retries
API layerlatency, 4xx/5xx rates, job creations, client quotas
Worker poolsactive concurrency, CPU/RAM, duration per stage, P50/P95/P99, failures/timeouts
Scheduler/domainseligible jobs, waiting time, 429s, cooldowns, quota saturation
Databasequery latency, I/O, connections, locks, pool, transactions
Browser poolactive instances, memory, crashes, rendering time
LLM callscalls/job, input/output tokens, cost/job, latency, failures, fallback rate
Scraping resultscompleteness rate, validation rejections, cache hit rate, freshness

Structured logs: structured events (job_created, lease_expired, domain_throttled, llm_fallback, result_persisted), with correlation identifiers and sensitive data redacted.

Distributed traces: propagate trace context from the API through the queue to workers. Spans: queue wait → fetch → browser render → extraction → LLM → validation → object storage → DB. OpenTelemetry can be used for instrumentation.

flowchart LR
    A[API trace] --> Q[Queue wait span]
    Q --> F[Fetch span]
    F --> B[Browser span if needed]
    B --> E[Extraction span]
    E --> L[LLM span if needed]
    L --> V[Validation span]
    V --> P[Persist span]

Service alerts: backlog age exceeding the SLA budget, P95 > 60 s under normal load, abnormal errors/429s, lack of scheduler progress, CPU/RAM/DB saturation, LLM cost drift, persistence failures.

Metric cardinality: do not use jobId or an arbitrary domain as a Prometheus metric label. Keep detailed identifiers in logs/traces; aggregate metrics, possibly with a limited set of important domains.

Diagnostic method: compare incoming/outgoing rates and queue wait; identify the saturated pool; examine traces by stage; correlate 429s with domains; inspect the DB and network; explain LLM costs through jobs × fallback rate × tokens/call × price.

15. Illustrative data model

sql
CREATE TABLE scraping_jobs (
    id UUID PRIMARY KEY,
    tenant_id UUID NOT NULL,
    canonical_url TEXT NOT NULL,
    request_fingerprint TEXT NOT NULL,
    status TEXT NOT NULL,
    attempt INT NOT NULL DEFAULT 0,
    worker_id TEXT,
    lease_until TIMESTAMPTZ,
    result_key TEXT,
    error_code TEXT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    completed_at TIMESTAMPTZ
);

CREATE INDEX scraping_jobs_status_lease_idx
    ON scraping_jobs (status, lease_until);

Add as needed: attempts table, snapshots, extraction cache, domain quotas/leases, outbox events, client subscriptions to a shared job. Active request uniqueness must account for the tenant, options, and lifecycle; a simple permanent unique constraint on request_fingerprint would be too restrictive.

16. Main architectural tradeoffs

Design choiceDesign benefitLimitation
Async API + pollingSimplicity, no long HTTP requestPolling and perceived latency
Durable job queueAbsorbs peaks, replayableAt-least-once, possible duplicates
HTTP / browser poolsAppropriate resourcesRouting and managing two pools
Reused browserReduces startupIsolation and memory leaks
JSON-LD then DOM then LLMReduces cost and hallucinationsMore complex pipeline
Per-domain schedulerRespects external sitesDistributed coordination
Leases + fencingRecovery and write consistencyZombie workers and in-flight HTTP
Cached snapshotsExplicit freshnessField re-extraction sometimes needed
Object storage layerEconomical storage for large dataCross-system consistency to manage

17. Additional practical examples

The following examples are illustrative: values, durations, and identifiers are fictitious. They show how to diagnose and operate the architecture.

17.1 Complete distributed trace example

A scraping operation may cross several processes and a queue. Trace context must be propagated when publishing the job and recovered when consuming it (for example, through OpenTelemetry). Queue time can be represented by a dedicated span or measured separately using enqueue/dequeue timestamps.

Trace trace_id=tr-8a42, job J123: end-to-end duration 12.0 s.

Processing stageRelative startStage durationRelative end
Queue wait0.0 s3.2 s3.2 s
HTTP Fetch3.2 s1.4 s4.6 s
Browser Render4.6 s4.1 s8.7 s
LLM extraction8.7 s2.8 s11.5 s
Validation and storage11.5 s0.5 s12.0 s
%% Illustrative timeline, not drawn to exact scale
sequenceDiagram
    participant C as Client
    participant A as API
    participant Q as Queue
    participant W as Worker
    participant E as Egress / Site
    participant L as LLM
    participant S as Storage / DB
    C->>A: POST /scrapings
    A->>Q: Enqueue J123 + trace context
    A-->>C: 202 Accepted, jobId=J123
    Note over Q,W: Wait 3.2 s
    Q->>W: Job J123
    W->>E: HTTP Fetch (1.4 s)
    E-->>W: HTML
    W->>E: Browser Render (4.1 s)
    E-->>W: Rendered DOM
    W->>L: Targeted extraction (2.8 s)
    L-->>W: Fields + evidence
    W->>S: Validation and save (0.5 s)
    W->>Q: ACK after commit

Interpretation: the browser accounts for 4.1/12 ≈ 34% of latency, queue wait for 27%, and the LLM for 23%. If P95 deteriorates, these segments can be compared by job type rather than indiscriminately increasing all workers. The initial POST duration is not included in this 12 s breakdown.

17.2 Structured logs and correlation example

Each component writes JSON logs with trace_id, job_id, attempt, stage, and a stable error code. Avoid logging full pages, secrets, cookies, or personal data.

json
{"timestamp":"2026-11-04T14:00:03.200Z","level":"INFO","service":"scraping-worker","trace_id":"tr-8a42","job_id":"J123","attempt":1,"stage":"fetch","event":"stage_started","domain":"example.com"}
{"timestamp":"2026-11-04T14:00:04.600Z","level":"INFO","service":"scraping-worker","trace_id":"tr-8a42","job_id":"J123","attempt":1,"stage":"fetch","event":"stage_completed","duration_ms":1400,"http_status":200}
{"timestamp":"2026-11-04T14:00:11.500Z","level":"INFO","service":"scraping-worker","trace_id":"tr-8a42","job_id":"J123","attempt":1,"stage":"llm","event":"stage_completed","duration_ms":2800,"input_tokens":2400,"output_tokens":220,"estimated_cost_usd":0.004}

The job_id locates an execution; the trace_id links the API, scheduler, worker, and external calls. In a Prometheus metric, these identifiers must not be labels: their cardinality would be too high.

17.3 Metrics and alerts example

plaintext
# Illustrative counters and histograms (Prometheus format)
scraping_jobs_enqueued_total{pool="browser"} 10520
scraping_jobs_completed_total{pool="browser",outcome="success"} 10112
scraping_queue_depth{pool="browser"} 850
scraping_queue_oldest_age_seconds{pool="browser"} 42
scraping_job_duration_seconds_bucket{pool="browser",le="60"} 9310
scraping_worker_active{pool="browser"} 120
scraping_http_responses_total{status_class="4xx",reason="rate_limited"} 750
scraping_llm_input_tokens_total{model="model-a"} 9000000
scraping_llm_cost_usd_total{model="model-a"} 23.80
Monitored signalIllustrative alertInvestigation
Oldest job age> 45 s for 5 minScheduler, worker capacity, domain quotas
End-to-end P95> 60 s for 10 minQueue / fetch / browser / LLM breakdown
429s per domainAbnormal increaseRetry-After, quota, concurrency, backoff
Job failure rate> 5% for 10 minTimeouts, parsing, LLM provider, network access
LLM cost per job+50% vs baselineTokens, prompts, LLM usage, retries

These thresholds are examples, not universal values. P95 must be calculated over a sufficient time window and sample size. Per-domain metrics must be aggregated or limited to important domains; to investigate an arbitrary domain, prefer logs and analytical data.

17.4 Diagnostic example: rising backlog and costs

flowchart TD
    A[Rising backlog] --> B{Incoming rate > outgoing rate?}
    B -->|Yes| C{Workers saturated?}
    C -->|Yes| D[Autoscale based on resources and SLA]
    C -->|No| E{Jobs blocked by quotas / 429s?}
    E -->|Yes| F[Respect cooldowns, rebalance domains]
    E -->|No| G[Inspect scheduler, DB, and queue]
    B -->|No| H[Examine job duration and P95 distribution]
    H --> I{LLM time increasing?}
    I -->|Yes| J[Compare calls, tokens, retries, and model]
    I -->|No| K[Compare HTTP, browser, and storage]

Investigation example: job count is stable, but LLM calls per job rise from 0.3 to 0.7. Costs roughly double with constant traffic and unit prices. One hypothesis is that JSON-LD extraction fails more often, triggering more LLM fallbacks. Verify this hypothesis using the JSON-LD success rate, extractor versions, and traces, rather than immediately concluding that model prices have increased.

17.5 Enriched result example with evidence and freshness

json
{
  "jobId": "J123",
  "status": "completed",
  "source": {
    "url": "https://example.com/product/123",
    "fetchedAt": "2026-11-04T14:00:04Z",
    "snapshotId": "snap-456"
  },
  "data": {
    "name": "XYZ Bluetooth Headphones",
    "price": 129.99,
    "currency": "EUR",
    "availability": "out_of_stock",
    "description": null
  },
  "provenance": {
    "price": {"method": "dom", "evidence": "€129.99", "selector": ".current-price"},
    "availability": {"method": "llm", "evidence": "Out of stock", "verifiedInSnapshot": true}
  },
  "warnings": ["description_not_found"]
}

Evidence appearing in a document does not establish its semantic correctness (for example, a crossed-out price versus the current price). Contextual validation is still necessary. The description field remains null rather than being invented.

17.6 Retry example after HTTP 429

sequenceDiagram
    participant W as Worker
    participant P as Egress Proxy
    participant S as External site
    participant R as Quotas / Scheduler
    participant Q as Delayed queue
    W->>P: GET /product/123
    P->>S: Allowed request
    S-->>P: 429 Retry-After: 30
    P-->>W: 429
    W->>R: Cooldown example.com until T+30s
    W->>Q: Retry J123 after cooldown
    Note over W: Worker released immediately
    Q->>R: Job eligible after T+30s
    R->>W: Retry if permit available

The delay specified by the site is not a signal to put the worker to sleep. Coordinate the cooldown across all instances and cap attempts / job age. On permanent failure, retain the failure reason and apply the intended DLQ or terminal-state policy.

17.7 Crash recovery example: PUT → UPDATE → ACK

Crash pointObserved durable stateRecovery worker behavior
Before PUTNo final objectRepeat or resume extraction
After PUT, before UPDATEObject present, job unfinishedVerify object and finalize if generation valid
After UPDATE, before ACKJob completed, message still visibleDo not reprocess; ACK the duplicate
After ACKJob finishedNothing to do

A versioned object key per attempt (scrapings/J123/attempt-2/result.json) prevents a zombie worker from overwriting a newer attempt's result. Publishing result_key in PostgreSQL is conditional on the current fencing token. Orphaned objects are cleaned up by a deferred process.


18. Design checklist

  • Clarify scope, SLA, volumes, cost, and site access obligations.
  • Describe the API, durable state, queue, and workers; explain 202 Accepted.
  • Calculate throughput, theoretical concurrency, and the P95 latency budget.
  • Justify separate HTTP/browser pools and their autoscaling.
  • Design JSON-LD → DOM → LLM, merging, evidence, and validation.
  • Explain SSRF, DNS rebinding, redirects, and egress filtering.
  • Coordinate per-domain quotas and 429 responses.
  • Distinguish self-healing, active/passive, and active/active.
  • Explain atomic reservation, lease, heartbeat, fencing, and zombie workers.
  • Describe PUT → UPDATE → ACK and recovery after each crash.
  • Distinguish checkpointing, idempotence, and the transactional outbox.
  • Explain snapshot caching, TTL, freshness, and single-flight.
  • Propose metrics, logs, traces, alerts, and cardinality control.
  • Read an end-to-end trace and diagnose a rise in backlog or LLM cost.

19. Design reasoning framework

For each decision: Constraint → Solution → Guarantee → Tradeoff.

Diagram
100%