
How We Run Lighthouse from 18 Regions in Under 2 Minutes
Most performance monitoring tools test your site from one location, or run tests sequentially across regions. That means testing from 18 locations can take 20+ minutes. We needed something faster. Ahoj Metrics tests from 18 global regions simultaneously in about 2 minutes. Here's how. The Architecture The core idea is simple: don't keep workers running. Spawn them on demand, run the test, destroy them. We use Fly.io's Machines API to create ephemeral containers in specific regions. Each container runs a single Lighthouse audit, sends the results back via webhook, and destroys itself. Here's how a request flows through the system: The key design decision: one audit = one ReportRequest , regardless of how many regions you test. Test from 1 region or 18 - it's the same user action. Spawning Machines with the Fly.io API Here's the actual code that creates a machine in a specific region: class FlyMachinesService API_BASE_URL = "https://api.machines.dev/v1" def self . create_machine ( region
Continue reading on Dev.to
Opens in a new tab




