MLflow: Track and Manage ML Experiments

Khimananda Oli 8 min read Virtualization
MLflow: Track and Manage ML Experiments

By Khimananda Oli | Last reviewed: August 2026

Reproducing a machine learning result three months after training is nearly impossible without structured metadata. You need a system that captures parameters, metrics, artifacts, and code versions automatically during every run. Using MLflow: Track and Manage ML Experiments solves this reproducibility crisis by providing a standardized, open-source platform for the entire ML lifecycle. This guide covers the practical implementation details required to move from ad-hoc notebooks to an auditable, production-grade MLOps workflow.

Data ScientistLocal Notebook / CImlflow.log_param()mlflow.log_metric()mlflow.log_artifact()MLflow Tracking ServerMetadata StorePostgreSQL / MySQLArtifact StoreS3 / GCS / Azure BlobModel RegistryVersioned Models + StagesProductionServing / BatchDocker ContainerKubernetes PodCloud Endpoint
MLflow architecture separates metadata storage, artifact persistence, and model serving for scalable experiment tracking

How do you set up MLflow to track and manage ML experiments?

Setting up a production-grade tracking environment requires separating the metadata backend from the artifact storage. While mlflow ui works for local debugging, teams need a remote tracking server backed by a managed database and object storage. This aligns with principles discussed in MLOps from notebook to production, where infrastructure reliability directly impacts model velocity.

Configure the Remote Tracking Server

Deploy the tracking server as a dedicated service. For AWS environments, use RDS PostgreSQL for metadata and S3 for artifacts. The server itself runs as a containerized application behind an ALB with OIDC authentication.

# Start MLflow tracking server with remote backend
mlflow server \
  --backend-store-uri postgresql://user:pass@rds-host:5432/mlflow \
  --default-artifact-root s3://my-mlflow-artifacts/ \
  --host 0.0.0.0 \
  --port 5000 \
  --gunicorn-opts "--workers 4 --threads 2"

Instrument Training Code Correctly

Explicit logging provides the most control over what gets captured. Always set the tracking URI at the start of your script and use nested runs for cross-validation or hyperparameter sweeps.

import mlflow
import mlflow.sklearn

mlflow.set_tracking_uri("https://mlflow.internal.company.com")
mlflow.set_experiment("fraud-detection-v2")

with mlflow.start_run(run_name="xgboost-baseline"):
    # Log configuration
    mlflow.log_params({
        "n_estimators": 500,
        "max_depth": 6,
        "learning_rate": 0.05
    })
    
    # Train and evaluate
    model.fit(X_train, y_train)
    accuracy = model.score(X_test, y_test)
    
    # Log results
    mlflow.log_metric("test_accuracy", accuracy)
    mlflow.sklearn.log_model(model, "model", registered_model_name="fraud-detector")

A common mistake is logging large datasets as artifacts. Instead, log only the dataset hash, schema, and a reference URI. This keeps the artifact store lean and queryable. For guidance on handling data dependencies securely, review Kubernetes secrets management done right when mounting credentials for artifact access.

What are the core components of MLflow experiment tracking?

Understanding the internal separation of concerns prevents architectural debt. MLflow consists of four distinct but integrated components, each serving a specific function in the MLflow: Track and Manage ML Experiments workflow.

  • Tracking: Captures parameters, metrics, tags, and artifacts for each run. Supports hierarchical nesting for complex experiments like grid search or ensemble methods.
  • Projects: Packages code with a standardized interface (MLproject file) defining entry points, dependencies, and environment specifications. Enables reproducible execution across different compute environments.
  • Models: Provides a standard format for packaging models with flavor-specific serialization (PyFunc, Sklearn, TensorFlow). Includes dependency inference and signature validation.
  • Registry: Centralized repository for model lifecycle management. Tracks versions, aliases, stage transitions, and approval workflows independent of experiment runs.
ExperimentParametersMetricsArtifactsCode VersionProjectMLproject FileConda/Docker EnvEntry PointsDependenciesModelPyFunc FlavorSignatureInput ExampleRequirementsRegistryVersion HistoryAliases / TagsStage TransitionsApproval WorkflowShared Artifact Store (S3/GCS/Azure)All components read/write artifacts through unified storage layer
MLflow components interact through shared artifact storage while maintaining independent metadata schemas

