adampointer / websockets-poc

POC for a high-throughput Kafka to WebSockets API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebSockets POC

Running

Prerequisites

  • Get Rancher Desktop or some other similar local k8s cluster.
  • Disable Traefik in Preferences->Kubernetes as we use Istio for ingress
  • Get Skaffold:
brew install skaffold
skaffold config set default-repo local

Build and Run

skaffold run

Run it! (You will get disconnected after 60s if you do not send ping frames with /ping)

wscat -c 'ws://localhost/ws' --slash -P
Connected (press CTRL+C to quit)
> {"jsonrpc" : "2.0", "id": 1, "method": "subscribe", "params": ["market:spot:tickers", { "pair": "btc_usdt", "exchange": "binance" }]}
< {"jsonrpc": "2.0", "id": 1, "result": "123456"}
< {"jsonrpc":"2.0","id":1,"method":"subscription","params":{"subscription":"1223456","result":{"exchange":"binance","timestamp":1690297936009,"bid":0.01,"ask":0.11,"bidVolume":100,"askVolume":1000}}}

Monitoring

kubectl -n istio-system port-forward deployment/grafana 3000:3000
kubectl -n istio-system port-forward deployment/prometheus 9090:9090

Import the Go Processes dashboard - https://grafana.com/grafana/dashboards/6671-go-processes/

Latency query (p95): histogram_quantile(0.95, sum by(le) (rate(websocket_adaptor_latency_bucket{app="websocket-adaptor"}[$__rate_interval])))

About

POC for a high-throughput Kafka to WebSockets API


Languages

Language:Go 97.6%Language:Makefile 2.4%