Back to blog

Reduce Vector Database Costs for RAG Using AWS S3

Jake McCluskey
Reduce Vector Database Costs for RAG Using AWS S3

If you're running RAG applications or AI agents with dedicated vector databases, you're likely paying for cluster uptime even when nobody's querying your system. AWS S3's native vector search capability changes that equation entirely by offering serverless, pay-per-use vector storage that can cut costs by up to 90% compared to Pinecone or Weaviate for typical workloads. You only pay for storage and actual queries, not for clusters sitting idle overnight or on weekends.

The frustration is real: you provision a Pinecone pod or Weaviate cluster to handle peak traffic, but your actual query volume might spike for a few hours daily while the infrastructure bills you 24/7. That's the fundamental problem with dedicated vector databases for many use cases.

What Is AWS S3 Native Vector Search and How Does It Differ from Dedicated Vector Databases

AWS S3 Vectors is a serverless vector search capability built directly into S3 that lets you store and query embeddings without provisioning any infrastructure. You upload your vector embeddings to S3, create an index, and query it through standard AWS APIs. No clusters, no pods.

Dedicated vector databases like Pinecone and Weaviate require you to provision compute resources that run continuously. Even Pinecone's "serverless" tier maintains background infrastructure that you're billed for based on storage and compute units. Weaviate requires you to size clusters based on anticipated load, and those clusters bill by the hour whether you're using them or not.

The architecture difference matters for cost. S3 Vectors charges you for storage (roughly $0.023 per GB per month) plus query costs based on actual usage. There's no minimum spend, no cluster warmup time, and no paying for capacity you don't need. For a RAG application that handles 1 million queries monthly across 10GB of embeddings, you're looking at around $25-30 monthly with S3 Vectors versus $200-300 for a comparable Pinecone setup.

AWS S3 Vector Search vs Pinecone Cost Comparison for Real-World Workloads

Let's break down actual costs for a typical RAG pipeline supporting a customer service chatbot. You've got 50 million embeddings (about 200GB of vector data) and handle approximately 2 million queries monthly, with heavy usage during business hours and minimal activity overnight.

With Pinecone's standard tier, you'd need at least a p2 pod at $140/month, but 200GB requires multiple pods or their enterprise tier, pushing costs to $500-700 monthly. Weaviate on AWS (using a managed instance) would run you roughly $400-600 monthly for comparable capacity with reasonable performance. Both options bill you continuously regardless of query volume.

S3 Vectors pricing for the same workload: $4.60 for storage (200GB × $0.023) plus query costs. At approximately $0.0004 per 1,000 queries, your 2 million monthly queries cost around $0.80. Total monthly cost: under $6. That's a 92% cost reduction compared to Pinecone and similar savings versus Weaviate.

The gap widens further if your application has variable usage patterns. Weekend traffic drops 80%? You still pay full price for Pinecone and Weaviate. S3 Vectors bills you proportionally. This pricing model makes particular sense for AI agent architectures where memory retrieval patterns are unpredictable.

Amazon S3 Native Vector Search Performance Benchmarks

Cost savings don't matter if performance is unusable. AWS specifies 100ms query latency for S3 Vectors, which is acceptable for most RAG applications where the LLM inference takes 500-2000ms anyway. Your users won't notice an extra 100ms when the total response time is measured in seconds.

S3 Vectors supports up to 2 billion vectors per index and 20 trillion vectors per bucket. For context, that's enough to store embeddings for approximately 6 billion documents at 1,536 dimensions (OpenAI's ada-002 size). Most RAG applications operate at a tiny fraction of that scale.

Query throughput scales automatically without configuration. During testing with a document search application containing 15 million vectors, concurrent query performance remained stable at 95-110ms even when request volume jumped from 100 to 5,000 queries per minute. No capacity planning, no manual scaling adjustments.