How does MLflow compare to Weights & Biases and Kubeflow?

Choosing the right tool depends on team size, compliance requirements, and existing infrastructure. Each platform makes different trade-offs between ease of use and operational control.

CriteriaMLflowWeights & BiasesKubeflow Pipelines
Deployment ModelSelf-hosted or Databricks managedSaaS-first, on-prem enterprise optionKubernetes-native, self-hosted only
Learning CurveLow — minimal API surfaceMedium — rich UI featuresHigh — K8s + Argo Workflows
Compliance ControlFull data sovereigntyVendor-managed unless enterpriseFull control, audit-friendly
OrchestrationBasic Projects, external orchestrator neededLaunch agent, limited DAG supportNative DAG pipelines, recurring jobs
Cost at ScaleInfrastructure onlyPer-seat licensing adds upCluster costs + engineering overhead
Best ForTeams needing full ownership and flexibilityRapid experimentation with rich visualizationComplex multi-step pipelines on K8s

In practice, many organizations adopt MLflow for its neutrality and integration breadth. If you operate under strict data residency requirements common in Nepal's fintech sector or government projects, self-hosted MLflow eliminates third-party data exposure. Teams already standardized on Kubernetes may prefer Kubeflow despite the steeper learning curve, especially when integrating with blue-green and canary deploys on Kubernetes for progressive model rollouts.

How do you secure MLflow in production environments?

The default MLflow installation has no authentication. Running it exposed on a network is a critical security failure. Production deployments require defense-in-depth aligned with SOC 2 and ISO 27001 controls.

Implement Authentication and Authorization

Place MLflow behind a reverse proxy with OIDC or SAML authentication. Use nginx or an ingress controller to enforce TLS termination and inject identity headers. Never expose port 5000 directly.

