-
Notifications
You must be signed in to change notification settings - Fork 1
INGESTION_ARCHITECTURE
GitHub Actions edited this page Jan 2, 2026
·
1 revision
┌─────────────────────────────────────────────────────────────────────┐
│ CLIENT APPLICATIONS │
│ (Python, JavaScript, Ruby, PHP, Rust, Go, Java, .NET SDKs) │
└────────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ CLIENT-SIDE OPTIMIZATIONS │
│ │
│ 💡 Optimization Ideas: │
│ ✅ Connection Pooling (100 connections) │
│ ✅ Auto-Batching (1000 ops → 1 request) │
│ ✅ Payload Compression (Zstd: -70%) │
│ ✅ HTTP/2 Multiplexing (10-100× concurrent) │
│ ⚡ Impact: +500-1000% throughput │
└────────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ NETWORK LAYER │
│ │
│ Protocol Options: │
│ 1. HTTP/1.1 + JSON (Baseline: 100%) │
│ 2. HTTP/2 + JSON (+50% throughput) │
│ 3. HTTP/2 + MessagePack (+140% throughput) │
│ 4. Binary/MessagePack (+200% throughput) │
│ 5. gRPC/Protobuf (+250% throughput) │
│ │
│ 💡 Optimization Ideas: │
│ ✅ Enable HTTP/2 │
│ ✅ Content-Encoding: zstd │
│ ✅ Zero-Copy Transfers │
│ ⚡ Impact: +100-300% throughput, -40-60% latency │
└────────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ SERVER-SIDE BUFFERS (Layer 1) │
│ │
│ Auto-Buffer Components: │
│ ┌──────────────────┬──────────────────┬─────────────────────┐ │
│ │ TSAutoBuffer │ VectorAutoBuffer │ GraphAutoBuffer │ │
│ │ (Time Series) │ (Embeddings) │ (Nodes/Edges) │ │
│ ├──────────────────┼──────────────────┼─────────────────────┤ │
│ │ ✅ Implemented │ ✅ Implemented │ ✅ Implemented │ │
│ │ 10-50× throughput│ 10-50× throughput│ 2-5× throughput │ │
│ │ Gorilla compress │ PQ compress (?) │ Zstd compress │ │
│ └──────────────────┴──────────────────┴─────────────────────┘ │
│ │
│ 💡 Optimization Ideas: │
│ ✅ Adaptive Batch Sizing (10-10000 items) │
│ ✅ Priority Queues (Critical/High/Normal/Low) │
│ ✅ Multi-Threshold Flush (Size/Time/Memory) │
│ ⚡ Impact: +15-25% throughput, -20-30% P99 latency │
└────────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ ROCKSDB WRITE PATH (Layer 2) │
│ │
│ Write Flow: │
│ ┌─────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Write │───▶│ Memtable │───▶│ WAL │───▶│ Commit │ │
│ │ Batch │ │ (Active) │ │ (Sync) │ │ │ │
│ └─────────┘ └──────────┘ └──────────┘ └──────────┘ │
│ │ │
│ ▼ │
│ ┌──────────┐ │
│ │ Memtable │ (Immutable) │
│ │ (Frozen) │ │
│ └──────────┘ │
│ │ │
│ ▼ │
│ Flush to L0 SST Files │
│ │
│ 💡 Optimization Ideas: │
│ ✅ Adaptive Write Buffer Sizing │
│ • 16GB RAM: 256MB memtable │
│ • 64GB RAM: 1GB memtable (+4×) │
│ • 128GB RAM: 2GB memtable (+8×) │
│ ✅ Parallel Memtable Writes │
│ • allow_concurrent_memtable_write: true │
│ • enable_pipelined_write: true │
│ • write_policy: WritePrepared │
│ ✅ Group Commit (Async WAL) │
│ • sync: false (⚠️ data loss risk) │
│ • wal_bytes_per_sync: 64MB │
│ ⚡ Impact: +40-60% write throughput │
└────────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ COMPACTION & STORAGE (Layer 3) │
│ │
│ LSM-Tree Levels: │
│ Level 0 (L0): [SST][SST][SST][SST] ← Memtable Flushes │
│ Level 1 (L1): [SST][SST][SST][SST][SST][SST] │
│ Level 2 (L2): [SST] ... (10× L1) │
│ Level 3 (L3): [SST] ... (10× L2) │
│ Level 4 (L4): [SST] ... (10× L3) │
│ Level 5 (L5): [SST] ... (10× L4) │
│ Level 6 (L6): [SST] ... (Bottommost) │
│ │
│ Compaction Flow: │
│ L0 → L1 → L2 → L3 → L4 → L5 → L6 │
│ ↓ ↓ ↓ ↓ ↓ ↓ ↓ │
│ Merge + Sort + Compress │
│ │
│ 💡 Optimization Ideas: │
│ ✅ Aggressive Level0 Compaction │
│ • level0_file_num_compaction_trigger: 2 (default: 4) │
│ • level0_slowdown_writes_trigger: 8 (default: 20) │
│ • level0_stop_writes_trigger: 16 (default: 36) │
│ • max_background_compactions: 8 (default: 4) │
│ • max_subcompactions: 2 (parallel) │
│ ✅ Parallel Compression │
│ • compression_opts.parallel_threads: 8 │
│ • compression: zstd (level 3) │
│ ✅ Tiered Storage │
│ • Hot data (L0-L2): NVMe SSD │
│ • Warm data (L3-L4): SATA SSD │
│ • Cold data (L5-L6): HDD │
│ ⚡ Impact: -50-70% P99 latency, +20-40% sustained throughput │
└────────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ DISK I/O (Layer 4) │
│ │
│ Storage Layout: │
│ /nvme/rocksdb/wal/ ← WAL files (low latency) │
│ /nvme/rocksdb/hot/ ← L0-L2 SST files │
│ /ssd/rocksdb/warm/ ← L3-L4 SST files │
│ /data/rocksdb/cold/ ← L5-L6 SST files │
│ │
│ 💡 Optimization Ideas: │
│ ✅ Separate WAL Directory (NVMe) │
│ • wal_dir: /nvme/rocksdb/wal │
│ • -30-50% write latency │
│ ✅ Direct I/O (bypass OS cache) │
│ • use_direct_io_for_flush_and_compaction: true │
│ • +30-50% bulk import speed │
│ ✅ Async I/O with Prefetching │
│ • enable_async_io: true │
│ • async_io_readahead_size_mb: 64 │
│ • +20-40% read performance │
│ ✅ Memory-Mapped File Import │
│ • Zero-copy, lazy loading │
│ • +100-300% for large files │
│ ⚡ Impact: -30-50% write latency, +50-100% bulk import │
└─────────────────────────────────────────────────────────────────────┘
| Layer | Optimization | Impact | Effort |
|---|---|---|---|
| Network | HTTP/2 | +50-100% throughput | 1 day |
| Client | Connection Pooling | +50-100% throughput | 2 days |
| Client | Payload Compression | -70% traffic | 3 days |
| RocksDB | Adaptive Write Buffer | +40-60% throughput | 2 days |
| RocksDB | Level0 Compaction Tuning | -50-70% P99 latency | 2 days |
| Total | Combined | +150-250% throughput | 10 days |
| Layer | Optimization | Impact | Effort |
|---|---|---|---|
| Server | Product Quantization | -90-97% storage | 2 weeks |
| Disk I/O | Memory-Mapped Import | +100-300% bulk | 1 week |
| Disk I/O | Direct I/O | +30-50% bulk | 1 week |
| RocksDB | Per-Thread Memtables | +150-250% (@64 threads) | 1 month |
| Total | Combined | +200-500% specific | 2 months |
High Impact │
│ ┌─HTTP/2──────┐ ┌─Adaptive WB─┐ ┌─Level0 Tune┐
│ │ │ │ │ │ │
│ │ ⭐⭐⭐⭐⭐ │ │ ⭐⭐⭐⭐⭐ │ │ ⭐⭐⭐⭐⭐ │
│ └─1 day──────┘ └─2 days─────┘ └─2 days─────┘
│
│ ┌─Compression─┐ ┌─Connection──┐
│ │ │ │ Pooling │
│ │ ⭐⭐⭐⭐ │ │ ⭐⭐⭐⭐⭐ │
│ └─3 days─────┘ └─2 days─────┘
│
Medium │ ┌─Product PQ──┐ ┌─MMap Import┐
Impact │ │ │ │ │
│ │ ⭐⭐⭐⭐ │ │ ⭐⭐⭐⭐ │
│ └─2 weeks────┘ └─1 week─────┘
│
│ ┌─Adaptive────┐ ┌─Direct I/O──┐
│ │ Batching │ │ │
│ │ ⭐⭐⭐ │ │ ⭐⭐⭐ │
Low Impact │ └─1 month────┘ └─1 week─────┘
│
└────────────────────────────────────────────────────▶
Low Effort Medium High Effort
Priority Ranking:
- ⭐⭐⭐⭐⭐ HTTP/2, Adaptive Write Buffer, Level0 Tuning
- ⭐⭐⭐⭐ Compression, Connection Pooling, Product Quantization
- ⭐⭐⭐ Adaptive Batching, Direct I/O
Client (Python SDK)
│
├─ POST /ts/put (single point, HTTP/1.1, JSON)
│ Latency: 50ms, Size: 229 bytes
│ ↓
└─ HTTP Handler
↓
RocksDB Put (single write, sync WAL)
Latency: 45ms
Total: 50ms per point
Throughput: 20 points/sec per thread
Client (Python SDK)
│
├─ Auto-Batching (1000 points → 1 request)
│ ↓
├─ Zstd Compression (229 bytes → 87 bytes, -62%)
│ ↓
├─ HTTP/2 Multiplexing (10 concurrent requests)
│ ↓
└─ POST /ts/put/buffered (Binary Protocol)
Size: 87 KB (1000 points)
Latency: 15ms
↓
Server-Side TSAutoBuffer
├─ Accumulate: 10,000 points
├─ Gorilla Compress: 10-20× reduction
├─ Flush interval: 5 seconds
↓
RocksDB WriteBatch (1 transaction, 10k points)
├─ Memtable: 1GB (large buffer)
├─ WAL: Async (group commit)
└─ Latency: 5ms per batch
Total: 0.5ms per point (100× faster)
Throughput: 2000 points/sec per thread
Improvements:
- Latency: 50ms → 0.5ms (100× faster)
- Throughput: 20 pts/s → 2000 pts/s (100× higher)
- Network: 229 bytes → 0.087 bytes per point (2600× less)
- Enable HTTP/2 in server configuration
- Implement client-side connection pooling
- Add payload compression (Zstd) to HTTP handler
- Configure adaptive write buffer sizing
- Tune Level0 compaction parameters
- Deploy to staging environment
- Run benchmarks and validate metrics
- Monitor production metrics
- Fine-tune configuration based on real workload
- Update client SDKs with connection pooling
- Document best practices
- Train team on new configurations
- Implement Product Quantization for embeddings
- Add memory-mapped file import
- Enable Direct I/O for bulk imports
- Test and benchmark medium-term optimizations
- Gradually roll out to production
For complete details, see:
- INGESTION_OPTIMIZATION_IDEAS.md - Full technical guide
- INGESTION_OPTIMIZATION_SUMMARY.md - Executive summary
- ingestion-optimized.yaml - Configuration template
Status: Architecture documented ✅
Next: Implementation Phase 1
- Architecture-ACCESS-MODEL-IMPLEMENTATION-SUMMARY
- Architecture-ADR-003-pg-dump-sql-parser
- Architecture-BASEENTITY-PRINCIPLE
- Architecture-CACHE-STORAGE-INTEGRATION
- Architecture-CMAKE-ARCHITECTURE
- Architecture-CMAKE-FLAGS-REFERENCE
- Architecture-CMAKE-MODULAR-ARCHITECTURE
- Architecture-CONCERNS-ARCHITECTURE-DIAGRAM
- Architecture-CONCERNS-IMPLEMENTATION-SUMMARY
- Architecture-CONTENT-MODEL
- Architecture-COPILOT-THEMISDB-GRAPH-RAG-BACKEND-ARCHITECTURE
- Architecture-CRYPTO-AND-KEYS
- Architecture-FEATURE-FLAGS-REFERENCE
- Architecture-GPU-ARCHITECTURE-REVIEW-TEMPLATE
- Architecture-HTTP-SHUTDOWN-HARDENING
- Architecture-MIGRATION-GUIDE-CONCERNS
- Architecture-MIGRATION-GUIDE-v13-v14
- Architecture-MODULARIZATION-GUIDE
- Architecture-MODULAR-ARCHITECTURE-ROADMAP
- Architecture-MODULE-ARCHITECTURE-INDEX
- Architecture-P1D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D08-MAMBA-GOVERNANCE-CONTRACT
- Architecture-P1-P2-IMPLEMENTATION-COMPLETION-INDEX
- Architecture-PHASE0-COMPLETION-ASSESSMENT
- Architecture-PHASE3-QUERYENGINE-DI-ARCHITECTURE
- Architecture-PHASE4-INDEX-MANAGER-DI
- Architecture-POSTGRESQL-WIRE-PROTOCOL
- Architecture-QUERYENGINE-IMPLEMENTATION-GUIDE
- Architecture-QUERY-SCHEDULING
- Architecture-RAFT-CONSENSUS-DESIGN
- Architecture-README
- Architecture-README-SSM-HYBRID-IMPLEMENTATION
- Architecture-REFACTORING-SUMMARY
- Architecture-RESOURCE-POOLING
- Architecture-SOURCE-DIRECTORY-GUIDE
- Architecture-THEMIS-CORE-GUIDE
- Architecture-UNIFIED-ACCESS-MODEL
- Architecture-WAL-GRPC-MTLS-CONFIGURATION
- Architecture-WIRE-PROTOCOL-RETRY
- Architecture-boltzmann-observability-draft
- Architecture-experimental-logarithmic-vector-storage
- Architecture-llm-wiki-mvp-adr
- Architecture-rewrite-engine-architecture
- Architecture-rope-api-architecture
- Architecture-ssm-gguf-mamba-status
- Architecture-ssm-hybrid-analysis
- Architecture-ssm-hybrid-rollout-plan
- Architecture-ssm-plugin-interface-design-review
- Architecture-transaction-coordinators
- Architecture-wiki-secondary-index
- Architecture-wire-protocol
- Governance-DISABLED-STUB-POLICY
- Governance-DOCS-PR-POLICY
- Governance-GA-PROMOTION-SIGN-OFF
- Governance-GITHUB-MILESTONES-SETUP
- Governance-MATURITY-CLAIM-VERIFICATION-CHECKLIST
- Governance-MATURITY-EVIDENCE-REGISTRY
- Governance-MERGE-GATE-BOT-CONFIG
- Governance-MERGE-GATE-STATUS-LIVE
- Governance-PHASE3-ENFORCEMENT-RUNBOOK
- Governance-PHASE-1-CLOSURE-REPORT
- Governance-PHASE-CLOSURE-POLICY
- Governance-PHASE-DEPENDENCY-GRAPH
- Governance-PLUGIN-SUBMODULE-ROLLBACK
- Governance-PRODUCTION-READY-2026-DELIVERY-PLAN
- Governance-PR-VERSION-TARGETING
- Governance-PR-VERSION-TARGETING-BACKFILL
- Governance-QUERY-MODULE-STATUS
- Governance-README
- Governance-RELEASE-PROMOTION-GATE-POLICY
- Governance-RELEASE-VALIDATION-CHECKLIST
- Governance-SECURITY-MODULE-5671-EVIDENCE-SUMMARY
- Governance-SHARDING-P6-RESIDUAL-RISK-ACCEPTANCE
- Governance-SOURCECODE-COMPLIANCE-GOVERNANCE
- Governance-UPDATES-DEVELOPMENT-STATUS-SIGN-OFF
- Governance-WAVE-C-IMPLEMENTATION-COMPLETE
- Module-acceleration-Roadmap
- Module-access-model-Roadmap
- Module-ai-Roadmap
- Module-analytics-Roadmap
- Module-api-Roadmap
- Module-aql-Roadmap
- Module-auth-Roadmap
- Module-base-Roadmap
- Module-cache-Roadmap
- Module-cdc-Roadmap
- Module-chaos-Roadmap
- Module-chimera-Roadmap
- Module-config-Roadmap
- Module-content-Roadmap
- Module-core-Roadmap
- Module-distributed-knowledge-Roadmap
- Module-distributed-tensor-Roadmap
- Module-document-Roadmap
- Module-ethics-ai-Roadmap
- Module-evaluation-Roadmap
- Module-execution-Roadmap
- Module-exporters-Roadmap
- Module-failover-Roadmap
- Module-geo-Roadmap
- Module-governance-Roadmap
- Module-gpu-Roadmap
- Module-graph-Roadmap
- Module-image-analysis-Roadmap
- Module-importers-Roadmap
- Module-index-Roadmap
- Module-ingestion-Roadmap
- Module-llama-cpp-Roadmap
- Module-llm-Roadmap
- Module-llm-streaming-Roadmap
- Module-llm-wiki-Roadmap
- Module-maintenance-Roadmap
- Module-metadata-Roadmap
- Module-network-Roadmap
- Module-observability-Roadmap
- Module-onnx-clip-Roadmap
- Module-performance-Roadmap
- Module-plugins-Roadmap
- Module-process-Roadmap
- Module-projects-Roadmap
- Module-prompt-engineering-Roadmap
- Module-query-Roadmap
- Module-rag-Roadmap
- Module-replication-Roadmap
- Module-retrieval-Roadmap
- Module-rpc-grpc-Roadmap
- Module-scheduler-Roadmap
- Module-scraper-Roadmap
- Module-search-Roadmap
- Module-security-Roadmap
- Module-server-Roadmap
- Module-sharding-Roadmap
- Module-stable-diffusion-Roadmap
- Module-storage-Roadmap
- Module-temporal-Roadmap
- Module-tensor-Roadmap
- Module-themis-Roadmap
- Module-timeseries-Roadmap
- Module-toolbox-Roadmap
- Module-training-Roadmap
- Module-transaction-Roadmap
- Module-updates-Roadmap
- Module-user-storage-encrypted-Roadmap
- Module-utils-Roadmap
- Module-vector-search-Roadmap
- Module-voice-Roadmap
- Module-whisper-Roadmap