Multi-runtime pooler engine for PGMQ
Pulsar is the execution engine for PGMQ. It decides when to wake, how much to pull, who does the work and how to keep going, on serverless functions, edge isolates or your own servers.
Every bar is a tick. When the tick budget or the host's clock runs out, Pulsar stops cleanly and hands off to a fresh run, so a serverless time limit never drops a job.
PGMQ stores the messages. Pulsar operates them.
Pulsar is an orchestration engine, not a queue. You keep your Postgres and your business logic. Pulsar runs everything in between.
- +When to wake and when to stay quiet
- +How much work to pull each tick
- +Per-queue and global concurrency
- +Distributed locks and worker slots
- +Retries and failure recovery
- +Clean handoff across serverless invocations
- −A message queue or broker
- −A replacement for PGMQ
- −A home for your business logic
Choose what wakes the engine, per queue
An interval-driven queue is polled on a schedule under one shared lock. An event-driven queue sleeps until a database trigger fires, then drains itself and goes quiet. One insert burst does not mean one invocation per job.
| Pooler | Trigger | Idle cost | Pickup latency | Best for |
|---|---|---|---|---|
| interval-driven-pooler | Timed polling | Low, regular polls | Bound by the interval | Continuous, batch and delayed work |
| event-driven-pooler | Storage event | Zero idle polls | Under 10ms | Bursty, sporadic, interactive tasks |
Interval-driven is the default. Polling cadence comes from the queue's profile.
Everything between the queues and your code
The moving parts of a production queue, already built and configured per queue.
Concurrency, batch size, tick limits, timing profile and consumer, tuned separately for every queue in the same engine.
An internal clock tracks the time your host has left and stops ticking before the platform ends the function, then hands off cleanly.
- 01Reliable by constructionDistributed locks, retries and failure recovery prevent races and duplicate processing.
- 02Elastic scalingWorkers wake on a trigger or an interval, so nothing idles waiting for jobs.
- 03Dispatch anywhereHTTP endpoints, async handlers, or streams into Kafka, NATS and other brokers.
- 04Deeply customizableHooks, payload transformations, queue routing and event triggers are yours to shape.
Two levels of control
The engine sets how Pulsar lives and what it may spend. Every queue then sets its own pace inside those limits.
Runtime, storage, self-invocation, global concurrency and the tick budget.
const pulsar = new Pulsar({
engine: {
runtime: "edge-isolate",
storage: { cache: upstash },
selfInvocation: { mode: "pg_net", intervalSec: 1 },
maxGlobalConcurrency: 100,
cycleTickLimit: 10,
tickConcurrency: "sequential",
},
});Pooler, polling profile, concurrency, batch size and consumer.
pulsar.createQueue({
name: "scrape",
pooler: "event-driven",
profile: "balanced",
concurrency: 10,
n: 10,
maxJobsPerTick: 100,
consumer: { type: "http", url: process.env.WORKER_URL },
});One loop runs everything: the tick
A tick is one complete execution cycle. Ticks repeat until a queue or engine cycleTickLimit is spent, or the host's clock runs low. Then the run ends and a fresh one begins.
- 1Evaluate limitsRead queue config, tick limits and the host clock.
- 2Size the batchWork out how much can run inside the budget.
- 3Pull from PGMQClaim a batch of jobs from the queue.
- 4DispatchSend each job to its configured consumer.
- 5Update stateRecord workers, slots and locks.
- 6DecideRun another tick, or stop and hand off.
Do the math before production does
Requested jobs are concurrency × n. If that exceeds maxJobsPerTick, Pulsar scales workers down for the tick instead of overloading your database. Self-invocation cost is just arithmetic.
Sequential is safe on CPU, memory and connections. Queues take turns inside the tick budget. With a cycleTickLimit of 10 across 10 queues: each queue gets about 1 tick.
With maxGlobalConcurrency at 100 and ten queues each asking for 100 workers, every queue is held to about 10. Slots are first come, first served when demand is lower.
Sequential is safe on CPU, memory and connections. Parallel ticks every queue at once for lower latency, at the price of spikes. With a cycleTickLimit of 10 across 10 queues, sequential gives each queue one tick.
One engine, three ways to live
Set the runtime and Pulsar adapts its scheduling and lifecycle. Pick one to watch how a run ends.
Tracks the invocation window and the isolate's age. Pauses briefly before self-invoking so the platform can recycle the old isolate.
- selfURL
- Required
- cycleTickLimit
- 10, max 20
- Restarts itself
- Yes, after a short pause
Postgres is enough. Redis makes it faster.
Unified Storage puts Redis and PostgreSQL behind one interface. Supply a cache driver and hot operations move to Redis. Leave it out and they run through an unlogged Postgres table.
Not connected. Nothing breaks without it.
Always the persistent layer. Handles all of the hot operations on the left.
Unlogged tables skip write-ahead logging, so they are truncated after a database crash. That only affects the engine's operational state, not your PGMQ queues.
Plug jobs into anything
Pulsar claims the jobs, then dispatches them to your own endpoint, your own function, or the streaming tools you already run.
consumer: {
type: "http",
url: "https://api.example.com/jobs/scrape",
headers: { authorization: "Bearer ..." },
}Runs on the Postgres you already have
Pulsar works with most Postgres databases, including serverless ones like NeonDB. If your database can run the required extensions, you're set.






