QuickDID#
QuickDID is a high-performance AT Protocol identity resolution service written in Rust. It provides blazing-fast handle-to-DID resolution with intelligent caching strategies, supporting in-memory, Redis-backed, and SQLite-backed persistent caching with binary serialization for optimal storage efficiency.
Built following the 12-factor app methodology with minimal dependencies and optimized for production use, QuickDID delivers exceptional performance while maintaining a lean footprint. Configuration is handled exclusively through environment variables, with only --version and --help command-line arguments supported.
⚠️ Production Disclaimer#
This project is a release candidate and has not been fully vetted for production use. While it includes comprehensive error handling and has been designed with production features in mind, more thorough testing is necessary before deploying in critical environments. Use at your own risk and conduct appropriate testing for your use case.
Performance#
QuickDID is designed for high throughput and low latency:
- Binary serialization reduces cache storage by ~40% compared to JSON
- Rate limiting protects upstream services from being overwhelmed
- Work shedding in SQLite queue adapter prevents unbounded growth
- Configurable TTLs allow fine-tuning cache freshness vs. performance
- Connection pooling for Redis minimizes connection overhead
Features#
- Fast Handle Resolution: Resolves AT Protocol handles to DIDs using DNS TXT records and HTTP well-known endpoints
- Multi-Layer Caching: Flexible caching with three tiers:
- In-memory caching with configurable TTL (default: 600 seconds)
- Redis-backed persistent caching (default: 90-day TTL)
- SQLite-backed persistent caching (default: 90-day TTL)
- Rate Limiting: Semaphore-based concurrency control with optional timeout to protect upstream services
- Binary Serialization: Compact storage format reduces cache size by ~40% compared to JSON
- Queue Processing: Asynchronous handle resolution with multiple adapters:
- MPSC (in-memory, default)
- Redis (distributed)
- SQLite (persistent with work shedding)
- No-op (testing)
- AT Protocol Compatible: Implements XRPC endpoints for seamless integration with AT Protocol infrastructure
- Comprehensive Error Handling: Structured errors with unique identifiers (e.g.,
error-quickdid-config-1), health checks, and graceful shutdown - 12-Factor App: Environment-based configuration following cloud-native best practices
- Minimal Dependencies: Optimized dependency tree for faster compilation and reduced attack surface
Building#
Prerequisites#
- Rust 1.70 or later
- Redis (optional, for persistent caching and distributed queuing)
- SQLite 3.35+ (optional, for single-instance persistent caching)
Build Commands#
# Clone the repository
git clone https://github.com/yourusername/quickdid.git
cd quickdid
# Build the project
cargo build --release
# Run tests
cargo test
# Run with debug logging
RUST_LOG=debug cargo run
Minimum Configuration#
QuickDID requires the following environment variables to run. Configuration is validated at startup, and the service will exit with specific error codes if validation fails.
Required#
HTTP_EXTERNAL: External hostname for service endpoints (e.g.,localhost:3007)SERVICE_KEY: Private key for service identity in DID format (e.g.,did:key:z42tmZxD2mi1TfMKSFrsRfednwdaaPNZiiWHP4MPgcvXkDWK)
Example Minimal Setup#
HTTP_EXTERNAL=localhost:3007 \
SERVICE_KEY=did:key:z42tmZxD2mi1TfMKSFrsRfednwdaaPNZiiWHP4MPgcvXkDWK \
cargo run
This will start QuickDID with:
- HTTP server on port 8080 (default)
- In-memory caching only (600-second TTL default)
- MPSC queue adapter for async processing
- Default worker ID: "worker1"
- Connection to plc.directory for DID resolution
- Rate limiting disabled (default)
Optional Configuration#
For production deployments, consider these additional environment variables:
Network & Service#
HTTP_PORT: Server port (default: 8080)PLC_HOSTNAME: PLC directory hostname (default: plc.directory)USER_AGENT: HTTP User-Agent for outgoing requestsDNS_NAMESERVERS: Custom DNS servers (comma-separated)
Caching#
REDIS_URL: Redis connection URL (e.g.,redis://localhost:6379)SQLITE_URL: SQLite database URL (e.g.,sqlite:./quickdid.db)CACHE_TTL_MEMORY: In-memory cache TTL in seconds (default: 600)CACHE_TTL_REDIS: Redis cache TTL in seconds (default: 7776000 = 90 days)CACHE_TTL_SQLITE: SQLite cache TTL in seconds (default: 7776000 = 90 days)
Queue Processing#
QUEUE_ADAPTER: Queue type - 'mpsc', 'redis', 'sqlite', 'noop', or 'none' (default: mpsc)QUEUE_WORKER_ID: Worker identifier (default: worker1)QUEUE_BUFFER_SIZE: MPSC queue buffer size (default: 1000)QUEUE_REDIS_PREFIX: Redis key prefix for queues (default: queue:handleresolver:)QUEUE_REDIS_TIMEOUT: Redis blocking timeout in seconds (default: 5)QUEUE_SQLITE_MAX_SIZE: Max SQLite queue size for work shedding (default: 10000)
Rate Limiting#
RESOLVER_MAX_CONCURRENT: Maximum concurrent handle resolutions (default: 0 = disabled)RESOLVER_MAX_CONCURRENT_TIMEOUT_MS: Timeout for acquiring rate limit permit in ms (default: 0 = no timeout)
Logging#
RUST_LOG: Logging level (e.g., debug, info, warn, error)
Production Examples#
Redis-based (Multi-instance/HA)#
HTTP_EXTERNAL=quickdid.example.com \
SERVICE_KEY=did:key:yourkeyhere \
HTTP_PORT=3000 \
REDIS_URL=redis://localhost:6379 \
CACHE_TTL_REDIS=86400 \
QUEUE_ADAPTER=redis \
QUEUE_WORKER_ID=prod-worker-1 \
RESOLVER_MAX_CONCURRENT=100 \
RESOLVER_MAX_CONCURRENT_TIMEOUT_MS=5000 \
RUST_LOG=info \
./target/release/quickdid
SQLite-based (Single-instance)#
HTTP_EXTERNAL=quickdid.example.com \
SERVICE_KEY=did:key:yourkeyhere \
HTTP_PORT=3000 \
SQLITE_URL=sqlite:./quickdid.db \
CACHE_TTL_SQLITE=86400 \
QUEUE_ADAPTER=sqlite \
QUEUE_SQLITE_MAX_SIZE=10000 \
RESOLVER_MAX_CONCURRENT=50 \
RUST_LOG=info \
./target/release/quickdid
Architecture#
QuickDID uses a layered architecture for optimal performance:
Request → Cache Layer → Rate Limiter → Base Resolver → DNS/HTTP
↓ ↓ ↓
Memory/Redis/ Semaphore AT Protocol
SQLite (optional) Infrastructure
Cache Priority#
QuickDID checks caches in this order:
- Redis (if configured) - Best for distributed deployments
- SQLite (if configured) - Best for single-instance with persistence
- In-memory (fallback) - Always available
Deployment Strategies#
- Single-instance: Use SQLite for both caching and queuing
- Multi-instance/HA: Use Redis for distributed caching and queuing
- Development: Use in-memory caching with MPSC queuing
API Endpoints#
GET /_health- Health check endpointGET /xrpc/com.atproto.identity.resolveHandle- Resolve handle to DIDGET /.well-known/atproto-did- Serve DID document for the service
Docker Deployment#
QuickDID can be deployed using Docker. See the production deployment guide for detailed Docker and Docker Compose configurations.
Quick Docker Setup#
# Build the image
docker build -t quickdid:latest .
# Run with environment file
docker run -d \
--name quickdid \
--env-file .env \
-p 8080:8080 \
quickdid:latest
Documentation#
- Configuration Reference - Complete list of all configuration options
- Production Deployment Guide - Docker, monitoring, and production best practices
- Development Guide - Architecture details and development patterns
License#
This project is open source and available under the MIT License.
Copyright (c) 2025 Nick Gerakines
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.