# Data Storage

Suno uses multiple datastores, each optimized for different use cases. This section explains what we use, why we chose it, and when to use each one.

## Storage Overview

| Datastore | Primary Use | Strengths | Weaknesses |
|-----------|-------------|-----------|------------|
| **PostgreSQL** | Core relational data | ACID, JOINs, consistency | Vertical scaling limits, slow migrations |
| **Redis / Valkey** | Caching, queues | Speed, TTL, pub/sub | Memory-limited, data loss risk |
| **DynamoDB** | Flexible metadata | Schema flexibility, high throughput | No JOINs, eventual consistency |
| **Elasticsearch** | Search | Full-text, filters, vectors | Resource-intensive, can drift |
| **S3** | Files | Object storage, CDN | Not queryable, eventual consistency |

## Storage Decision Guide

Use this flowchart to decide which datastore to use:

```
Need to store data?
├─ Is it a file (audio, image, video)?
│  └─ YES → Use S3
├─ Need full-text search?
│  └─ YES → Use Elasticsearch (+ PostgreSQL as source)
├─ Is it temporary (< 1 hour)?
│  └─ YES → Use Redis
├─ Does the schema change frequently?
│  └─ YES → Use DynamoDB
├─ Need relationships or ACID?
│  └─ YES → Use PostgreSQL
```

## Detailed Guides

Learn about each datastore:

1. **[PostgreSQL](/backend/data-storage/postgresql)** - Primary relational database
2. **[Redis / Valkey](/backend/data-storage/redis)** - Caching and queues
3. **[DynamoDB](/backend/data-storage/dynamodb)** - Flexible metadata storage
4. **[Elasticsearch](/backend/data-storage/elasticsearch)** - Search engine

## Quick Comparison

### When to Use Each

**PostgreSQL** ✅
- User accounts and profiles
- Core application entities (clips, playlists)
- Data requiring relationships
- Data needing ACID guarantees

**Redis** ✅
- Caching expensive queries
- Rate limiting and throttling
- Temporary data (sessions, recent history)
- Job queues

**DynamoDB** ✅
- Larger metadata schemas
- Data with evolving schemas
- High-throughput read/write patterns
- Data without complex relationships

**Elasticsearch** ✅
- Full-text search (lyrics, titles)
- Autocomplete and suggestions
- Filtered search
- Vector similarity search

**S3** ✅
- Audio files (MP3, WAV)
- Images and videos
- Model checkpoints
- Static assets

