ML Engineering · Serving Tools
Flask vs Old Tools: What Changed for ML Engineers
Quick summary — what changed for ML engineers
Flask was the natural first step. Before it, ML engineers shipped pickled models and cron scripts. Flask gave them a real HTTP endpoint and a real deployment story. Then FastAPI arrived with async, types, and auto-generated docs. Now, most serious teams put a serving platform on top — but Flask and FastAPI are still the tools you build your intuition on.
In this guide you will learn:
- What the "old tools" actually were — and why they hurt.
- What Flask changed — the first real serving stack.
- What FastAPI changed on top of Flask — async and types.
- Where serving platforms now fit — KServe, BentoML, Ray Serve.
- What to learn first in 2026 — for ML engineers.
SECTION 01The old tools ML engineers used before Flask
Before Flask became the default, ML engineers shipped models in ways that were fragile, slow to change, and hard to monitor. These are the patterns that dominated 2015-2018 — and why they caused pain:
| Old pattern | How it worked | What it broke | Career pain |
|---|---|---|---|
| Pickle + cron | Save model as .pkl, load in a nightly script | No versioning, no rollback | Incidents at 2 AM, no owner |
| Notebook in prod | Run a notebook with papermill | No API, no way for apps to call it | Nothing the product team could use |
| Django admin as an API | Reuse the web app's auth + DB | Tightly coupled to product code | Every model change becomes a release |
| Excel + macros | Analyst runs the model manually | Not a service — a person | Doesn't scale; doesn't count as engineering |
| MLaaS black boxes | Cloud "auto-ML" APIs | No control over model or latency | Can't tune, can't debug |
SECTION 02What Flask changed for ML engineers
Flask didn't invent the web — it made shipping a model endpoint trivial. A dozen lines, one command, and your model was reachable by a frontend, a mobile app or another service. That was revolutionary for ML engineers in 2018.
| What Flask gave | Why it mattered | What it didn't solve | Interviewer signal |
|---|---|---|---|
| HTTP endpoints | Models could be called by any client | No input validation | "You can ship a model as a service" |
| Small footprint | Easy to learn, easy to deploy | No async support | "You understand request/response" |
| WSGI standard | Works with Gunicorn, uWSGI, Nginx | No built-in metrics | "You know how Python web serving works" |
| Jinja templates | Quick demo UIs for models | Not for production frontends | "You can show a demo fast" |
| Python native | Model code and serving code in one language | Slower than compiled services | "You think in one stack" |
from flask import Flask, request, jsonify
import pickle
app = Flask(__name__)
model = pickle.load(open("model.pkl", "rb"))
@app.route("/health")
def health():
return {"status": "ok"}
@app.route("/predict", methods=["POST"])
def predict():
payload = request.get_json()
features = payload["features"]
prediction = model.predict([features])[0]
return jsonify({"prediction": float(prediction)})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
Before a Flask ML server is production-ready:
□ Load model once, not per request
□ Input schema validation (pydantic or custom)
□ Timeout on the model call
□ Structured JSON logging
□ /health and /ready endpoints
□ Run behind gunicorn with multiple workers
□ Metrics endpoint (Prometheus)
□ Error handling with clean HTTP codes
□ Dockerfile + CI
□ Load test with locust or k6
SECTION 03What FastAPI added on top of Flask
FastAPI is not a replacement — it is an evolution. It keeps the Flask feel, adds async, typed schemas and auto-generated documentation. For ML serving, this is a meaningful improvement, not just a nicer API.
| Feature | Flask | FastAPI | Why it matters for ML |
|---|---|---|---|
| Async support | WSGI — one request at a time per worker | ASGI — concurrent requests | Higher throughput for I/O-heavy serving |
| Type hints | Optional | First-class, enforced | Safer model input contracts |
| Validation | Manual | pydantic built-in | Bad inputs never reach the model |
| Docs | Manual Swagger | Auto-generated /docs and /redoc | Instant client contract |
| Dependency injection | Not built-in | Built-in | Cleaner model loading and auth |
| Performance | Fine for low volume | Meaningfully faster | Lower cost at scale |
from fastapi import FastAPI
from pydantic import BaseModel, conlist
import pickle
app = FastAPI()
model = pickle.load(open("model.pkl", "rb"))
class PredictRequest(BaseModel):
features: conlist(float, min_length=10, max_length=10)
class PredictResponse(BaseModel):
prediction: float
@app.get("/health")
def health():
return {"status": "ok"}
@app.post("/predict", response_model=PredictResponse)
def predict(req: PredictRequest):
prediction = model.predict([req.features])[0]
return PredictResponse(prediction=float(prediction))
Why a team moves from Flask to FastAPI:
- Built-in /docs means clients can integrate without asking
- pydantic validation stops bad inputs at the door
- Async means fewer workers per node, cheaper scale
- Type hints catch bugs before deploy
- Depends() makes loading and auth clean
- Faster response times in benchmarks
Why a team stays on Flask:
- Existing code and tests are stable
- The model is called rarely (low QPS)
- Team is more comfortable with WSGI
- Simple cron-style jobs, not real APIs
SECTION 04Where serving platforms now fit — KServe, BentoML, Ray Serve
For real ML systems in 2026, "one Flask app per model" starts to break — not because Flask is bad, but because companies need autoscaling, versioning, A/B tests, GPUs, and observability. That is where serving platforms come in.
| Tool | What it adds | Best for | What interviewers ask |
|---|---|---|---|
| KServe | Kubernetes-native, autoscale, canary, multi-model | Enterprise ML platforms on K8s | "How would you roll out a new model safely?" |
| BentoML | Packaging, versioning, batch + online serving | Teams wanting portability across clouds | "What's a bento?" |
| Ray Serve | Composable, distributed serving of any model | Complex inference graphs (LLMs, vision) | "How do you serve an LLM at low latency?" |
| SageMaker endpoints | Managed autoscale, A/B, shadow deploys | AWS-native companies | "How do you version endpoints?" |
| Vertex AI | Managed training + serving, monitoring | GCP-native companies | "How is model monitoring set up?" |
SECTION 05What to learn first in 2026
If you are an ML engineer starting today, the answer is not "Flask or FastAPI or a platform" — it is a sequence. Here is the learning order that actually matches how teams work in 2026:
| Step | What to learn | Why first | What to ship |
|---|---|---|---|
| 1 | Flask — one /predict endpoint | Simplest way to learn serving | A live model demo |
| 2 | Production Flask — validation, logging, /health | Shows you understand reliability | A containerized Flask API |
| 3 | FastAPI — async, pydantic, /docs | The current default for new services | The same model in FastAPI |
| 4 | Docker + CI + deploy | Nothing counts until it runs in prod | A deployed endpoint with a URL |
| 5 | One serving platform — BentoML or KServe basics | Shows you think at platform scale | A versioned, autoscaled demo |
| 6 | Monitoring — latency, drift, errors | What senior interviews probe | A dashboard with real metrics |
Before you call your ML serving project done:
□ A trained model with a clean training script
□ A FastAPI (or Flask) /predict endpoint
□ Input validation — bad inputs return 422
□ /health endpoint for load balancers
□ Model loaded once, not per request
□ Structured logs including request_id
□ Prometheus metrics on latency and error rate
□ Dockerfile + GitHub Actions CI
□ Deployed with a public URL
□ Load test documented in the README
Prepare answers to these questions:
1. Why does loading the model per request
destroy your p99 latency?
2. When would you choose Flask over
FastAPI for an ML service?
3. How do you roll out a new model
without breaking clients?
4. How do you detect input drift in
production?
5. What does your /health endpoint
actually check, and why does
Kubernetes need it?
6. How do you serve a GPU model
cheaply at low traffic?
7. What is the difference between
batch inference and online serving?
SECTION 06Interview Q&A — Flask vs old tools for ML
Q1Is Flask still relevant for ML serving in 2026?
Yes — especially for low-QPS services, internal tools, and cron-driven jobs. But new public-facing ML services usually start in FastAPI because of async, typing and auto-docs. Flask is the tool you should understand, even if you don't always choose it.
Q2What did Flask actually replace for ML engineers?
Pickle + cron jobs, notebooks in production, and Django admin used as an API. Flask gave ML engineers the simplest possible way to put a model behind an HTTP endpoint — with a real deployment story.
Q3Why do many teams now prefer FastAPI over Flask?
Because FastAPI adds async support, enforced type hints, pydantic validation and auto-generated /docs. For ML services, that means faster responses, safer inputs, and clients that can integrate without asking questions. It's an evolution, not a revolution.
Q4When should an ML team move to a serving platform?
When the number of models grows, when they need autoscaling, GPU sharing, versioning and A/B tests, or when multiple teams share the infrastructure. That's when KServe, BentoML or Ray Serve start to pay off. Below that threshold, a well-written FastAPI service is often enough.
Q5What's the most common ML serving mistake in 2026?
Loading the model on every request. It is the single biggest cause of slow p99 latency in small ML services — and it comes up in almost every junior interview. Load the model once at startup and reuse it.
SECTION 07Test yourself — Flask vs old tools
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
Is Flask still used in production for ML models?
Yes. It remains popular for small services, internal tools and cron-style jobs. For higher-traffic public APIs, most new work starts in FastAPI — but the mental model is the same.
What was the biggest problem with the "old tools"?
Pickle files and cron jobs had no versioning, no observability and no way for other teams to call the model. Flask fixed the "call the model" part — the rest came later with FastAPI, platforms, and monitoring.
Do I need to learn both Flask and FastAPI?
Learn Flask first — it teaches you how a Python web service actually works. Then move to FastAPI, which is what new services in 2026 are usually built with. Understanding both is a strong interview signal.
When should I use KServe, BentoML, or Ray Serve?
When you have multiple models, real autoscaling needs, GPU sharing, or a shared platform across teams. Below that threshold a single FastAPI service is usually cheaper and simpler.
What should I build as a portfolio project for ML serving?
A single model deployed as a FastAPI (or Flask) service, with input validation, /health, structured logs, Prometheus metrics, Docker, CI, and a public URL. Add a README and a short load test — that is enough to stand out.
SECTION 09Related reads
Classroom & online · Noida
Ship a real ML serving project
Our Machine Learning Training Course is built around the full serving stack — Flask, FastAPI, Docker, CI, and a deployed model endpoint you can actually show an interviewer.
₹15,500 · full programme- Flask + FastAPI serving
- Docker + CI + deploy
- Monitoring & metrics
- Weekday & weekend batches