DEV Community

Adam Albarghouthi
Adam Albarghouthi

Posted on

Job queue for serverless apps #low-code

What's a job queue πŸ€”

A job queue allows apps to schedule jobs to run in the background.

No easy solution for serverless apps

Serverless apps are event-driven, so they only run when called upon. There's no running server that can host a job queue or even run cron-jobs.

But running jobs in background (at specific times) is a need that comes up all the time when building apps.

Idea πŸ’‘

So I decided to bootstrap a job queue using as little code as possible. My stack:

  • Airtable functions
  • Airtable scripting
  • Airtable automations
  • Nextjs/Vercel

Basically the app is in Nextjs hosted on Vercel with an endpoint /api/job where users can submit their job.

Here's an example api call to schedule a job:

fetch("", { 
    method: "POST", 
    headers: {
        "Content-Type": "application/json",
        Accept: "application/json",
        "x-api-key": "API_KEY_GOES_HERE", // replace with your API key
    body: {
        timezone: "America/New_York", // optional (default: "America/New_York")
        run_time: 1639015224, // required (Unix timestamp)
        url: "", // required (endpoint to trigger at run time)
        data: { // optional (data passed to your endpoint)
            email: ""
Enter fullscreen mode Exit fullscreen mode

Airtable Functions

The job gets recorded in Airtable and there's one field that makes everything work.

The to_run field is a function of whether the run_time is less than or equal to the current time. Seems like Airtable runs these functions every 10 minutes to update the fields.

That means, max 10 minutes after run_time Airtable will update the to_run field to 1.

(Usually delayed jobs are not sensitive to the exact minute, so it's a trade-off I'm willing to take)

Airtable Automations

The job then enters the "running" view in Airtable. That will run an Airtable automation that runs an Airtable script.

Airtable Scripting

The Airtable script does 2 things:

  • logs what's happening into the logs table
  • hits the endpoint that was requested to be hit at run_time

That's how was born

You can currently get an API key at and get started. This can only do delayed jobs for now, but there's more in the pipeline - here's the roadmap for who's interested.

And btw, it's free! Happy for anyone to test it out 😊

Comments/feedback are much appreciated!

Top comments (0)