Performance: Celery integration overview
MEDIUM IMPACT
This affects backend task processing speed and responsiveness of the Flask web app by offloading long-running tasks.
from flask import Flask from celery import Celery app = Flask(__name__) celery = Celery(app.name, broker='redis://localhost:6379/0') @celery.task def long_task(): # Long task runs asynchronously return 'done' @app.route('/process') def process(): task = long_task.delay() return f"Task started: {task.id}"
from flask import Flask app = Flask(__name__) @app.route('/process') def process(): # Long task runs synchronously result = long_task() return f"Result: {result}"
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous long task in Flask route | Minimal | 0 | 0 | [X] Bad |
| Asynchronous task with Celery | Minimal | 0 | 0 | [OK] Good |