# Polyaxon

> ML platform for experiment tracking and automation.

- Category: AI & Machine Learning
- Difficulty: advanced
- Components: polyaxon, postgres, redis, rabbitmq
- Tags: polyaxon, mlops, experiments, automation
- Source: https://docker.recipes/ai-ml/polyaxon

## Overview

Polyaxon is a comprehensive machine learning operations platform that provides experiment tracking, hyperparameter optimization, and ML workflow automation. Originally developed to address the challenges of managing complex ML experiments at scale, Polyaxon offers a unified interface for tracking experiments, managing datasets, and orchestrating training jobs across different compute environments. The platform supports both individual data scientists and enterprise teams looking to standardize their ML workflows.

This Docker stack combines Polyaxon's API server and scheduler with PostgreSQL for persistent metadata storage, Redis for caching and session management, and RabbitMQ for reliable task queuing and job coordination. PostgreSQL handles experiment metadata, model artifacts information, and user data with ACID compliance, while Redis accelerates frequent queries and caches intermediate results. RabbitMQ manages the distributed task execution, ensuring reliable job scheduling and status updates across the platform.

ML teams, data science departments, and AI startups benefit from this configuration when they need centralized experiment tracking without the complexity of Kubernetes deployment. This setup is particularly valuable for teams transitioning from notebook-based workflows to production ML pipelines, organizations implementing MLOps best practices, and research groups requiring reproducible experiment management with proper versioning and collaboration features.

## Features

- Comprehensive experiment tracking with automatic logging of hyperparameters, metrics, and artifacts
- PostgreSQL-backed metadata store with full ACID compliance for experiment reproducibility and audit trails
- Redis-powered caching layer for fast dashboard queries and real-time experiment monitoring
- RabbitMQ message broker enabling distributed job scheduling and reliable task execution
- RESTful API server supporting programmatic experiment management and integration with ML frameworks
- Scheduler service for automated hyperparameter optimization and experiment queue management
- Multi-framework support including TensorFlow, PyTorch, Scikit-learn, and XGBoost integration
- Web-based dashboard for experiment comparison, visualization, and collaboration across ML teams

## Use cases

- ML research teams tracking hundreds of experiments with different model architectures and hyperparameters
- Data science departments implementing standardized MLOps workflows across multiple projects
- Startups building AI products requiring experiment versioning and model performance comparison
- Academic institutions managing student research projects with proper experiment documentation
- Enterprise ML teams migrating from scattered notebook experiments to centralized tracking systems
- Consulting firms demonstrating ML model development progress to clients with detailed experiment logs
- MLOps engineers setting up local development environments before Kubernetes production deployment

## Prerequisites

- Minimum 4GB RAM recommended for PostgreSQL experiment storage and Redis caching operations
- Docker Engine 20.10+ and Docker Compose v2 for proper container orchestration support
- Port 8000 available for Polyaxon API access and web interface connectivity
- Python environment with pip for installing polyaxon CLI client and ML framework integrations
- Basic understanding of machine learning workflows and experiment management concepts
- At least 10GB available disk space for PostgreSQL data persistence and experiment artifact storage

## docker-compose.yml

```yaml
services:
  polyaxon-api:
    image: polyaxon/polyaxon-api:latest
    container_name: polyaxon-api
    restart: unless-stopped
    environment:
      POLYAXON_DB_HOST: postgres
      POLYAXON_REDIS_HOST: redis
      POLYAXON_RABBITMQ_HOST: rabbitmq
    ports:
      - "8000:8000"
    depends_on:
      - postgres
      - redis
      - rabbitmq
    networks:
      - polyaxon

  polyaxon-scheduler:
    image: polyaxon/polyaxon-scheduler:latest
    container_name: polyaxon-scheduler
    restart: unless-stopped
    environment:
      POLYAXON_DB_HOST: postgres
      POLYAXON_REDIS_HOST: redis
    depends_on:
      - postgres
      - redis
    networks:
      - polyaxon

  postgres:
    image: postgres:16-alpine
    container_name: polyaxon-postgres
    environment:
      POSTGRES_DB: polyaxon
      POSTGRES_USER: polyaxon
      POSTGRES_PASSWORD: polyaxon
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - polyaxon

  redis:
    image: redis:alpine
    container_name: polyaxon-redis
    networks:
      - polyaxon

  rabbitmq:
    image: rabbitmq:3-management-alpine
    container_name: polyaxon-rabbitmq
    networks:
      - polyaxon

volumes:
  postgres_data:

networks:
  polyaxon:
    driver: bridge
```

## .env

```bash
# Configure via polyaxon CLI
```

## Usage notes

- Docs: https://polyaxon.com/docs/
- API at http://localhost:8000 - configure via polyaxon CLI
- CLI: pip install polyaxon, then polyaxon config set --host=localhost:8000
- Submit jobs: polyaxon run -f polyaxonfile.yaml
- Experiment tracking with automatic artifact storage
- Full platform requires Kubernetes for distributed workloads

## Troubleshooting

- API connection refused on port 8000: Verify postgres and redis containers are healthy before polyaxon-api starts
- Polyaxon CLI cannot connect to localhost:8000: Run 'polyaxon config set --host=http://localhost:8000' with http protocol specified
- Database connection errors in polyaxon-api logs: Check POSTGRES_PASSWORD matches between postgres and polyaxon-api environment variables
- Scheduler not processing jobs: Ensure RabbitMQ container is running and accessible from polyaxon-scheduler service
- High memory usage in PostgreSQL: Configure postgres shared_buffers and work_mem limits using additional environment variables
- Redis connection timeouts during experiment logging: Increase Redis memory allocation or add redis.conf with appropriate timeout settings

