Milvus
Milvus
An open-source vector database. Specialized for large-scale vector search. Core infrastructure for RAG, semantic search, and recommendation systems, reaching 40,000+ GitHub stars.
Milvus
An open-source vector database. Specialized for large-scale vector search. Core infrastructure for RAG, semantic search, and recommendation systems, reaching 40,000+ GitHub stars.
Milvus is an open-source vector database designed for large-scale vector similarity search. Developed by Zilliz, it can search billions of vectors in milliseconds, so it is used as core infrastructure for RAG (Retrieval-Augmented Generation), semantic search, recommendation systems, and image/video search.
Since being released as open source in 2019, it has earned more than 40,000 GitHub stars as of 2025, becoming the most popular vector DB. As a graduated project of the LF AI & Data Foundation, it is used in production by more than 10,000 organizations worldwide.
Milvus's core strength is its distributed architecture, which separates compute and storage so they can be scaled independently. It supports various index types such as HNSW, IVF, and DiskANN, and maximizes performance relative to cost through GPU acceleration (NVIDIA CAGRA), quantization (RaBitQ), mmap, and more. In version 2.6, built-in embedding functionality enables direct integration with OpenAI, Bedrock, and Vertex AI.
In practice, it is used for knowledge bases of LLM-based chatbots, e-commerce recommendations, image search engines, document similarity analysis, and more. It delivers 3-4 times higher throughput than Elasticsearch while maintaining the same recall, and it also supports hybrid search (vector + keyword).
| Specs | Milvus 2.6 |
|---|---|
| Maximum Number of Vectors | Billions |
| Supported Indexes | HNSW, IVF, FLAT, SCANN, DiskANN + GPU(CAGRA) |
| Memory Optimization | RaBitQ 1-bit quantization (72% memory reduction) |
| Hybrid Search | Vector + BM25 full-text search |
| Built-in Embedding | Integration with OpenAI, Bedrock, Vertex AI, HuggingFace |
# pip install pymilvus
from pymilvus import MilvusClient, DataType
# 1. Milvus 연결 (Milvus Lite - 로컬 개발용)
client = MilvusClient("./milvus_demo.db")
# 2. 컬렉션 생성 (스키마 정의)
# 방법 1: 자동 스키마 (간편)
client.create_collection(
collection_name="documents",
dimension=1536, # OpenAI embedding 차원
metric_type="COSINE" # 유사도 메트릭: COSINE, L2, IP
)
# 방법 2: 상세 스키마 (프로덕션 권장)
from pymilvus import CollectionSchema, FieldSchema
fields = [
FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=256),
FieldSchema(name="content", dtype=DataType.VARCHAR, max_length=65535),
FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=1536),
]
schema = CollectionSchema(fields, description="문서 검색용 컬렉션")
# 3. 데이터 삽입
import openai
def get_embedding(text):
"""OpenAI 임베딩 생성"""
response = openai.embeddings.create(
model="text-embedding-3-small",
input=text
)
return response.data[0].embedding
documents = [
{"title": "RAG 소개", "content": "RAG는 검색 증강 생성 기법입니다..."},
{"title": "벡터 DB란", "content": "벡터 데이터베이스는 임베딩을 저장..."},
{"title": "Milvus 가이드", "content": "Milvus는 대규모 벡터 검색에 특화..."},
]
data = []
for doc in documents:
data.append({
"title": doc["title"],
"content": doc["content"],
"embedding": get_embedding(doc["content"])
})
client.insert(collection_name="documents", data=data)
print(f"✅ {len(data)}개 문서 삽입 완료")
# 4. 벡터 유사도 검색
query = "벡터 데이터베이스의 활용 방법"
query_vector = get_embedding(query)
results = client.search(
collection_name="documents",
data=[query_vector],
limit=3, # Top-K
output_fields=["title", "content"],
search_params={"metric_type": "COSINE", "params": {"nprobe": 10}}
)
print("\n🔍 검색 결과:")
for hits in results:
for hit in hits:
print(f"- [{hit['distance']:.4f}] {hit['entity']['title']}")
# 5. 하이브리드 검색 (벡터 + 필터)
results = client.search(
collection_name="documents",
data=[query_vector],
filter='title like "%Milvus%"', # 메타데이터 필터
limit=3,
output_fields=["title", "content"]
)
# 6. 인덱스 생성 (대규모 데이터용)
index_params = {
"index_type": "HNSW", # 고성능 그래프 기반 인덱스
"metric_type": "COSINE",
"params": {"M": 16, "efConstruction": 256}
}
client.create_index(
collection_name="documents",
field_name="embedding",
index_params=index_params
)
print("✅ HNSW 인덱스 생성 완료")
Comparison of Milvus options as of January 2025.
| Option | Price | Features |
|---|---|---|
| Milvus Open Source | Free (Apache 2.0) | Self-hosted, full features |
| Milvus Lite | Free | pip install, for local development |
| Zilliz Cloud Free | Free | 1 cluster, 1M vectors |
| Zilliz Cloud Standard | $0.07 ~ $0.13 / CU-hour | Managed Service |
| Zilliz Cloud Enterprise | Inquiry required | SLA, dedicated support |
| Performance Metrics | Value | Conditions |
|---|---|---|
| Vector Processing Speed | ~5,000 QPS | 1 million vectors, HNSW |
| Search Latency | <10ms (p99) | top-10 search |
| Memory Reduction (RaBitQ) | 72% | When 1-bit quantization is applied |
"I think Milvus would be a good fit as the vector DB for the RAG pipeline. We have about 5 million documents, and with an HNSW index we can search within 10ms. Starting with version 2.6, OpenAI embedding integration is built in, which simplifies the pipeline."
"Milvus is a distributed vector DB where compute and storage are separated, enabling independent scaling. It supports various indexes such as HNSW and IVF, and RaBitQ quantization can cut memory by more than 70%. It costs less than managed services like Pinecone, and on-premises deployment is also possible."
"pgvector is good for small scale, and Pinecone is convenient because it's managed, but it's expensive. Milvus is the best choice when you need large scale plus on-premises. With Zilliz Cloud, you can also get managed Milvus."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Running a brute-force search over millions of vectors without an index takes several seconds or more. Be sure to create an HNSW or IVF index.
If the dimension specified when creating a collection differs from the actual embedding dimension, insertion fails. Check the dimension for each model, such as 1536 for OpenAI and 1024 for Cohere.
During development, test quickly with Milvus Lite (file-based), and for production, deploy in a distributed manner with Docker Compose or Kubernetes. You can also reduce the management burden with Zilliz Cloud.