Sub topic 3
MLflow: Tracking Client, Backend Store, and Artifact Store
Prerequisites and the basic architecture
This chapter assumes you know basic Python and the command line, have trained and evaluated a machine learning model, and understand hyperparameters, metrics, and train/validation splits. You should also know that a client application can call a server through an API.
MLflow tracking records information about machine learning runs. A run is one execution of a training or evaluation script. The MLflow tracking client is the Python library used by that script. It sends run data to a tracking server or writes it directly to a configured store.
MLflow separates run metadata from large files:
- The backend store holds metadata such as run IDs, parameters, metrics, tags, timestamps, and run status. It is commonly a database.
- The artifact store holds files produced by a run, such as model files, plots, checkpoints, data samples, and evaluation reports. It can be a local directory or object storage such as Amazon S3.
- The tracking server provides an HTTP endpoint between training code and these stores. It accepts client requests, applies configuration and authentication, and writes the data to the correct location.
- The MLflow UI reads tracking data and displays runs, metrics, parameters, and artifacts.
The separation matters because metadata and artifacts have different access patterns. A database is well suited to querying “which runs had validation AUC above 0.90?” An object store is better suited to storing a multi-gigabyte model.
Configuring the client and server
The client needs a tracking URI. The URI identifies where MLflow should send tracking requests. For a local server, it can be an HTTP URL. A training script can then create or select an experiment and log values inside a run.
import mlflow
mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("churn-model")
with mlflow.start_run(run_name="baseline"):
mlflow.log_param("max_depth", 6)
mlflow.log_param("learning_rate", 0.1)
for step, auc in enumerate([0.84, 0.88, 0.91]):
mlflow.log_metric("val_auc", auc, step=step)
mlflow.set_tag("data_version", "2026-11-01")A parameter describes an input chosen before or during training, such as a learning rate. A metric is a numeric observation, often recorded at several steps. A tag is flexible descriptive metadata, such as a data version, Git commit, owner, or purpose.
Start a simple local tracking server in another terminal:
pip install mlflow
mlflow server --host 127.0.0.1 --port 5000The server address is deliberately bound to 127.0.0.1, so it is available only on the local machine. A shared server requires deliberate choices about authentication, network access, storage credentials, and backups.
What happens during a run
When start_run() executes, MLflow creates a run ID and associates the run with an experiment. Calls such as log_param, log_metric, and set_tag send metadata to the tracking endpoint. When the run closes, MLflow records its final status, such as successful or failed.
Metrics differ from parameters in an important way. A parameter usually has one value per run. A metric can have a history, with values associated with steps or timestamps. This history supports learning curves and comparisons between training schedules.
Artifacts use a separate path. For example, mlflow.log_artifact("confusion_matrix.png") uploads a file to the run’s artifact location. mlflow.log_model(...) can store a model together with metadata describing how to load it. The backend store may contain a reference to the artifact, but it does not need to contain the artifact’s binary contents.
Operational choices and failure modes
For a team, the local file-based setup is useful for learning but limited for concurrent workloads. A production design commonly uses a managed relational database for backend metadata and object storage for artifacts. Keep these concerns separate:
| Concern | Typical question | Example choice |
|---|---|---|
| Backend store | How will runs be queried and backed up? | PostgreSQL |
| Artifact store | Where will large files live? | S3-compatible object storage |
| Tracking endpoint | How will clients reach MLflow? | Private service with authentication |
| Access control | Who can read or modify runs? | Network policy and identity-based permissions |
Common failures include pointing clients at the wrong tracking URI, allowing training workers to write directly to storage without the needed permissions, and deleting artifacts while retaining metadata that references them. Network interruptions can also leave a run marked as running even after the training process has stopped. Record the Git commit, data version, environment, and run status so that an apparently successful run can be reconstructed and investigated.
Exercise
A run contains parameters and metrics in the UI, but its saved model cannot be downloaded. Which MLflow boundary should you inspect first, and why?
Show answer
Inspect the artifact store configuration and permissions first. Parameters and metrics use the backend metadata path, while the model file is an artifact stored separately.