1. Why do people keep asking "Why PHP?"
There are two main reasons:
- Wrong architectural assumption: When people see "PHP-based PBX," they assume SIP signaling, RTP audio streams, call queues, or real-time chat flow through PHP.
- Legacy FreePBX / PHP 5 trauma: Slow screens in old FreePBX setups and 15-year-old PHP stereotypes still trigger an automatic reflex.
Here is the actual reality in AiPBX — PHP is never in the media or signaling hot path:
- SIP / RTP / WebRTC media and call queues: C (Asterisk 22 LTS + PJSIP + coturn).
- Port 443 ALPN / SNI multiplexing: C (Nginx stream module).
- Real-time team chat and presence (WebSocket): Go (aipbx-chat).
- Live AI voice agents and local TTS/VAD (ARI / AudioSocket 20 ms PCM streams): Python asyncio + C++ ONNX Runtime (aipbx-ai).
- PHP 8 is strictly the Control Plane: Admin portal forms, REST API CRUD, reports, and generating /etc/asterisk/pbx/*.conf files when you click Apply. While calls are running, PHP uses near-0% CPU.
The one honest bottleneck: If many call-center agents keep the live wallboard or agent console open in browsers polling AJAX every few seconds, PHP/Apache workers and MariaDB queries take the load — yet even then, active phone calls in Asterisk/RTP are completely unaffected; only the portal UI slows down.
2. How many "agents" can run on a 4 vCPU / 4 GB RAM server?
The base services (Linux + MariaDB + Asterisk 22 + Apache/PHP + Nginx + Go aipbx-chat + coturn) use roughly 1.0–1.3 GB of RAM combined, leaving ~2.5–3.0 GB of RAM and 4 CPU cores for workload headroom.
A) Human Call Center Agents
| Scenario | Comfortable Concurrency | Where is the bottleneck? |
|---|---|---|
| Registered / logged-in portal agents | ~80 – 150 agents | Portal AJAX polling + MariaDB (Go aipbx-chat easily handles 1,000+ concurrent WebSockets on this hardware) |
| Active talking agents (WebRTC + Opus↔G.711 transcoding + recording) | ~40 – 70 concurrent calls | Asterisk codec transcoding + SRTP encryption CPU |
| Active talking agents (Desk SIP / G.711 passthrough, no transcoding) | ~80 – 120 concurrent calls | Network & Asterisk channel I/O |
B) AI Voice Agents (Concurrent Active Calls)
Here again, the limiting factor is not PHP — it is whether speech synthesis runs locally or via cloud APIs (based on our real 2-core ONNX benchmarks in the documentation):
| AI Mode | Comfortable Concurrency | Where is the bottleneck? |
|---|---|---|
| Cloud Realtime (OpenAI Realtime / Gemini Live / xAI) or full Cloud Cascade | ~25 – 50 concurrent calls (~15 – 25 with local Silero VAD / Smart Turn enabled) |
Usually hits provider API rate limits before server CPU |
| Cascade + Local EMA Lightning (TR, ONNX ~115–250 MB RAM, 11–12× real time on 2 cores) | ~6 – 10 speaking simultaneously (~10 – 15 active calls) |
CPU ONNX TTS inference latency |
| Cascade + Local Piper (DE/EN, ONNX ~120–170 MB RAM, 13–16× real time on 2 cores) | ~10 – 18 concurrent calls | CPU ONNX TTS synthesis load |
| Cascade + Local Kokoro (EN, ONNX ~460–650 MB shared RAM, 1.7× real time on 2 cores) | ~2 – 4 concurrent calls | CPU bound without GPU acceleration |
In short
PHP is never in the media or signaling hot path in AiPBX. SIP, RTP, WebRTC, queues, and transcoding run in C (Asterisk 22 + Nginx + coturn); real-time chat runs in Go; live AI voice streams (ARI / AudioSocket) and ONNX TTS/VAD run in Python/C++. PHP 8 is strictly the control plane (admin UI, REST CRUD, and generating Asterisk configs on Apply) — zero runtime overhead on active calls, low idle RAM (~1 GB for the whole stack), and simple single-server deployment on small VPSs or Raspberry Pi.