How can I use tensorflow serving for multiple models
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 more than one model in a single server process, which is useful when you want separate endpoints for different tasks or versions. The usual setup is to store each model in its own directory and point TensorFlow Serving at a configuration file that lists all the models it should load.
How multi-model serving is organized
TensorFlow Serving expects models in the SavedModel directory format:
Each top-level directory is a model name, and each numbered subdirectory is a version. The version numbers let you roll forward without replacing files in place.
Use a model config file
For multiple models, you usually do not start the server with just one --model_name and --model_base_path. Instead, use --model_config_file.
Example models.config:
That tells the server to load both models and expose them under separate names.
Running with Docker
A common deployment pattern is to mount both the model directory and the config file into the container:
Once the container starts, TensorFlow Serving loads all configured models it can find on disk.
Calling each model over REST
Each model gets its own URL path.
Example request for the sentiment model:
Example request for the recommender model:
The important detail is that the endpoint path contains the model name from the config file.
Serving multiple versions of one model
You can also keep more than one version of the same model under a single model name. TensorFlow Serving can choose the latest version automatically or be configured to serve specific versions depending on your needs.
Directory example:
That is different from serving multiple named models. One model name can have many versions, while a multi-model server can expose many model names.
When one server is a good idea
Serving multiple models in one process is convenient when:
- the traffic level is moderate
- the models are related and deployed together
- operational simplicity matters more than strict isolation
If the models have very different memory usage, scaling requirements, or release schedules, separate serving instances are often cleaner. Multi-model serving is convenient, but it also couples resource usage and failure domains.
Common Pitfalls
- Using
--model_nameand--model_base_pathwhen you actually need a multi-model config file. - Forgetting the required directory structure with version-number subfolders.
- Mounting the model data into Docker but not mounting the config file correctly.
- Calling the wrong REST path and assuming the model failed to load.
- Packing too many large models into one server and running into memory pressure.
Summary
- Use a
model_config_fileto serve multiple TensorFlow models from one TensorFlow Serving instance. - Store each model under its own directory with version-number subdirectories.
- Mount the models and config file into the serving container.
- Each configured model is exposed under its own REST or gRPC endpoint.
- Multi-model serving is convenient, but separate instances may be better when models need isolation.

