⚽ Thairath LiveScore – Real-Time API Gateway System
Developed a
high-performance real-time API gatewaypowering live football data, delivering instant updates on scores, lineups, match events, and statistics across multiple leagues.
📚 Overview
This system is designed as a
scalable real-time data infrastructure, aggregating data from external providers and distributing updates to thousands of concurrent users with minimal latency.
Key goals:
Handle
high concurrency during live matchesDeliver
low-latency, bandwidth-efficient updatesProvide
fine-grained subscription-based data streaming
It acts as a
general-purpose real-time gateway, not limited to sports.
🚀 Core Architecture
🔄 Data Pipeline
External partner APIs →
data scraping every 15 seconds(rate-limited)
Data processed and published into
Redis Pub/SubMessages encoded using
MessagePack (compressed binary format)Distributed to gateway pods → decompressed → streamed to clients via SSE
⚙️ Infrastructure & Scaling
- Kubernetes-based deployment (horizontal scaling)
Each pod:
~
0.5 CPU (500m)+
512MB RAMHandles ~
6,000+ concurrent SSE connections per pod
👉 In Kubernetes,
1500m CPU = 0.5 CPU core
(1000m = 1 core)
- Auto-scaling strategy
:
Scale pods horizontally based on traffic
Maintain stable performance under heavy load
🚀 Key Features
📡 Real-Time Streaming (SSE)
Lightweight, persistent connection for pushing live updates
Optimized for high concurrency
📦 MessagePack Compression
Reduces payload size significantly vs JSON
Improves throughput and latency
🔁 Redis Pub/Sub Distribution
Decouples ingestion from delivery
Enables multi-node horizontal scaling
⚙️ Advanced System Capabilities
🧠 Auto Compare (Delta Updates)
Clients receive
only changed dataReduces unnecessary bandwidth usage
🧾 Version-Based Sync
Clients send current version → receive only diffs
Ensures efficient state synchronization
📡 Channel-Based Subscription
Fine-grained topics like:
1sport-livescore/{matchId}
🌐 Wildcard Channels
Supports patterns:
1sport-livescore/*
❤️ Auto Heartbeat
Sent every
15–30 secondsKeeps connection alive + detects disconnects
🚀 Initial Data Sync
On first connect:
Sends latest full state
Aligns user with current system version
🧩 Channel Mapping System
Dynamic channel creation
Flexible routing between publishers and subscribers
🛠️ Tech Stack
- Backend:
Node.js (Realtime API Gateway)
- Realtime Layer:
Redis (Pub/Sub)
- Protocol:
SSE (Server-Sent Events)
- Data Format:
MessagePack
- Infrastructure:
Kubernetes (auto-scaling pods)
👨💻 Responsibilities
Designed and built the
entire real-time gateway architectureImplemented
data ingestion pipeline (15s scraping from partner APIs)Built
Redis-based pub/sub messaging systemDesigned
MessagePack encoding/decoding pipelineDeveloped
SSE streaming layer for real-time deliveryImplemented advanced features:
Delta updates (auto compare)
Version-based syncing
Channel subscription system (with wildcard support)
Heartbeat & connection management
Deployed and optimized system on
Kubernetes with horizontal scaling
🔮 Future Scalability
Supports
multi-source ingestion (multiple providers)Can serve
multiple client types(web, mobile, third-party APIs)
Designed as a
reusable real-time infrastructure platform
🎯 Impact
Delivered
low-latency real-time experienceat scale
Reduced bandwidth via
delta updates + MessagePack compressionAchieved
high concurrency (~6,000+ users per pod)Built a
reusable real-time system for future products




