A local mlflow.db works for one person; teams need a shared server so runs and models are visible to all.
mlflow server runs the tracking API, model registry and UI as a service. Two stores are configured separately:
- Backend store for metadata (experiments, runs, params, metrics, registry): a SQL database such as PostgreSQL or MySQL, e.g.
--backend-store-uri postgresql://user:pw@db/mlflow. SQLite is fine for small single-machine setups. - Artifact store for files and models: S3, GCS, Azure Blob, HDFS or a shared filesystem, e.g.
--artifacts-destination s3://ml-artifacts.
By default the server proxies artifact access: clients upload and download through the server, so they need no cloud credentials. Alternatively clients can write directly to the store if they have access.
Clients point at the server with either:
mlflow.set_tracking_uri("http://mlflow.internal:5000")in code, or- the environment variable
MLFLOW_TRACKING_URI, which keeps code environment-agnostic.
Production considerations:
- Put it behind TLS and authentication. MLflow has built-in basic auth (
mlflow server --app-name basic-auth) or you can use a reverse proxy or managed offering. - Run several server workers (
--workers) for heavier traffic. - Back up the database; artifacts live in the object store.
- Database schema changes between MLflow versions are applied with
mlflow db upgrade <uri>; back up first.
Example
# Start a team server (shell):
# mlflow server --host 0.0.0.0 --port 5000 \
# --backend-store-uri postgresql://mlflow:secret@db:5432/mlflow \
# --artifacts-destination s3://acme-ml-artifacts
#
# Clients: export MLFLOW_TRACKING_URI=http://mlflow.internal:5000
import os
import mlflow
uri = os.environ.get("MLFLOW_TRACKING_URI", "sqlite:///mlflow.db")
mlflow.set_tracking_uri(uri)
print(mlflow.get_tracking_uri()) # whichever store is configured
mlflow.set_experiment("shared-experiment")
with mlflow.start_run() as run:
mlflow.log_metric("rmse", 3.2)
print(run.info.artifact_uri[:30]) # mlflow-artifacts:/... when proxied by a serverRemember
- Backend store = SQL metadata; artifact store = object storage for files
- Default proxied artifacts mean clients need no cloud credentials
- Configure clients with MLFLOW_TRACKING_URI rather than hard-coded URIs
Watch out for
- Running a shared server on the local file or SQLite store from a laptop, then losing the team's history when the laptop goes away.