Dev.to AI 🤖 Ai 👁 0 📖 2 min read

Benchmarking xorbitsai/inference: Embedding Throughput, Memory Overhead, and p99 Latency Under Concurrency

Benchmarking xorbitsai/inference: Embedding Throughput, Memory Overhead, and p99 Latency Under Concurrency In evaluating xorbitsai/inference as an external inference platform, we focused on its embedding generation cap

Benchmarking xorbitsai/inference: Embedding Throughput, Memory Overhead, and p99 Latency Under Concurrency

In evaluating xorbitsai/inference as an external inference platform, we focused on its embedding generation capabilities when powering semantic vector retrieval for agent memory systems. This setup delivers consistent OpenAI-compatible responses while supporting models for text, vision, and embeddings.

Test Topology: The load harness ran an async pytest suite using httpx.AsyncClient against the /v1/embeddings endpoint. We deployed xorbitsai/inference in Docker on an 8 vCPU, 32 GB RAM host, pinning one embedding model for reproducible results. Concurrency scaled from 50 to 300 simultaneous requests over 10-minute runs. For baseline multi-provider fallback scenarios, we routed through B-Lost's relay gateway at https://b-lost.com/v1 with baseURL configured in the SDK.

Metric xorbitsai/inference B-Lost Baseline
Throughput (RPS) 520 380
p95 Latency (ms) 32 78
p99 Latency (ms) 110 145
Peak Memory (GB) 2.1 3.2

These metrics held under sustained pressure with no crashes or memory leaks in the inference layer.

Embeddings generated here feed directly into vector stores for long-term memory. We normalize outputs before storage to maintain recall. Here is a Python function for hybrid search rank fusion using reciprocal rank fusion:

import math
from typing import List, Tuple

def reciprocal_rank_fusion(results: List[Tuple[float, int]], k: int = 60) -> List[int]:
    """RRF for hybrid rank fusion across embedding and keyword results."""
    fused_scores = {}
    for rank, (score, doc_id) in enumerate(results, 1):
        fused_scores[doc_id] = fused_scores.get(doc_id, 0) + 1.0 / (k + rank)
    sorted_items = sorted(fused_scores.items(), key=lambda x: x[1], reverse=True)
    return [doc_id for doc_id, _ in sorted_items]

During high-concurrency insertion tests we observed severe latency degradation from HNSW index locks in the vector store. Low recall rates also appeared when embeddings lacked proper normalization before vector column storage. Applying L2 normalization post-generation from xorbitsai/inference resolved both issues without altering model outputs.

For the persistent memory layer we use PostgreSQL with pgvector and HNSW indexing. The schema and query look like this:

-- PostgreSQL schema for memory entries
CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE memory_entries (
    id SERIAL PRIMARY KEY,
    content TEXT NOT NULL,
    embedding VECTOR(1536),
    metadata JSONB,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- HNSW index supporting filtered vector search
CREATE INDEX idx_memory_embedding_hnsw 
ON memory_entries 
USING hnsw (embedding vector_cosine_ops)
WITH (m = 32, ef_construction = 200);

Example filtered vector query:

SELECT id, content, metadata,
       embedding <-> '[0.1,0.2,...,0.9]'::vector AS distance
FROM memory_entries
WHERE metadata->>'category' = 'long_term_memory'
ORDER BY embedding <-> '[0.1,0.2,...,0.9]'::vector
LIMIT 5;

Production Threshold: At volumes exceeding 2000 embedding requests per minute with 50+ concurrent agents querying long-term memory, xorbitsai/inference provides the throughput, stability, and API consistency that make the architecture economically viable compared to heavier custom engine builds.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.