- Category: B. Software Architecture
- English term: Webhook and Polling
- Related: Watchdog Timer / Watchdog Process · Heartbeat and Failure Detection · Orchestration and Choreography · Idempotency · Free Tier as an Architectural Constraint
General Meaning
Systems communicate state changes across boundaries in two primary ways: Webhooks (Push), where the sender immediately issues an HTTP POST to a registered callback URL the moment an event (such as a Git push or PR creation) occurs; and Polling (Pull), where the receiver periodically queries an API or database on a timer (e.g., every 15 minutes) to ask for new items.
Webhooks deliver near-zero latency with minimal traffic, but a dropped packet or brief receiver outage can lose an event forever. Polling is self-healing, though high polling frequencies waste API quotas. Resilient architectures combine both: reacting immediately via webhooks while keeping periodic polling as a safety net to catch missed events.
Why It Matters
- Minimizing reaction latency: Webhooks trigger downstream builds or merges within seconds of a Git commit or PR event.
- Slashing wasted API queries: Avoids hammering APIs or databases during quiet periods, preserving rate limits and free-tier quotas.
- Self-healing against transient network drops: Periodic polling acts as a guaranteed safety net that picks up any event missed during a brief webhook outage.
How the Site Factory Uses It
The Site Factory combines instant GitHub Webhooks on Cloudflare Workers with 15-minute periodic polling by patrol.py on Mac: (1) All 15 repositories send GitHub webhooks to honbu-dispatcher (/webhook/github), which verifies the HMAC signature and records the event in D1 immediately; (2) Launchd service dev.memocho.honbu-service-patrol runs every 15 minutes to scan pending cloud tickets, reclaim stalled jobs, and auto-squash passing PRs; and (3) Any webhook lost to a network blip is automatically picked up by the next 15-minute patrol sweep.
At the same time, the Site Factory strictly bans aggressive high-frequency polling (such as 20-second timer loops querying D1) to protect Cloudflare D1's daily 5M-row read quota.
Caveats & Operational Rules
- Never rely on webhooks alone: Webhook delivery is not guaranteed when a receiver is briefly unreachable; always keep a periodic polling sweep as a catch-up safety net.
- Ensure idempotent webhook handling: Networks can deliver the same webhook payload more than once; receivers must deduplicate by event ID or state so tasks are never executed twice.
Related Terms
- Watchdog Timer / Watchdog Process
- Heartbeat and Failure Detection
- Orchestration and Choreography
- Idempotency
- Free Tier as an Architectural Constraint
References
- Book: Mark Richards & Neal Ford, *Fundamentals of Software Architecture*, Chapter 12 (Event-Driven Architecture)
Verified: 2026-11-08