Hybrid routing and coordination for llama.cpp RPC + Ollama deployments
Description
I'm building SOLLOL, a control/observability/orchestration layer over llama.cpp RPC backends and Ollama nodes. This system handles both embedding performance at scale and model sharding across RPC backends, and I've hit some bottlenecks and questions about llama.cpp internals that would help optimize the infrastructure layer.
Context
Project: Production-grade hybrid routing system coordinating llama.cpp RPC + Ollama backends Use case: High-throughput embedding pipelines + model sharding for large models Current setup: 2-3 mixed CPU/GPU nodes with llama.cpp RPC backends + Ollama instances
Problem 1: Embedding Performance Bottlenecks
In my distributed setup, SOLLOL achieves ~19–21 embeddings/sec across 3 nodes (1 GPU, 2 CPU), but individual llama.cpp embedding calls show significant latency variation.
Sample performance data:
- Single embedding call: 163ms–2.3sec (high variance)
- Batch processing (32-128 chunks): 12× throughput improvement
- Connection reuse: 10× speedup
- HTTP/2 multiplexing: Additional 30% improvement
Key questions on embedding internals:
-
Memory buffer reuse: Does llama.cpp embed reuse memory buffers internally on repeated calls, or does it re-allocate each time? This affects our connection pooling strategy.
-
Internal batching: Are there internal vectorization or batching hints (e.g. SIMD flags, prefetch) that client applications can enable to improve throughput?
-
Threading model: Is multi-threading / OpenMP used in embedding inference by default? Can it be tuned for concurrent requests?
-
Concurrent call limits: Are there internal locks that prevent parallelism when multiple clients send concurrent embedding requests to the same RPC backend?
-
Memory layout: Does tensor layout or context memory reuse affect embedding performance when processing sequential batches?
Problem 2: Model Sharding Coordination
SOLLOL is the first orchestration layer to support model sharding across llama.cpp RPC backends, but I need guidance on optimal patterns.
Current implementation:
# Hybrid router with model sharding
router = HybridRouter()
# Splits large models across RPC backends on port 50052
# Routes embeddings to Ollama (port 11434)
# Layer-wise sharding across 3 RPC backends
# Result: 2.6× speedup (2.1s → 0.8s latency)
Key questions on model sharding:
-
Sharding protocol: Is there a recommended way to split models across RPC backends? We're using layer-wise sharding - is this optimal, or should we consider attention head splitting or other strategies?
-
Backend coordination: Are there plans for native coordination between multiple llama.cpp RPC backends? Currently we handle this at the orchestration layer with custom routing.
-
Memory synchronization: When sharding models, how should we handle KV cache and context memory across backends? Should each backend maintain separate state?
-
Health monitoring: What's the best way to monitor RPC backend health and available VRAM during sharded operations? We're using gRPC health checks + nvidia-smi polling.
-
Load balancing: For sharded models, should we distribute layers evenly, or weight by GPU capability? How do we detect if a backend becomes a bottleneck?
Current Architecture
Client App → SOLLOL Hybrid Router → llama.cpp RPC Backends (model sharding, large models)
→ Ollama Nodes (embeddings, standard generation)
What works:
- Batch embedding calls: 12× throughput improvement
- Connection pooling + HTTP/2: 10× speedup
- Layer-wise sharding: 2.6× latency reduction
What needs optimization:
- High latency variance on embedding calls
- Manual coordination required for RPC backend sharding
- Uncertainty about optimal sharding strategies
Sample Code
# High-throughput embedding with connection reuse
import httpx
session = httpx.Client(
transport=httpx.HTTPTransport(retries=3, http2=True),
limits=httpx.Limits(
max_keepalive_connections=40,
max_connections=100,
keepalive_expiry=30.0
)
)
# Batch embedding via RPC backend
response = session.post(
f"http://{rpc_backend}:50052/embed",
json={"texts": batch_texts} # 32-128 chunks
)
# Model sharding coordinator
# Routes request layers to appropriate RPC backend
for layer_batch in shard_layers(model, num_backends=3):
backend = select_backend(layer_batch, vram_availability)
result = backend.inference(layer_batch, context)
Why This Matters
Many teams are running hybrid infrastructure with both llama.cpp RPC backends (for large models/sharding) and Ollama instances (for embeddings/standard models). SOLLOL aims to make this production-grade and automatic, but optimization depends on understanding llama.cpp internals.
Any insights on:
- Embedding performance optimization
- Recommended model sharding patterns
- RPC backend coordination
- Memory/threading model for high-concurrency scenarios
Happy to share logs, benchmark scripts, or test harnesses if useful. Anything you share I'll integrate into SOLLOL as routing optimizations for the community.
Links
- SOLLOL: https://github.com/BenevolentJoker-JohnL/SOLLOL
- FlockParser (document processing): https://github.com/BenevolentJoker-JohnL/FlockParser
- SynapticLlamas (multi-agent): https://github.com/BenevolentJoker-JohnL/SynapticLlamas
Dashboard Screenshots
1. Hybrid Backend Monitoring

- RPC Backends section showing llama.cpp endpoints (undefined in this view - development in progress)
- Ollama nodes actively serving requests (10.9.66.48, 10.9.66.154)
- Unified health monitoring across both backend types
2. Multi-Application Coordination

- FlockParser: Document processing using hybrid routing
- SynapticLlamas: Multi-agent reasoning across RPC + Ollama backends
- Both leveraging SOLLOL's unified orchestration layer
3. llama.cpp Activity Logs

- llama.cpp activity stream connected (left panel)
- SOLLOL routing decisions showing backend selection logic
- Real-time request routing: Ollama for embeddings, RPC for sharded models
- Latency tracking per backend type
4. Distributed Processing Coordination

- Dask distributed scheduler coordinating tasks across infrastructure
- Enables parallel processing across both Ollama and RPC backends
- Task distribution for optimal resource utilization
Key architectural benefits:
- Heterogeneous backend support - First system to treat llama.cpp RPC and Ollama as unified infrastructure
- Model sharding - Distribute large models across RPC backends automatically
- Intelligent routing - Embeddings → Ollama (optimized), Large models → RPC (sharding)
- Unified observability - Single dashboard for all backend types
The goal is making hybrid deployments as simple as single-backend setups.
This issue was closed because it has been inactive for 14 days since being marked as stale.