TinkerLab
ARTIFACT // BENCHMARK-CONCURRENT-LLM.SH (SHELL)

Multi-Worker Concurrency & P95 TTFT Benchmark Script (Ollama vs vLLM) (benchmark-concurrent-llm.sh)

Fires N parallel OpenAI-compatible requests and measures individual wall-clock latency, queue stall, and aggregate tokens/sec.

[KEY VERIFIED TAKEAWAY / TL;DR]This reproducible configuration artifact "Multi-Worker Concurrency & P95 TTFT Benchmark Script (Ollama vs vLLM)" (benchmark-concurrent-llm.sh, SHELL) is paired with Tinker AI Lab's hardware-verified guide "vllm-vs-ollama-concurrent-homelab". It exposes 3 customizable browser variables (BENCH_ENDPOINT=http://127.0.0.1:11434/v1/chat/completions, BENCH_MODEL=qwen2.5:7b, CONCURRENCY=4) with loopback-first security defaults.
01 // HOMELABLocal AI / HomeLab· Verified: 2026-10-23
Browse All 42 Artifacts →
benchmark-concurrent-llm.sh

Multi-Worker Concurrency & P95 TTFT Benchmark Script (Ollama vs vLLM)

Fires N parallel OpenAI-compatible requests and measures individual wall-clock latency, queue stall, and aggregate tokens/sec.

View Paired Guide →
Customizable Variables (Saved in Browser)
UTF-8 Encoded · Live Client-Side Compilation
#!/usr/bin/env bash
# Tinker AI — Concurrent Local LLM Throughput & Queue Latency Probe
set -euo pipefail

ENDPOINT="http://127.0.0.1:11434/v1/chat/completions"
MODEL="qwen2.5:7b"
WORKERS="4"

echo "=== Firing $WORKERS Parallel Requests against $MODEL ($ENDPOINT) ==="
START_TS=$(python3 -c 'import time; print(time.time())')

seq 1 "$WORKERS" | xargs -I{} -P "$WORKERS" bash -c '
  REQ_START=$(python3 -c "import time; print(time.time())")
  RESP=$(curl -sS "'"$ENDPOINT"'" -H "Content-Type: application/json" -d "{
    \"model\": \"'"$MODEL"'\",
    \"temperature\": 0,
    \"max_tokens\": 160,
    \"messages\": [{\"role\": \"user\", \"content\": \"Worker #{}: List 3 key differences between continuous batching and static request queues in 80 words.\"}]
  }")
  REQ_END=$(python3 -c "import time; print(time.time())")
  python3 -c "
import json, sys
d = json.loads(sys.argv[1])
toks = d.get("usage", {}).get("completion_tokens", 0)
dur = float(sys.argv[3]) - float(sys.argv[2])
print(f"[Worker #{}] Completed in {dur:.2f}s | {toks} tokens ({toks/max(0.01,dur):.1f} tok/s)")
" "$RESP" "$REQ_START" "$REQ_END"
'

END_TS=$(python3 -c 'import time; print(time.time())')
python3 -c "print(f'=== Total Wall-Clock Duration for $WORKERS parallel requests: {float($END_TS)-float($START_TS):.2f}s ===')"
PARAMETER SPECIFICATION // 参数化变量规范说明表

Customizable Parameter Reference for benchmark-concurrent-llm.sh

This SHELL artifact exposes 3 template variables compiled client-side in your browser.

Template TokenParameter DescriptionVerified DefaultExample Format
{{BENCH_ENDPOINT}}OpenAI-Compatible Endpointhttp://127.0.0.1:11434/v1/chat/completionshttp://127.0.0.1:11434/v1/chat/completions
{{BENCH_MODEL}}Model IDqwen2.5:7bqwen2.5:7b
{{CONCURRENCY}}Parallel Workers44
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录

Verified Environment for "Concurrent Local LLM Serving: Ollama NUM_PARALLEL vs vLLM Continuous Batching Benchmark"

Tested Hardware & OS

NVIDIA RTX 4090 (24GB VRAM) · 64GB DDR5 · Ubuntu 24.04 · Docker Engine 27.x

Pinned Stack & Model Versions
Ollama 0.5.7 (GGUF Q4_K_M)vLLM v0.6.4 (AWQ INT4)Qwen2.5-7B-Instruct & 14B-Instruct
Offline Boundary (100% Local LAN OpenAI-Compatible Serving)

Once model weights are cached on local NVMe, both Ollama and vLLM run with `--offline` / zero internet access.

Known Operational Limits & Failure Modes
  • vLLM pre-allocates `--gpu-memory-utilization` (default 90% of VRAM) on startup and holds it permanently; it does NOT auto-unload after 5 minutes like Ollama.
  • Raising `OLLAMA_NUM_PARALLEL` from 1 to 4 multiplies KV cache memory by 4x; if you do not lower per-slot `num_ctx` or enable `q8_0` KV cache, Ollama will spill layers to CPU.
DEPLOYMENT CHECKLIST // 配置落地核验步骤

3-Step Verification Checklist After Deploying benchmark-concurrent-llm.sh

  1. Calculated multi-slot KV cache budget (`OLLAMA_NUM_PARALLEL` × `num_ctx`) in the VRAM Calculator before raising concurrency.
  2. Ran the parallel benchmark script (`benchmark-concurrent-llm.sh`) to verify P95 latency stays below client timeout.
  3. Confirmed whether the host needs auto-unloading (`Ollama`) or dedicated 24/7 pinned VRAM (`vLLM --gpu-memory-utilization 0.85`).