Why Move Work Off the Request
Keep responses fast with async tasks.
Why Move Work Off the Request is a free Flask Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Flask Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Slow Work Hurts
Some work is slow: sending email, resizing images, calling APIs. If you do it inside a view, the user waits for all of it. ⏳
The Blocking Problem
A request that runs slow work blocks the worker handling it. While it waits, that worker cannot serve anyone else.
Users Feel Latency
Every second a view spends on background-ish work is a second the browser shows a spinner. Slow responses feel like a broken app.
The Core Idea
A task queue lets a view hand slow work to a separate process, then return a response right away while work runs later.
Meet Celery
Celery is the most common task queue for Flask. Your app pushes jobs onto it, and worker processes pick them up and run them.
Producer and Worker
Your Flask app is the producer: it enqueues jobs. Separate Celery workers consume those jobs and do the heavy lifting.
The Broker in the Middle
A broker like Redis or RabbitMQ holds the queue of pending jobs. The app writes to it and workers read from it.
Fire and Forget
For email or logging you often do not need the result. The view enqueues the job, returns fast, and never blocks on it. ✉️
When You Need an Answer
Sometimes you do want the result, like a finished report. Celery can store that result so you can poll for it once the job is done.
Good Candidates for Tasks
Move work that is slow, external, or bursty: emails, image processing, third-party API calls, report generation, and scheduled jobs.
Keep Views Thin
A healthy view validates input, enqueues the slow part, and returns immediately. Heavy logic lives in the task, not the request.
Quick Check
Think about why we use a queue.
Recap
Slow work blocks views. A queue lets you enqueue it and respond fast. Celery is the producer-broker-worker pattern for Flask. ✅
Frequently asked questions
Is the “Why Move Work Off the Request” lesson free?
Yes — the full text of “Why Move Work Off the Request” is free to read here on the web, and the Flask Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Flask Academy course, upgrade to CoddyKit PRO.
What will I learn in “Why Move Work Off the Request”?
Keep responses fast with async tasks. You practise Flask Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Flask Academy?
No prior experience is required. Flask Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Why Move Work Off the Request” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Flask Academy lesson?
Yes. Every Flask Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why Move Work Off the Request
- Wire Celery into the App Factory
- Define and Call a Task
- Track Results and Handle Failures