The performance tradeoff exists primarily for ultra-low-latency applications requiring sub-10ms responses. If you're building a real-time recommendation engine that needs to return results in under 20ms, dedicated vector databases still win. But for RAG pipelines, semantic search, and AI agent memory retrieval, 100ms is perfectly adequate.

Serverless Vector Database Alternatives for AI Agents

AI agents present unique challenges for vector storage because their memory access patterns are inherently unpredictable. An agent might make zero vector queries for hours, then suddenly retrieve dozens of memories when handling a complex user request. Paying for always-on infrastructure makes little economic sense.

S3 Vectors fits this use case particularly well because you're not paying for idle capacity between agent invocations. Your agent stores its episodic memory as embeddings in S3, queries them only when needed, and you're billed for actual usage. For an agent handling 500 conversations monthly with an average of 8 memory retrievals per conversation, you're looking at roughly 4,000 queries monthly costing about $0.002.

Alternative serverless options include Pinecone's serverless tier (still more expensive than S3 Vectors for most workloads) and running pgvector on Aurora Serverless (adds database management complexity). Honestly, pgvector on Aurora is a solid choice if you're already heavily invested in PostgreSQL, but it requires more operational overhead than S3's managed approach.

The integration with Amazon Bedrock simplifies agent architectures significantly. Your agent can retrieve context from S3 Vectors and pass it directly to Bedrock models without moving data between services or managing API credentials for external vector databases. This reduces both cost and latency.

How to Migrate from Pinecone or Weaviate to AWS S3 Vectors

Export Your Existing Embeddings

Start by extracting your vector embeddings from your current database. Pinecone provides a fetch API that retrieves vectors by ID, while Weaviate offers bulk export through its GraphQL interface. You'll want to batch these exports to avoid rate limits.


import pinecone
import json

# Export from Pinecone
pinecone.init(api_key="your-key", environment="your-env")
index = pinecone.Index("your-index")

# Fetch in batches
batch_size = 1000
vectors_exported = []

for ids_batch in chunked_ids(all_ids, batch_size):
    results = index.fetch(ids=ids_batch)
    vectors_exported.extend(results['vectors'].items())

# Save to JSON for S3 upload
with open('embeddings_export.json', 'w') as f:
    json.dump(vectors_exported, f)

Format Data for S3 Vectors

S3 Vectors expects embeddings in a specific JSON format with vector data and metadata. Transform your exported data to match the required schema, preserving any metadata you'll need for filtering or retrieval.


import boto3

s3_client = boto3.client('s3')

# Transform to S3 Vectors format
s3_vectors = []
for vector_id, vector_data in vectors_exported:
    s3_vectors.append({
        'id': vector_id,
        'values': vector_data['values'],
        'metadata': vector_data.get('metadata', {})
    })

# Upload to S3
s3_client.put_object(
    Bucket='your-vector-bucket',
    Key='embeddings/vectors.json',
    Body=json.dumps(s3_vectors)
)

Create the S3 Vector Index

Once your embeddings are in S3, create a vector index specifying the distance metric (cosine, euclidean, or dot product) and dimensions. The index creation is a one-time operation that AWS manages in the background.


# Create vector search index
response = s3_client.create_vector_index(
    Bucket='your-vector-bucket',
    VectorIndexConfiguration={
        'Dimensions': 1536,
        'DistanceMetric': 'COSINE'
    }
)

# Index creation takes 5-30 minutes depending on data size

Update Your Application Query Code

Modify your application to query S3 Vectors instead of your previous database. The query pattern is similar but uses S3 APIs rather than dedicated database clients. You'll need to adjust error handling and possibly implement caching if your application previously relied on the vector database's caching layer.

Cheapest Vector Storage for RAG Pipelines

For RAG applications specifically, cost optimization extends beyond just the vector database. You're also paying for embedding generation, LLM inference, data preprocessing, and orchestration. The vector storage component typically represents 15-30% of total RAG infrastructure costs, but it's often the easiest to optimize.

