Vercel Storage: Edge Config vs KV vs Blob Storage Decision Guide
Choose the right Vercel storage solution for your use case. Edge Config for config data, KV for session cache, Blob for file uploads—each has distinct performance characteristics.
Vercel offers three storage solutions: Edge Config, KV, and Blob. Pick wrong and you'll face latency issues, cost overruns, or both. Each targets different use cases with distinct performance trade-offs.
Edge Config: Global Configuration Store
Best for: Application config, feature flags, A/B test variants, routing rules.
import { get } from '@vercel/edge-config';
export default async function middleware(request: NextRequest) {
// Read config at edge (0-5ms globally)
const maintenanceMode = await get('maintenance');
if (maintenanceMode) {
return new Response('Maintenance', { status: 503 });
}
return NextResponse.next();
}Performance characteristics:
- Read latency: 0-5ms globally (edge cache)
- Write latency: 30-60 seconds (global propagation)
- Size limit: 500KB total
- Cost: $20/month flat rate
Edge Config gotchas: Updates aren't instant—expect 30-60 second propagation. Don't use for real-time config changes or user-specific data. The 500KB limit includes all keys combined.
KV: Redis for Edge Functions
Best for: Session storage, caching API responses, rate limiting, real-time counters.
import { kv } from '@vercel/kv';
export async function GET(request: Request) {
const sessionId = request.headers.get('x-session-id');
// Check session in KV (sub-10ms from edge)
const session = await kv.get('session:' + sessionId);
if (!session) {
return Response.json({ error: 'Invalid session' }, { status: 401 });
}
// Increment page views with atomic operation
const views = await kv.incr('views:' + sessionId);
return Response.json({ session, views });
}Performance characteristics:
- Read latency: 1-10ms (depends on edge location)
- Write latency: 1-10ms (immediate consistency)
- Size limit: 100MB per key, unlimited total
- Cost: $0.30 per 100K requests + $0.50/GB storage
KV gotchas: Operations are billed per request—batch with kv.pipeline() for multiple operations. TTL (expiration) is approximate, not precise. KV is eventually consistent across regions.
Blob: File Storage and CDN
Best for: User uploads, images, PDFs, video files, static assets.
import { put } from '@vercel/blob';
export async function POST(request: Request) {
const formData = await request.formData();
const file = formData.get('file') as File;
// Upload to Blob with automatic CDN distribution
const blob = await put(file.name, file, {
access: 'public',
addRandomSuffix: true,
});
return Response.json({
url: blob.url, // CDN URL for serving
downloadUrl: blob.downloadUrl, // Direct download
size: blob.size
});
}Performance characteristics:
- Upload latency: 100-500ms (depends on file size)
- CDN serve latency: 10-50ms globally
- Size limit: 500MB per file
- Cost: $0.15/GB storage + $0.40/GB transfer
Blob gotchas: Files are immutable once uploaded—you can't update, only delete and re-upload. The CDN cache can take 60+ seconds to update globally. Use addRandomSuffix to prevent naming conflicts.
Decision Matrix
Choose based on data characteristics:
// Configuration data (infrequent writes, global reads)
const config = await get('feature-flags'); // → Edge Config
// Session data (frequent reads/writes, user-specific)
const session = await kv.get('user:123'); // → KV
// Files (uploads, static content)
const fileUrl = await put('image.jpg', file); // → BlobAnti-patterns to avoid:
- Using Edge Config for user data (doesn't scale, slow writes)
- Using KV for large files (expensive, not optimized for file serving)
- Using Blob for configuration (no atomic reads, CDN cache lag)
Cost optimization tips: Edge Config becomes cost-effective with high-frequency config reads. KV costs scale with request volume—cache locally when possible. Blob transfer costs matter for large files—optimize with image compression and proper caching headers.
Advertisement
Explore these curated resources to deepen your understanding
Official Documentation
Tools & Utilities
Related Insights
Explore related edge cases and patterns
Advertisement