ComfyLess is a ComfyUI serverless platform developed in Go, providing task queue management and automatic worker scaling capabilities.
- π Component-based Design: Queue management and worker management use interface design for pluggable replacement
- βοΈ Multi-cloud Support: Supports Docker local deployment and Novita AI cloud GPU instances
- π¦ Docker Containerization: Uses Docker to manage ComfyUI worker instances
- π Auto-scaling: Automatically scales worker count based on task load
- πΎ Task Queue: Redis-based task queue
- π― Standard API: Compatible with ComfyUI standard API interface
- π Monitoring Metrics: Provides detailed queue and worker metrics monitoring
- π§ Health Checks: Automatic worker health status monitoring
ComfyLess supports multiple worker providers:
- Uses local Docker to manage worker instances
- Suitable for development environments and small-scale deployments
- Requires Docker environment
- Uses Novita AI cloud GPU instances
- Auto-scaling, pay-as-you-go
- Supports multiple GPU specifications
- See Novita Provider Documentation
- Go 1.21+
- Redis
- Docker (if using Docker Provider)
- Novita AI account (if using Novita Provider)
go mod download# Option 1: Use quick start configuration
cp deploy/quickstart.env .env
source .env
# Build and run
go build -o comfyless ./cmd/main.go
./comfyless
# Option 2: Manual configuration
export REDIS_HOST=localhost
export REDIS_PORT=6379
export WORKER_IMAGE=novitalabs/comfyui:flux1-dev-fp8v5
export MAX_WORKERS=10
export MIN_WORKERS=1
go run ./cmd/main.go# Use environment configuration
cp deploy/env.example .env
# Edit .env file with your Novita credentials
vim .env
# Or set environment variables directly
export NOVITA_API_KEY="your-api-key"
export NOVITA_PRODUCT_ID="your-product-id"
export REDIS_HOST=localhost
export REDIS_PORT=6379
# Build and run
go build -o comfyless ./cmd/main.go
./comfyless# Quick start with Docker Compose
cd deploy/
cp env.example .env
# Edit .env with your configuration
docker-compose up -dFor detailed configuration, please refer to the Novita Provider Documentation and Deployment Documentation.
curl -X POST http://localhost:8080/api/v1/tasks \
-H "Content-Type: application/json" \
-d '{
"workflow_id": "text_to_image_v1",
"priority": 5,
"payload": {
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 8,
"denoise": 1,
"latent_image": [
"5",
0
],
"model": [
"4",
0
],
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"sampler_name": "euler",
"scheduler": "normal",
"seed": 46588125086418,
"steps": 20
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "flux1-dev-fp8.safetensors"
}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 512,
"width": 512
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "text, watermark"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"4",
2
]
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
}
}
}
}'curl http://localhost:8080/api/v1/tasks/{task_id}# Get worker metrics
curl http://localhost:8080/api/v1/workers/metrics
# List all workers
curl http://localhost:8080/api/v1/workers
# Novita Provider specific status interface
curl http://localhost:8080/novita/statusBoth queue manager and worker manager are designed as interfaces that can be replaced as needed.
type QueueManager interface {
Start(ctx context.Context) error
AddTask(task *queue.Task) error
GetNextTask() (*queue.Task, error)
UpdateTask(task *queue.Task) error
}type WorkerManager interface {
Start(ctx context.Context) error
GetAvailableWorker() (*interfaces.Worker, error)
CreateWorker() (*interfaces.Worker, error)
TerminateWorker(workerID string) error
GetWorkerMetrics() *interfaces.WorkerMetrics
}ComfyLess follows a modular architecture with clear separation of concerns:
- API Layer (
internal/api/): Handles HTTP requests and responses - Queue Management (
internal/queue/): Redis-based task queue with priority support - Worker Management (
internal/worker/): Pluggable worker providers (Docker, Novita AI) - Task Dispatcher (
internal/dispatcher/): Orchestrates task assignment and monitoring - ComfyUI Client (
internal/comfyui/): Communicates with ComfyUI instances - Configuration (
internal/config/): Environment-based configuration management
comfyless/
βββ cmd/
β βββ main.go # Main program entry point
βββ internal/ # Internal application code
β βββ api/ # HTTP API layer
β β βββ handler.go # API request handlers
β β βββ types.go # API request/response types
β βββ queue/ # Task queue management
β β βββ manager.go # Queue manager implementation
β β βββ types.go # Queue data types
β βββ worker/ # Worker management
β β βββ docker_manager.go # Docker provider implementation
β β βββ novita_manager.go # Novita AI provider implementation
β β βββ factory.go # Worker factory
β β βββ persistence.go # Worker state persistence
β βββ dispatcher/ # Task dispatcher
β β βββ dispatcher.go # Task dispatch logic
β βββ interfaces/ # Interface definitions
β β βββ queue.go # Queue interface
β β βββ worker.go # Worker interface
β β βββ types.go # Common types
β βββ comfyui/ # ComfyUI client
β β βββ client.go # ComfyUI API client
β βββ config/ # Configuration management
β βββ config.go # Configuration loading
βββ deploy/ # Deployment configurations
β βββ Dockerfile # Docker image build file
β βββ docker-compose.yml # Docker Compose configuration
β βββ config.json # JSON configuration example
β βββ env.example # Environment variables template
β βββ quickstart.env # Quick start configuration
β βββ development.env # Development environment config
β βββ production.env # Production environment config
β βββ README.md # Deployment documentation
βββ docs/ # Documentation
β βββ openapi.yaml # OpenAPI specification (YAML)
β βββ openapi.json # OpenAPI specification (JSON)
β βββ API.md # API documentation
β βββ TASK_DISPATCH_FLOW.md # Task dispatch flow documentation
β βββ COMPLETE_WORKFLOW.md # Complete workflow documentation
β βββ NOVITA_PROVIDER.md # Novita AI provider documentation
βββ examples/ # Example files
β βββ create_task.json # Task creation example
βββ go.mod # Go module definition
βββ go.sum # Go module checksums
βββ LICENSE # License
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
Comprehensive documentation is available in the docs/ directory:
- API Documentation - Complete REST API reference with examples
- Task Dispatch Flow - Detailed task lifecycle and dispatch logic
- Complete Workflow - End-to-end system workflow documentation
- Novita Provider - Cloud GPU provider integration guide
- OpenAPI Specification - Machine-readable API specification
For deployment and configuration:
- Deployment Guide - Deployment configurations and environment setup
- Environment Examples - Ready-to-use configuration templates
This project is licensed under the Apache 2.0 License.