Published on December 28, 2024 by Australian AI Company

Milvus Azure deployment architecture

Introduction

Milvus is a powerful open-source vector database designed for AI applications and similarity search at scale. In this comprehensive tutorial, you'll learn how to deploy Milvus on Azure Container Instances (ACI) using Docker Compose, providing a scalable and cost-effective solution for your vector database needs.

This guide will walk you through the complete process of setting up Milvus v2.6.0-rc1 on Azure, including etcd for metadata storage and MinIO for object storage, all orchestrated through Azure Container Instances.

1Prerequisites

Before we begin, ensure you have the following:

  • Azure CLI installed and configured on your local machine
  • An active Azure subscription with appropriate permissions
  • Basic understanding of Docker and containerization concepts
  • Familiarity with YAML configuration files

2Setting Up Azure Resources

First, we'll create the necessary Azure resources including a resource group and storage account for persistent data.

Set Up Environment Variables

First, we'll define the variables for our deployment. You can customize these values based on your preferences:

RESOURCE_GROUP="milvus-aci-rg-v2"
LOCATION="australiaeast"
STORAGE_ACCOUNT="milvusstorage$RANDOM"
FILE_SHARE="milvus-data"

You can copy the following code and paste it into your terminal to set up the environment variables:


RESOURCE_GROUP="milvus-aci-rg-v2"
LOCATION="australiaeast"
STORAGE_ACCOUNT="milvusstorage$RANDOM"
FILE_SHARE="milvus-data"

Create Resource Group

Create a new resource group to organize all our Milvus-related resources:

# Create a Resource Group
az group create --name $RESOURCE_GROUP --location $LOCATION

Create Storage Account

Create an Azure Storage Account that will provide persistent storage for our Milvus data:


az storage account create --name $STORAGE_ACCOUNT --resource-group $RESOURCE_GROUP --location $LOCATION --sku Standard_LRS

Get Storage Key

Retrieve the storage account key and create a file share for persistent data storage:


az storage account keys list \
  --resource-group $RESOURCE_GROUP \
  --account-name $STORAGE_ACCOUNT \

Create File Share

Create a file share for persistent data storage:


az storage share create --name $FILE_SHARE --account-name $STORAGE_ACCOUNT --account-key $STORAGE_KEY

3Creating the ACI Configuration

Now we'll create the Azure Container Instances YAML configuration file that defines our Milvus deployment with all required services.

Create a file named deploy-aci-v2.yml with the following content:

# ACI Configuration File for Milvus Standalone (v2.6.0-rc1)
apiVersion: 2023-05-01
location: australiaeast
name: milvus-container-group-v2
properties:
  containers:
  - name: milvus-etcd
    properties:
      image: quay.io/coreos/etcd:v3.5.18
      resources:
        requests:
          cpu: 1.0
          memoryInGB: 2.0
      command:
      - etcd
      - -advertise-client-urls=http://localhost:2379
      - -listen-client-urls
      - http://0.0.0.0:2379
      - --data-dir
      - /etcd
      environmentVariables:
      - name: 'ETCD_AUTO_COMPACTION_MODE'
        value: 'revision'
      - name: 'ETCD_AUTO_COMPACTION_RETENTION'
        value: '1000'
      - name: 'ETCD_QUOTA_BACKEND_BYTES'
        value: '4294967296'
      - name: 'ETCD_SNAPSHOT_COUNT'
        value: '50000'
      volumeMounts:
      - name: milvus-data-volume
        mountPath: /etcd
      livenessProbe:
        exec:
          command:
          - etcdctl
          - endpoint
          - health
        initialDelaySeconds: 30
        periodSeconds: 30
        timeoutSeconds: 20
        failureThreshold: 3

  - name: milvus-minio
    properties:
      image: minio/minio:RELEASE.2023-03-20T20-16-18Z
      resources:
        requests:
          cpu: 1.0
          memoryInGB: 2.0
      ports:
      - port: 9000
        protocol: TCP
      - port: 9001
        protocol: TCP
      command:
      - /bin/sh
      - -c
      - "minio server /minio_data --console-address :9001"
      environmentVariables:
      - name: 'MINIO_ACCESS_KEY'
        value: 'minioadmin'
      - name: 'MINIO_SECRET_KEY'
        value: 'minioadmin'
      volumeMounts:
      - name: milvus-data-volume
        mountPath: /minio_data
      livenessProbe:
        exec:
          command:
          - /bin/sh
          - -c
          - "curl -f http://localhost:9000/minio/health/live"
        initialDelaySeconds: 30
        periodSeconds: 30
        timeoutSeconds: 20
        failureThreshold: 3

  - name: milvus-standalone
    properties:
      image: milvusdb/milvus:v2.6.0-rc1
      resources:
        requests:
          cpu: 2.0
          memoryInGB: 4.0
      ports:
      - port: 19530
        protocol: TCP
      - port: 9091
        protocol: TCP
      command:
      - milvus
      - run
      - standalone
      environmentVariables:
      - name: 'ETCD_ENDPOINTS'
        value: 'localhost:2379'
      - name: 'MINIO_ADDRESS'
        value: 'localhost:9000'
      - name: 'MQ_TYPE'
        value: 'woodpecker'
      volumeMounts:
      - name: milvus-data-volume
        mountPath: /var/lib/milvus
      livenessProbe:
        exec:
          command:
          - /bin/sh
          - -c
          - "curl -f http://localhost:9091/healthz"
        initialDelaySeconds: 90
        periodSeconds: 30
        timeoutSeconds: 20
        failureThreshold: 3

  osType: Linux
  ipAddress:
    type: Public
    ports:
    - port: 19530
      protocol: TCP
    - port: 9091
      protocol: TCP
    - port: 9000
      protocol: TCP
    - port: 9001
      protocol: TCP
    dnsNameLabel: milvus-v2-demo-$RANDOM
  volumes:
  - name: milvus-data-volume
    azureFile:
      shareName: milvus-data
      storageAccountName: YOUR_STORAGE_ACCOUNT_NAME
      storageAccountKey: YOUR_STORAGE_ACCOUNT_KEY
