# FAQ - Common Questions

import { CardGrid, LinkCard } from '@astrojs/starlight/components';

## What are the two Edge Worker modes?

**Short Answer:** Edge Worker supports two modes: **background jobs** (simple task processing) and **flows** (multi-step workflows with dependencies).

Edge Worker can run in two distinct modes depending on what you pass to `EdgeWorker.start()`:

**Background Jobs Mode** - For simple, independent tasks:
```typescript
EdgeWorker.start(async (payload) => {
  // Your task handler
});
```

In this mode, Edge Worker polls a queue (default: `tasks`) and processes messages independently. Perfect for simple background jobs like sending emails, processing uploads, or web scraping.

**Flow Mode** - For multi-step workflows:
```typescript
import MyFlow from './_flows/my_flow.ts';
EdgeWorker.start(MyFlow);
```

In this mode, Edge Worker processes tasks for a specific workflow, handling step dependencies, data flow between steps, and automatic coordination. The queue name matches your flow slug.

<details>
<summary>Read more about choosing the right mode</summary>

**Background Jobs:** Single-step tasks without dependencies (sending notifications, processing webhooks, image resizing)

**Flows:** Multi-step processes with dependencies, data flow between steps, parallel execution (AI pipelines, data transformations, business workflows)

**Configuration:** Both modes share the same Edge Worker options. Background jobs use `queueName` option (default: `tasks`), flows use the flow slug as queue name.

**🤔 Hard to decide?** Consider flows if your "single step" has multiple distinct operations that could fail independently, or you might add steps later. Handler functions are reusable between modes - start with background jobs and migrate to flows when needed.

</details>

## Will running Edge Worker 24/7 affect my billing?

**Short Answer:** It depends on your workload

Edge Worker consumes:
- **Invocations:** One invocation to start, then processes messages continuously until CPU/clock limits terminate the function. Automatically self-respawns (and can be additionally respawned by [pg_cron safety net](/deploy/supabase/keep-workers-running/) if configured).
- **Egress:** Message data transferred during processing. Varies based on message size and count.

This is more efficient than invoking Edge Functions per-message or per-batch via pg_cron, which would require one invocation per batch.

Actual costs depend on message volume, message size, and worker stability. Monitor your usage in [Supabase Dashboard](https://supabase.com/dashboard) and review [Supabase Pricing](https://supabase.com/pricing) to understand limits and costs.

## Can one Edge Worker process multiple queues or flows?

**Short Answer:** No - one Edge Worker processes one queue

Each Edge Worker instance is bound to a single queue:
- **Background jobs mode:** Queue name set via `queueName` configuration (default: `tasks`)
- **Flow mode:** Queue name automatically matches the flow slug

**Scaling options:**
- **Multiple workers on same queue:** Deploy multiple Edge Workers pointing to the same queue for increased throughput
- **Multiple queues:** Deploy separate Edge Workers - one per queue

## How do I prevent one tenant from monopolizing the queue?

**Short Answer:** You can't - fair processing is not implemented yet

Fair processing is not currently implemented in Edge Worker.

Need this? Let's chat on [Discord](https://pgflow.dev/discord/) - there are ideas for workarounds to explore.

## Can I force a new Edge Worker to spawn by calling the function again?

**Short Answer:** Not reliably

Spawning new Edge Worker instances is managed by the Supabase platform, and simply invoking
the same Edge Function again doesn't guarantee a new Edge Worker is started.

<details>
<summary>Read more about the Supabase load balancer</summary>

### Why can't I control Edge Worker creation?

- Edge Workers are managed by an API gateway that decides when to start new instances based on load and availability.
- Sending multiple HTTP requests to the same Edge Function will not necessarily create new Edge Workers.
- For concurrency or throughput, run multiple Edge Functions with Edge Workers, each configured separately.
</details>

## Related Documentation

<CardGrid>
  <LinkCard title="Create your first worker" href="/get-started/background-jobs/create-worker/" />
  <LinkCard title="Run your Flow" href="/get-started/flows/run-flow/" />
  <LinkCard title="Worker Configuration" href="/reference/configuration/worker/" />
  <LinkCard title="Supabase Pricing" href="https://supabase.com/pricing" />
</CardGrid>