A multi-tenant realtime platform built with Elixir Phoenix, supporting WebSocket and HTTP APIs for chat, trading, gaming, and any realtime application.
- Elixir Gateway: Phoenix WebSocket/HTTP server with multi-tenant channels
- Go Processor: Event processing and analytics (HTTP on port 8080)
- C++ Driver: Ultra-low latency processing (optional)
- Storage: Postgres for tenant/API/user records, Redis for sessions/ephemeral state, optional ClickHouse analytics sink in Go processor
docker-compose up --buildThis starts:
- Nginx load balancer on
http://localhost - Elixir server on
localhost:4000(internal) - Go processor on
localhost:8080(internal) - PostgreSQL on
localhost:5432(internal) - Redis on
localhost:6379(internal)
Scale services with Docker Compose:
# Scale Elixir servers
docker-compose up --scale polyglot=3
# Scale Go processors
docker-compose up --scale go-processor=2The load balancer automatically distributes traffic.
- Build components:
make all # or manually: cd go_processor && go build -o processor .- Start services:
# Terminal 1: Go Processor
cd go_processor && ./processor
# Terminal 2: Elixir Gateway
mix deps.get
mix ecto.setup
mix phx.server- Test:
# Health check
curl http://localhost:4000/health
# Publish event
curl -X POST http://localhost:4000/apps/demo-app/channels/room:test/publish \
-H "Content-Type: application/json" \
-H "X-API-Key: demo-app-local-key" \
-d '{"type": "message", "data": {"text": "Hello World"}}'
# Get history
curl http://localhost:4000/apps/demo-app/channels/room:test/historyimport { Socket } from "phoenix";
const socket = new Socket("ws://localhost:4000/socket", {
params: { app_id: "your-app", token: "valid_token_user123" }
});
socket.connect();
const channel = socket.channel("room:lobby", {});
channel.join();
channel.on("event", (event) => console.log(event));# Publish
curl -X POST /apps/{app_id}/channels/{channel}/publish \
-H "X-API-Key: <postgres-backed-api-key>" \
-d '{"type": "message", "data": {"text": "Hello"}}'
# History
curl /apps/{app_id}/channels/{channel}/history- JavaScript/TypeScript: polyglot-realtime-client on npm
npm install polyglot-realtime-client ws
See examples/ directory for client implementations in HTML/JavaScript and Python.
Run benchmarks:
mix run benchmarks/benchmark.exsRun tests:
mix test- Elixir 1.17+
- Go 1.21+
- PostgreSQL
- Redis
- ClickHouse (optional, when
ANALYTICS_BACKEND=clickhouse)
MIT