Celery , an asynchronous distributed task queue for Python, is now supported natively on Vercel. Tasks are executed as Vercel Functions and automatically scale with traffic.
from celery import Celery
app = Celery ( "celery" , broker = "vercel://" )
@app . task
def add ( x , y ) :
return x + y
By default, task results are stored in Runtime Cache , which is sufficient for small data sizes and relatively short workflow runtimes. For workloads that require stronger persistence guarantees, more storage or longer retention, a durable result backend can be configured.
from fastapi import FastAPI
from worker import add , app as celery
app = FastAPI ( )
@app . post ( "/add" )
def enqueue ( x : int , y : int ) :
return { "id" : add . delay ( x , y ) . id }
@app . get ( "/result/{task_id}" )
def result ( task_id ) :
task = celery . AsyncResult ( task_id )
return { "status" : task . status , "result" : task .…