Skip to content

Lesson 21 ยท Servers, Deployment and Teams

Run a Tracking Server

Run a shared MLflow tracking server with a database backend and artifact storage, understand the key command flags, protect it and upgrade it safely.

A local database works for one person. A team needs one shared place for runs, models and traces. That is the job of an MLflow tracking server.

Start a server

The simplest form starts a server on your machine:

Terminal
mlflow server --port 5000

By default it uses SQLite. A shared setup usually names its stores:

Terminal
mlflow server \
  --backend-store-uri "$MLFLOW_DB_URI" \
  --artifacts-destination s3://my-team-mlflow \
  --host 0.0.0.0 --port 5000 \
  --allowed-hosts "mlflow.example.com"

Here MLFLOW_DB_URI is a variable of our own that holds a database address such as postgresql://user:password@db-host:5432/mlflow. Fill it from a secret manager. Do not type a real password into a script or your shell history.

Flag Meaning
--backend-store-uri Where metadata lives
--artifacts-destination Where the server stores the artifacts it handles
--host, --port Where the server listens
--allowed-hosts Which Host header values are accepted
--cors-allowed-origins Which web origins may call the API

Run mlflow server --help to see the flags of your version.

Proxied or direct artifacts

With proxied artifact access, clients send files to the server, which stores them. Clients need no storage credentials. With direct access, clients talk to storage themselves, so each one needs permissions. Proxied access is simpler to manage, but remember that people who can use the server can reach artifacts through its storage access.

Be careful with a plain local path as the artifact location for a shared server. The client and the server may refer to different disks, and files end up where nobody expects them.

Point clients at it

Terminal
export MLFLOW_TRACKING_URI=https://mlflow.example.com
python train.py

Security first

A tracking server holds details about your code, data samples, traces and models.

  • Do not expose it to the public internet without protection.
  • Serve it over HTTPS, using a reverse proxy or load balancer.
  • Require login. MLflow offers basic HTTP authentication, single sign-on options and plugins.
  • Limit the accepted Host values and CORS origins. An "Invalid Host header" error often means that you need to add your domain to --allowed-hosts. The docs say these two security flags work with the default server, not with some alternative server options.
  • Control network access, and back up both stores.

A basic server does not ask anyone to log in. Anyone with network access to it can use it. Add authentication before you share it.

Database upgrades

A new MLflow version may change the database schema. Back up first, then run:

Terminal
mlflow db upgrade "$MLFLOW_DB_URI"

The documentation warns that migrations can be slow and are not guaranteed to be transactional. Practice on a copy first. If you still use the old file store, read the official guide for migrating from it, because moving data has its own steps and limits.

A configuration check

Before you launch, a simple script can catch risky settings. This stand-in checks a settings dictionary that we invented.

Python Stand-in: a pre-launch checklist

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

These rules are teaching suggestions, not an official audit.

Containers and managed options

Many teams run the server in a container with a managed database and object storage. Cloud vendors and data platforms also offer managed MLflow. A managed service takes care of operations, but check which MLflow version and features it supports, because they may differ from the open source server.

Verify the setup

After you start a server, test it from another machine, not only from the server itself:

Python
import mlflow

mlflow.set_tracking_uri("https://mlflow.example.com")
mlflow.set_experiment("smoke-test")

with mlflow.start_run():
    mlflow.log_param("who", "setup-check")
    mlflow.log_metric("ok", 1)
    mlflow.log_text("artifact upload works", "check.txt")

This tests three things at once: the address, metadata writes and artifact uploads. Artifact problems often appear only now, because a run with parameters and metrics can succeed while file uploads fail. Then open the run in the browser and download check.txt.

Operating the server

Plan the ordinary work of running a service:

Task Why
Back up database and artifacts Restore after failure or mistakes
Test a restore A backup you never restored is unproven
Monitor disk and storage growth Runs and traces accumulate
Apply updates Security fixes and new features
Review users and permissions People join and leave

Back up the database and artifact storage at times that fit together. A database that refers to files you did not back up is only half a backup.

Version compatibility

Clients and servers with very different MLflow versions can have trouble, especially for newer features. Agree on a supported client version range for your team, state it in your project requirements, and upgrade the server and clients in a planned order. Read the release notes before a major upgrade.

Common mistakes

Do not keep the only copy of a shared database on someone's laptop, and do not solve connection errors by switching off security checks. Find the cause instead: the address, the firewall, the allowed hosts, or the credentials. If you widen access to test something, set it back right away.

Keep a short operations note that lists the server address, store locations, backup schedule and the person to contact when it fails.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. Which flag sets where run metadata is stored?

    The backend store URI points to the metadata database.
  2. 2. What should you do before upgrading the database schema?

    Migrations can be slow and may not be transactional.
  3. 3. What is a benefit of proxied artifact access?

    The server handles storage access on behalf of clients.

Summary

  • A tracking server shares runs, models and traces.
  • Use a real database and shared artifact storage for teams.
  • Add HTTPS, authentication and host limits.
  • Back up before you upgrade the schema.

Next: Serve and Deploy Models

Your progress is saved in this browser. No account needed.