How to serve multiple versions of model via standard tensorflow serving docker image?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
TensorFlow Serving can host multiple model versions from one model directory using standard Docker images. The key is directory structure and version policy configuration. With the right layout, you can run canary and stable versions side by side while controlling which versions stay loaded.
Core Sections
Required Model Directory Layout
TensorFlow Serving expects numbered subdirectories under each model name.
Each numeric folder represents one servable version.
Run Container with Model Mount
Mount the model root and pass model name environment variable.
By default, serving loads all available versions unless policy limits are set.
Control Version Loading with Config File
Use model config to choose latest N versions or specific version sets.
Start container with config file:
Request a Specific Version
Client requests can target explicit version IDs through REST URL path.
For gRPC, version selection is done in model spec fields.
Operational Best Practices
Store versions immutably and avoid overwriting existing version directories. Promote new versions by adding new numeric folders and updating policy if needed. Keep model signatures consistent across versions where possible to simplify client compatibility.
Monitor load latency and memory footprint when multiple versions are active. Version policies that keep too many versions loaded can increase startup time and resource usage.
Blue-green and Canary Approach
A practical deployment style is keeping current stable plus one candidate version loaded. Route a small share of traffic to candidate version, compare metrics, then promote. If regressions appear, route back without rebuilding container images.
Multi-model and Multi-version Configuration
Production stacks often serve several models, each with its own version policy. The standard TensorFlow Serving config supports this directly.
This allows independent rollout cadence per model. Keep monitoring segmented by model name and version to detect regressions accurately.
Also validate file permissions inside mounted volumes. Containers that cannot read version folders will silently fail to load expected versions.
Automated smoke tests per version endpoint are valuable before shifting production traffic. Validate model load status and basic prediction responses for each active version.
Clear model lifecycle rules also simplify rollback and incident response procedures.
Version-aware alerting and dashboards are essential for safe canary analysis in live environments.
Operational discipline around versions improves reliability and rollback speed.
Documented runbooks make emergency rollback decisions much faster.
This operational rigor improves reliability during high-pressure production events.
Common Pitfalls
- Using non-numeric version folder names, which TensorFlow Serving ignores.
- Overwriting an existing version directory and breaking immutability assumptions.
- Forgetting model config file when custom version policies are needed.
- Serving too many versions simultaneously and exhausting memory.
- Changing signature inputs between versions without client migration planning.
Summary
- Organize model versions as numeric subdirectories under one model name.
- Use standard TensorFlow Serving image with bind-mounted model paths.
- Configure version policy to load latest or specific versions intentionally.
- Target version-specific endpoints for canary or rollback workflows.
- Treat model versions as immutable deployment artifacts.