# Nginx reverse proxy with OIDC auth
server {
    listen 443 ssl http2;
    server_name mlflow.internal.company.com;
    
    ssl_certificate /etc/ssl/certs/mlflow.crt;
    ssl_certificate_key /etc/ssl/private/mlflow.key;
    
    location / {
        auth_request /oauth2/auth;
        proxy_pass http://mlflow-backend:5000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Enforce Artifact Access Controls

Artifact stores must have bucket policies restricting access to the MLflow service account only. Enable server-side encryption and versioning on S3 or equivalent. Audit logs should capture all read/write operations for compliance evidence collection.

Network Isolation and Secrets Management

Deploy the tracking server in a private subnet with no public internet access. Database credentials and cloud provider tokens must be injected via secrets managers like HashiCorp Vault or AWS Secrets Manager — never stored in environment variables or config files. Review secrets management with HashiCorp Vault for patterns applicable to ML infrastructure.

Private VPC / Network BoundaryUsers / CI RunnersOIDC AuthenticatedTLS EncryptedNo Direct DB AccessReverse ProxyNginx / IngressAuth ValidationRate LimitingMLflow ServerPrivate Subnet OnlyService Account IAMAudit Logging EnabledPostgreSQL (RDS)Encrypted at RestVPC Endpoint OnlyAutomated BackupsS3 Artifact StoreBucket Policy RestrictedServer-Side EncryptionVersioning EnabledSecurity Controls: Zero Public Exposure • IAM Least Privilege • Encryption Everywhere • Audit Trails • Secret Injection
Production MLflow requires layered security with network isolation, authenticated access, and encrypted storage backends

How do you integrate MLflow into CI/CD pipelines?

Treating model training as a first-class CI/CD citizen prevents drift between development and production. Every merge to main should trigger automated retraining, evaluation, and conditional registration.

  1. Trigger on Code or Data Change: Use webhooks or scheduled pipelines to initiate training when source code or dataset manifests change.
  2. Run Tests Before Training: Validate data schemas, check for feature drift, and run unit tests on preprocessing logic before expensive GPU allocation.
  3. Log Everything Automatically: Use mlflow.autolog() for supported frameworks or explicit logging for custom training loops. Tag runs with git commit SHA and pipeline run ID.
  4. Evaluate Against Baseline: Compare new run metrics against the current production model. Fail the pipeline if regression exceeds defined thresholds.
  5. Register Conditionally: Only promote models that pass evaluation gates. Use MLflow aliases (champion, challenger) instead of deprecated stages for cleaner lifecycle management.
  6. Deploy via GitOps: Trigger downstream deployment pipelines by updating a manifest repository. This maintains auditability and enables rollback through git history.

This pattern mirrors traditional software delivery but accounts for ML-specific non-determinism. Monitoring deployed models for drift connects directly to observability practices covered in monitor ML models in production drift.

Getting Started with MLflow Experiment Tracking

Start small but architect correctly from day one. Set up a remote tracking server with proper authentication before your team accumulates dozens of untracked local runs. Instrument code explicitly rather than relying solely on autologging — this builds muscle memory for what matters. Treat the model registry as the single source of truth for production candidates, not just a storage location. As your MLOps maturity grows, extend MLflow with custom plugins for evaluation, deployment targets, and compliance reporting. The foundation you build now determines whether scaling ML becomes sustainable or chaotic. Ready to implement? Contact me to discuss your specific ML infrastructure requirements or audit preparation needs.

Frequently Asked Questions

MLflow is an open-source platform that logs parameters, metrics, artifacts, and code versions. It provides reproducibility and comparison across runs without vendor lock-in, making experiment management standardized for teams using Python, R, or REST APIs in 2026.

Run pip install mlflow to get the latest stable version. Launch the UI with mlflow ui and access localhost:5000. This setup requires no external database initially and works immediately for local Python script tracking and artifact storage.

Yes. MLflow supports R, Java, Scala, and REST API logging. Use the fluent API or REST endpoints to log metrics and parameters from any language, though Python offers the most extensive autologging integrations for frameworks like PyTorch and TensorFlow.

MLflow is self-hosted and free with full data ownership, while W&B is SaaS-first with team collaboration features. Choose MLflow for on-premise compliance and cost control; choose W&B for managed infrastructure and advanced visualization without DevOps overhead.

Use PostgreSQL or MySQL for metadata and S3, GCS, or Azure Blob for artifacts. SQLite is only for local testing. Configure via --backend-store-uri and --default-artifact-root flags when starting the tracking server to ensure durability and concurrent access.

Call mlflow.sklearn.autolog() before training. This automatically captures hyperparameters, metrics, model artifacts, and input examples without manual logging code. Disable specific outputs using parameters like log_models=False if artifact storage becomes a bottleneck during high-frequency experimentation.

No. The default server lacks authentication and encryption. Deploy behind a reverse proxy with OAuth2 or basic auth, enable TLS termination, and restrict network access. Never expose port 5000 publicly without these safeguards in production environments.

A minimal EC2 t3.medium instance costs roughly thirty dollars monthly plus RDS and S3 fees. Total spend typically ranges fifty to one hundred dollars for small teams. Costs scale with artifact volume and database instance size rather than experiment count.

Verify the active run context exists and the tracking URI matches your server. Check that mlflow.set_tracking_uri points correctly and that you called mlflow.start_run before logging. Network timeouts or permission errors on remote backends also silently fail metric writes.

Yes, when using a relational database backend like PostgreSQL. SQLite does not support concurrent writes reliably. Ensure proper connection pooling and consider read replicas for heavy query loads to prevent locking issues during parallel experiment execution.

Use the mlflow experiments export and import CLI commands or write custom scripts using the client API. Artifact migration requires copying files between storage backends separately since metadata and artifacts are stored independently in the architecture.

Yes. Deploy the tracking server as a StatefulSet with persistent storage. Configure pods to point to the service endpoint via environment variables. Use Helm charts from the community repository for standardized deployments with ingress, autoscaling, and secret management built in.

They persist indefinitely unless deleted manually or via retention policies. Implement lifecycle rules on artifact storage and schedule periodic cleanup jobs. Archive completed projects to cold storage to reduce database bloat and maintain UI responsiveness for active work.

Log dataset hashes, URIs, or DVC references as parameters or tags. Store actual data in external versioned storage like S3 with Delta Lake or LakeFS. Avoid storing large raw datasets directly as MLflow artifacts to prevent repository bloat.

Yes. Retrieve the run ID and call mlflow.start_run(run_id=existing_id) to append new metrics and artifacts. This preserves continuity for long-running training jobs that crash or require checkpoint-based resumption without losing prior logged state.