Important: Before deploying, replace YOUR_STORAGE_ACCOUNT_NAME and YOUR_STORAGE_ACCOUNT_KEY with the actual values from your Azure Storage Account.

4Deploying to Azure

Now we'll deploy our Milvus configuration to Azure Container Instances:

Update Configuration File

Replace the placeholder values in the YAML file with your actual storage account details:

# Replace placeholder values in the YAML file
sed -i.bak "s/YOUR_STORAGE_ACCOUNT_NAME/$STORAGE_ACCOUNT/g" deploy-aci-v2.yml
sed -i.bak "s/YOUR_STORAGE_ACCOUNT_KEY/$STORAGE_KEY/g" deploy-aci-v2.yml

Deploy Container Group

Create the container group with all Milvus services:

# Deploy the container group
az container create \
  --resource-group $RESOURCE_GROUP \
  --file deploy-aci-v2.yml

Get Public IP Address

Retrieve the public IP address of your deployed container group:

# Get the public IP address
az container show \
  --resource-group $RESOURCE_GROUP \
  --name milvus-container-group-v2 \
  --query ipAddress.ip \
  --output tsv

5Verifying the Deployment

After deployment, verify that all services are running correctly:

Check Container Status

Verify that all containers in the group are running properly:

# Check container status
az container show \
  --resource-group $RESOURCE_GROUP \
  --name milvus-container-group-v2 \
  --query containers[].instanceView.currentState

Test Milvus Health

Test the Milvus health endpoint (replace YOUR_PUBLIC_IP with your actual IP):

# Test Milvus connection (replace IP with your actual IP)
curl -X GET "http://YOUR_PUBLIC_IP:9091/healthz"

Test MinIO Health

Verify that MinIO object storage is accessible:

# Test MinIO access
curl -X GET "http://YOUR_PUBLIC_IP:9000/minio/health/live"

6Connecting to Your Milvus Instance

Once deployed, you can connect to your Milvus instance using the Python SDK:

Python Connection Example

Use the following Python code to connect to your Milvus instance:

from pymilvus import connections, Collection

# Connect to Milvus
connections.connect(
    alias="default",
    host="YOUR_PUBLIC_IP",  # Replace with your ACI public IP
    port="19530"
)

# Verify connection
print("Connected to Milvus successfully!")

# You can now create collections and perform operations
# Example: List collections
from pymilvus import utility
print("Collections:", utility.list_collections())

Key Benefits of This Setup

  • Cloud-Native: Fully managed container deployment on Azure
  • Cost-Effective: Pay only for the resources you use
  • Scalable: Easy to modify resource allocation as needed
  • Secure: Built-in Azure security and network isolation
  • Persistent: Data stored in Azure Files for durability
  • Reliable: Health checks ensure service availability

Troubleshooting Tips

If you encounter issues during deployment:

  • Check container logs: az container logs --resource-group $RESOURCE_GROUP --name milvus-container-group-v2 --container-name milvus-standalone
  • Verify network connectivity between containers using health check endpoints
  • Ensure sufficient storage space in your Azure File Share
  • Allow sufficient time for initial startup (especially for Milvus standalone)

Next Steps

Now that you have Milvus running on Azure, you can:

  • Create collections and insert vector data
  • Implement similarity search in your applications
  • Set up monitoring and alerting for production use
  • Explore advanced Milvus features like partitioning and indexing
Production Considerations: For production deployments, consider implementing proper authentication, SSL/TLS encryption, backup strategies, and monitoring solutions. You may also want to explore Azure Kubernetes Service (AKS) for more advanced orchestration needs.
BACK TO BLOGS
footer-frame