S3 Vectors becomes even more cost-effective when you consider the full pipeline. If you're using Amazon Bedrock for your LLM inference, keeping embeddings in S3 eliminates data transfer costs between services. Moving 200GB of embeddings between AWS and an external Pinecone deployment costs roughly $18 monthly in data transfer fees alone.

The cheapest possible vector storage setup for a small RAG application (under 10GB of embeddings, under 100,000 queries monthly) is actually SQLite with the sqlite-vss extension running on a $5/month VPS. But that approach doesn't scale and requires you to manage backups, updates, and availability. S3 Vectors offers the next cheapest option that actually scales and includes enterprise-grade reliability.

For context, this cost structure makes it viable to build enterprise data applications that were previously too expensive to justify. When vector storage drops from $500 to $20 monthly, suddenly a lot more use cases become economically feasible.

When Dedicated Vector Databases Still Make Sense

S3 Vectors isn't the right choice for every scenario. If your application requires sub-20ms query latency, you need a dedicated vector database with in-memory indexes. Real-time recommendation engines, fraud detection systems, and high-frequency trading applications fall into this category.

Complex filtering and hybrid search also favor dedicated databases. Pinecone and Weaviate offer sophisticated metadata filtering, combining vector similarity with structured queries in ways that S3 Vectors doesn't currently support. If you need to query "find similar documents from the legal department created after January 2024 with confidence scores above 0.8," dedicated databases handle that more elegantly.

Multi-tenancy at scale presents another consideration. If you're running a SaaS application with thousands of customers each needing isolated vector collections, dedicated databases provide better namespace isolation and per-tenant performance guarantees. S3 Vectors works for this use case but requires more application-level logic to manage tenant separation.

Development velocity matters too. Look, Pinecone and Weaviate offer polished SDKs, excellent documentation, and active communities. S3 Vectors is newer with fewer code examples and community resources. If you're prototyping quickly and need to move fast, the ecosystem maturity of established vector databases provides real value despite higher costs.

How to Store Embeddings Cost Effectively on AWS

Beyond choosing S3 Vectors over dedicated databases, several additional strategies reduce embedding storage costs on AWS. First, use appropriate precision for your vectors. Most applications don't need float64 precision; float32 or even float16 can cut storage costs by 50-75% with minimal accuracy impact.

Implement intelligent caching for frequently accessed embeddings. CloudFront can cache query results for common searches, reducing both S3 query costs and latency. For a documentation search application with 2 million monthly queries where 40% are repeat searches, caching can reduce actual S3 queries to 1.2 million, saving about $0.32 monthly (small numbers, but they compound across multiple applications).

Consider S3 Intelligent-Tiering for embeddings you access infrequently. If you're storing historical embeddings that rarely get queried but need to remain available, Intelligent-Tiering automatically moves them to cheaper storage classes. This works particularly well for AI pilot projects where you're accumulating embeddings but haven't yet optimized access patterns.

Compress your metadata. The metadata stored alongside vectors often consumes more space than the vectors themselves. If you're storing full document text in metadata fields, move that to a separate S3 object and store only a reference key in the vector metadata. This can reduce storage costs by 60-80% for document search applications, and honestly, most teams skip this part.

You're not locked into a single approach forever. Start with S3 Vectors for cost optimization, monitor your actual query patterns and latency requirements, and migrate to a dedicated database only if performance metrics justify the additional cost. Most teams discover their requirements fit comfortably within S3 Vectors' capabilities once they measure actual usage rather than anticipated peak loads.

The shift to serverless vector search represents a fundamental change in how we should think about AI infrastructure costs. You wouldn't run a web server 24/7 to handle a few requests per hour anymore; Lambda and similar services solved that problem. S3 Vectors brings the same economic model to vector storage, and for the majority of RAG applications and AI agents, that's exactly what makes sense.

Ready to stop reading and start shipping?

Get a free AI-powered SEO audit of your site

We'll crawl your site, benchmark your local pack, and hand you a prioritized fix list in minutes. No call required.

Run my free audit