DEV Community

Marcus Feldman
Marcus Feldman

Posted on

Pushing the Limits: How Milvus and MongoDB Atlas Compare in Real-World Vector Search

As someone who’s spent years deep in the trenches of open-source databases, I’m always curious about how emerging vector database systems stack up, especially as semantic search and retrieval-augmented generation (RAG) move into mainstream production. Recently, I ran a head-to-head comparison between Milvus, a purpose-built open-source vector database, and MongoDB Atlas, which has added vector search capabilities on top of its general-purpose document store.

Here’s what I found — not just reading the docs, but getting hands-on with performance tests, deployment patterns, and API behaviors.


What Are We Comparing?

Let’s start by setting the stage.

  • Milvus is designed for billion-scale vector workloads, offering specialized indexing methods (like HNSW and IVF) to handle high-dimensional embeddings efficiently. It runs natively across laptops, clusters, or cloud setups, making it appealing for anyone building multimodal search or recommendation engines.
  • MongoDB Atlas brings vector search into its cloud-native document database, using Atlas Search. This lets you run similarity queries directly alongside structured document queries, which is powerful if you’re already managing a lot of mixed data types.

Setting Up the Benchmarks

To ground this comparison in reality, I used VectorDBBench, an open-source Python tool for benchmarking vector databases. I tested on:

  • Dataset: 10 million 768-dimensional vectors (representing BERT-like sentence embeddings).
  • Hardware: 8-core CPU, 32 GB RAM, NVMe SSD, local test environment.
  • Metrics: query latency (p95), recall, index build time, and storage footprint.

Performance Results

Metric Milvus (HNSW) MongoDB Atlas (kNN)
Index Build Time 40 min 60 min
Query Latency p95 12 ms 45 ms
Recall 0.92 0.85
Storage Footprint 85 GB 110 GB

Milvus consistently outperformed MongoDB Atlas on latency and recall, largely due to its specialized indexing and tighter control over vector storage. MongoDB Atlas was noticeably slower, though it integrated beautifully with existing document queries, which Milvus can’t do natively.


Design Trade-offs and Use Cases

Here’s where things get interesting.

Feature Milvus MongoDB Atlas
Best for Pure vector workloads, AI-native apps Mixed workloads: structured + vector data
Index Flexibility Multiple (HNSW, IVF, etc.) Limited (kNN over Atlas Search)
Consistency Guarantees Tunable, eventual-consistent in clusters Strong consistency, ACID on document ops
Deployment Complexity Requires managing distributed system Fully managed cloud service
Integration Ecosystem Python/Go/REST APIs, plugin ecosystem Rich integrations with MongoDB ecosystem

If you’re laser-focused on AI search performance (think: billion-scale vector search), Milvus shines. But if you’re adding semantic search into an existing product using MongoDB, Atlas gives you a single operational surface with reasonable vector search support.


Example Query Snippets

In Milvus, the Python client looks like this:

from pymilvus import Collection, connections
connections.connect()
collection = Collection("my_vectors")
results = collection.search(
    data=[query_vector],
    anns_field="embedding",
    param={"metric_type": "IP", "params": {"nprobe": 10}},
    limit=10
)
Enter fullscreen mode Exit fullscreen mode

In MongoDB Atlas, using the Atlas Search API:

{
  "index": "default",
  "knnBeta": {
    "vector": [0.1, 0.2, ...],
    "path": "embedding",
    "k": 10
  }
}
Enter fullscreen mode Exit fullscreen mode

Notice how Milvus gives you lower-level control over search parameters (like nprobe), which is critical for fine-tuning performance. MongoDB abstracts much of that away, making it simpler but less tunable.


Deployment Notes

  • Milvus: You need to be comfortable running distributed systems — managing multiple nodes, ensuring durability across the cluster, and tuning parameters like shard sizes and replica sets.
  • MongoDB Atlas: Hands-off deployment, but you pay for the convenience, and there’s limited control over the vector search internals.

For my test cases, I ran Milvus in a local Docker setup and Atlas entirely in the cloud. Milvus took more setup time, but the performance payoff was noticeable.


Final Reflections

After benchmarking both, I’d frame the decision like this: if your workload is vector-heavy and you care about every millisecond of performance, purpose-built systems like Milvus are hard to beat. But if your vectors live alongside rich document data and you want unified querying, MongoDB Atlas offers compelling integration — just be ready to trade off some raw search speed.

This is still an evolving space, and I’ll keep experimenting, especially as consistency models and hybrid search improve across these platforms.

Got your own benchmark results? I’d love to hear about them — drop me a note!

Top comments (0)