Overview
Self-hosting Convex requires deploying three main services:- Convex backend - The core database and function runtime
- Convex dashboard - Web UI for managing deployments
- Your frontend app - Hosted on your platform of choice (Vercel, Netlify, etc.)
The Convex backend handles all database operations and server-side compute. It does not host your frontend application.
Core components
Convex backend
The backend is the heart of Convex, written in Rust for performance and reliability. It provides:- Database layer - Stores and queries your data with strong consistency
- Function runtime - Executes your TypeScript queries, mutations, and actions
- Sync engine - Powers real-time reactivity and live updates
- HTTP server - Serves API endpoints and handles client connections
Key services
Database API
Main API endpoint listening on port 3210 (default)
HTTP actions
HTTP endpoints for your actions on port 3211 (default)
Function runtime
Isolated JavaScript environment for executing your TypeScript functions
Storage layer
Pluggable storage supporting SQLite, Postgres, MySQL, and S3
Dashboard
The self-hosted dashboard provides a web interface for:- Viewing and editing data in your tables
- Monitoring function executions and logs
- Running ad-hoc queries and mutations
- Managing deployments and configurations
- Exploring your database schema
Client libraries
Convex provides client libraries for various platforms:- React - Hooks for queries, mutations, and real-time updates
- Next.js - Server and client components support
- Vue, Svelte - Framework-specific integrations
- Node.js - Server-side client for backend-to-backend communication
Repository structure
The Convex backend repository is organized as follows:Rust crates (crates/)
The backend is primarily written in Rust, with code organized in crates:
local_backend/- Application server and serving edgedatabase/- Core database implementationsync/- Real-time synchronization enginevector/- Vector search capabilitiestext_search/- Full-text search implementationfunction_runner/- JavaScript function execution runtimestorage/- Storage abstraction layer
TypeScript packages (npm-packages/)
TypeScript code for client libraries, CLI, and internal tooling:
convex/- Main client library published to npmudf-runtime/- JavaScript environment for user-defined functionssystem-udfs/- System functions used by the CLI and dashboarddashboard/- Cloud-hosted dashboarddashboard-self-hosted/- Self-hosted dashboard builddashboard-common/- Shared dashboard code
Data flow
Client initiates request
Your frontend application uses the Convex client library to call a query, mutation, or action.
Backend receives request
The backend’s HTTP server receives the request and routes it to the appropriate handler based on the function type.
Function executes
The function runtime creates an isolated JavaScript environment and executes your TypeScript function with a context object that provides database access.
Database operation
The backend performs the requested database operation (read, write, or both) with strong consistency guarantees.
Result returned
The function result is serialized and sent back to the client. For queries, the client automatically subscribes to changes.
Function types
Convex provides three types of functions, each with different characteristics:Queries
- Read-only - Cannot modify the database
- Cacheable - Results can be cached and reused
- Reactive - Client automatically subscribes to updates
- Transactional - Reads are strongly consistent
Mutations
- Read-write - Can read and modify the database
- Transactional - ACID guarantees for all operations
- Consistent - All reads within a mutation see a consistent snapshot
- Triggers reactivity - Changes trigger query updates
Actions
- Side effects - Can call external APIs and services
- Long-running - Configurable timeout for extended operations
- Non-deterministic - Can use randomness, current time, etc.
- Can call queries and mutations - Orchestrate multiple database operations
Storage architecture
Convex provides flexible storage options to suit different deployment scenarios:SQLite (default)
- Best for: Development, small deployments, single-server setups
- Location: Local file in Docker volume or filesystem
- Performance: Excellent for single-server workloads
- Scaling: Vertical scaling only
Postgres
- Best for: Production deployments requiring high availability
- Providers: Neon, RDS, self-hosted
- Performance: Excellent with proper co-location
- Scaling: Managed service handles replication and backups
MySQL/Vitess
- Best for: Teams already using MySQL infrastructure
- Providers: PlanetScale, RDS MySQL, self-hosted
- Performance: Comparable to Postgres
- Scaling: Vitess provides horizontal scaling capabilities
S3 storage (optional)
For larger deployments, you can offload certain data to S3:- Exports - Backup data exports
- Snapshots - Point-in-time snapshots
- Modules - Bundled function code
- Files - User-uploaded files
- Search indexes - Full-text and vector search indexes
Deployment considerations
Resource requirements
The Convex backend is designed to run efficiently with modest resources:- Minimum: 512MB RAM, 1 CPU core
- Recommended: 2GB+ RAM, 2+ CPU cores
- Storage: Depends on your data size plus indexes
Scaling strategies
Vertical scaling
Increase CPU and memory for the backend container
Database scaling
Use managed database services that handle replication and failover
Persistent storage
Configure cloud provider volumes for SQLite persistence
S3 offloading
Move large files and indexes to object storage
High availability
For production deployments requiring high availability:- Use managed Postgres or MySQL with automatic failover
- Deploy backend containers across multiple availability zones
- Configure load balancer health checks using
/versionendpoint - Set up monitoring and alerting for backend and database
- Regular backups using
npx convex export
Security considerations
Authentication
Convex supports multiple authentication patterns:- Convex Auth - Built-in authentication system (requires manual setup for self-hosted)
- Third-party providers - Clerk, WorkOS, Auth0, etc.
- Custom JWT - Bring your own auth provider
Network security
- Use HTTPS/TLS for all production deployments
- Set
DO_NOT_REQUIRE_SSL=1only for local development - Restrict dashboard access to trusted networks
- Rotate admin keys periodically
- Never commit
.env.localto version control
Telemetry beacon
Self-hosted builds include an optional beacon that sends minimal, anonymous usage data to help improve Convex. You can disable it with the
--disable-beacon flag. The beacon only includes:- Random deployment identifier
- Migration version
- Git revision
- Uptime
Next steps
Quickstart guide
Deploy your first self-hosted Convex instance
Advanced configurations
Explore hosting options, database choices, and tuning
Build from source
Compile the Rust backend yourself
Contributing
Learn how to contribute to Convex