repobenchmarks // agent infrastructure
AI TOOLS
$ git clone https://github.com/langgenius/dify.git && docker compose up -d

Dify AI Orchestration Engine

Production-grade visual AI workflow builder, autonomous agent framework, and hybrid RAG pipeline self-hosted on your infrastructure.

Stack: Docker Compose (9 Services) Vector DB: Weaviate / Qdrant Code Exec: Dify Sandbox
Dify Core API & Worker Celery Tasks Data Layer PostgreSQL Weaviate / Redis

Building production-ready Large Language Model (LLM) applications requires orchestrating numerous moving pieces: prompt engineering, document parsing, embedding generation, vector indexing, retrieval-augmented generation (RAG), and multi-step agent reasoning. While frameworks like LangChain and LlamaIndex provide code-level libraries, Dify provides an end-to-end, visual platform that bridges the gap between technical infrastructure and visual application development.

Self-hosting Dify gives engineering teams complete control over their sensitive documents, API keys, and workflow execution without routing proprietary business logic through third-party SaaS platforms.

Dify Microservices Topology & Request Flow Architectural diagram detailing ingress Nginx reverse proxy, frontend web container, backend API, Celery worker queue, data persistence layer, and secure execution sandbox. Nginx Ingress Port 80 Routing dify-web (Next.js) Port 3000 // Studio UI dify-api (Flask) Port 5001 // Core Engine dify-worker Celery Async Queues PostgreSQL 15 (DB) Redis 7 (Cache/Queue) Weaviate (Vector DB) dify-sandbox (Code)
Figure 1: Internal service topology illustrating how Dify coordinates synchronous web requests with asynchronous Celery background workers and vector storage.

Understanding the Dify Service Fleet

Unlike monolithic applications, Dify is architected as an interconnected fleet of microservices packaged via Docker Compose:

  • dify-web: Next.js web application providing the drag-and-drop workflow canvas, prompt evaluation playground, and user management console.
  • dify-api: Python Flask backend managing business logic, user authentication, model provider routing, and dataset orchestration.
  • dify-worker: Celery asynchronous worker process that handles long-running jobs: PDF document parsing, text chunking, embedding calculations, and batch dataset synchronization.
  • weaviate / qdrant: High-performance vector database storing document embeddings for hybrid full-text and semantic vector retrieval.
  • dify-sandbox: Isolated Docker container that executes user-defined Python and JavaScript code nodes safely without risking host access.

Service Inventory & Resource Allocation Matrix

Service Name Container Port Internal Role Recommended Minimum RAM
nginx 80 / 443 Public ingress and static asset reverse proxy 64 MB
dify-web 3000 Next.js frontend user interface 256 MB
dify-api 5001 Core application REST API and LLM router 512 MB - 1 GB
dify-worker None (Queue) Celery async worker for RAG chunking and batch tasks 1 GB - 2 GB
db (PostgreSQL) 5432 Relational storage for users, apps, and chat logs 512 MB
redis 6379 In-memory cache and Celery broker 256 MB
weaviate 8080 Vector database indexing document embeddings 1 GB - 2 GB
dify-sandbox 8190 Sandboxed Python/Node.js code node execution 256 MB

Step-by-Step Deployment Runbook

To deploy Dify on an Ubuntu 22.04 or Debian 12 host with Docker Engine and Docker Compose installed:

bash
# 1. Clone the official Dify repository
git clone https://github.com/langgenius/dify.git
cd dify/docker

# 2. Copy the environment configuration template
cp .env.example .env

# 3. Launch the container stack in detached mode
docker compose up -d

Once deployed, verify container health by checking the status of the entire stack:

docker compose ps

All nine containers should display status Up (healthy). Navigate to http://your-server-ip to complete the initial administrator setup wizard.

✓ Production Tuning & Model Integration Checklist
  • Connecting Local Ollama: To connect local Ollama models to Dify running in Docker, navigate to Settings > Model Provider > Ollama. Set the Base URL to http://host.docker.internal:11434 (or your machine's local LAN IP), never localhost:11434.
  • Worker Concurrency Sizing: In high-throughput RAG environments, PDF document processing can back up. In .env, increase CELERY_WORKER_CONCURRENCY=4 if your VPS has 4 or more CPU cores available.
  • Storage Volume Persistence: Ensure dify/docker/volumes is included in your daily backup snapshots. It houses your PostgreSQL database, Redis keys, uploaded knowledge files, and Weaviate vector indices.
⚠ Minimum Hardware Sizing Warning

Do not attempt to run Dify on a VPS with less than 4 GB of RAM (8 GB is strongly recommended). Weaviate and the Celery worker will suffer out-of-memory (OOM) crashes during concurrent PDF document chunking if memory headroom is insufficient.

Conclusion & Next Steps

Dify stands out as the most mature open-source platform for orchestrating LLM workflows, visual agents, and knowledge-base retrieval. By hosting it on your own servers, you combine enterprise-grade AI capabilities with total data sovereignty.

// Primary Sources & Documentation
Editorial Note: This deployment guide synthesizes official upstream documentation from Dify v0.15+. Hardware requirements and container networking topologies reflect standard production baseline environments.