Expose a trained model as a simple web service

Practical MLOps knowledge from model serialization to serving. Package the model into a standard format, containerize it, expose a REST endpoint behind a load balancer, and add monitoring. A bare Flask server without containers or health checks is a red flag.
What's really being asked
This question probes whether you can bridge the gap between a trained model artifact and a production-grade service. Interviewers want to see that you think in terms of the MLOps lifecycle, specifically the packaging, deployment, and integration stages, rather than treating serving as an afterthought. They are looking for awareness of scalability, observability, and dependency isolation.
The full answer
A strong response walks through five layers in order. First, serialization: export the trained model into a stable format such as ONNX, TorchScript, or TensorFlow SavedModel so the artifact is decoupled from the training notebook. Second, packaging: bundle the serialized artifact, inference code, and dependency manifest into a Docker image to create a portable model server. Third, serving infrastructure: expose REST endpoints through an API gateway that delegates traffic to a load balancer, which then distributes requests across multiple worker processes or nodes. Fourth, the runtime: each worker loads the model into memory and performs inference, ideally using an ML-optimized runtime rather than a generic web framework for large models. Fifth, observability: add a monitoring endpoint that tracks request latency, throughput, input data distribution, and prediction drift. The candidate should also mention that this architecture isolates heavy ML dependencies from the main application stack and enables independent versioning and rollback.
The mistakes people make
The biggest red flag is stopping at a raw Flask or FastAPI script with model.load and app.run, with no mention of containers, serialization, or horizontal scaling. Another weak pattern is conflating training dependencies with serving dependencies, suggesting the server image includes Jupyter, full GPU training stacks, or data pipelines. Failing to mention health checks, request validation, or a monitoring endpoint also signals a lack of production experience. Finally, suggesting a model server for pure batch processing or a trivial single-instance workflow shows poor architectural judgment.
What usually comes next
Expect the interviewer to ask how you would handle a model that is too large for a single container, how to implement A-B testing between two model versions, or how to protect the endpoint from traffic spikes. They may also dig into cold-start latency, GPU utilization strategies, or how to update the model without dropping traffic.
A concrete example
Suppose you have a PyTorch computer vision model. You would trace it to TorchScript, then copy the artifact into a Docker image built on an ML-optimized server like TorchServe or Triton. The container exposes a REST endpoint on port 8080 behind an Nginx API gateway. A load balancer spreads incoming requests across three worker replicas. Each worker keeps the model resident in memory and returns predictions in under 100 milliseconds. A monitoring sidecar scrapes latency and logs input image distributions to detect data drift.
Interview question
A team serves a model with a Flask script that calls model.load and app.run. Which change most directly addresses the key production gaps?
- a.Serialize the model, containerize the runtime with health checks, and expose it behind a load-balanced gateway with monitoringCorrect
- b.Deploy the script to a larger cloud VM with a public static IP
- c.Convert the model to ONNX to reduce framework overhead
- d.Add async request handlers to improve concurrency
Why? this is the answer
C covers the full MLOps lifecycle from the card: serialization decouples the artifact, containers isolate dependencies, and the gateway enables scaling and observability. D is tempting because serialization is correct in isolation, but without containerization, health checks, and a scalable serving layer it remains a prototype-level solution.
Just read this? Test yourself on what you have been reading.
Read the original → axelmendoza.com
- #mlops
- #model-serving
- #system-design
- #deployment
- #production
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on mlops — each one lists the topics its interview covers.
See open roles