- Optimizing Parallel RTSP Stream Decoding for Smart City Dashboards
Modern smart city surveillance systems need to process hundreds or even thousands of CCTV streams in real time. Handling multiple RTSP streams simultaneously introduces challenges around decoding, CPU/GPU utilization, network bandwidth, latency, and frontend delivery.
In this project, we built a real-time CCTV analytics pipeline using AWS infrastructure, FastAPI, WebSockets, and React.
Architecture
The overall pipeline follows:
RTSP Cameras → Stream Decoder → AI Processing → Event Engine → FastAPI → WebSockets → React Dashboard
Why Parallel Stream Processing?
Processing each camera sequentially creates significant latency as the number of cameras increases. We designed the system to process multiple streams concurrently while keeping the frontend responsive.
AWS Infrastructure
The backend processing layer runs on AWS EC2 infrastructure. GPU-enabled instances can be used for computationally intensive computer vision workloads such as object detection and Re-ID.
RTSP Stream Processing
Each camera provides an RTSP stream. The backend handles multiple streams concurrently and extracts frames for downstream AI processing.
The system is designed to avoid blocking one camera stream while another camera is being processed.
FastAPI and WebSockets
FastAPI acts as the backend API layer, while WebSockets provide low-latency communication between the backend and the React dashboard.
Instead of repeatedly polling the server, the dashboard receives camera events and updates through persistent WebSocket connections.
React Dashboard
The React frontend provides a centralized interface for monitoring multiple camera feeds and AI-generated events in real time.
This architecture allows the frontend to remain responsive while the backend handles stream processing and AI workloads.
Scaling the Architecture
As the number of cameras increases, the system can be extended by distributing camera streams across multiple processing nodes.
Possible scaling strategies include:
- Stream-to-worker assignment
- Dedicated AI inference workers
- WebSocket-based real-time updates
Conclusion
Building a real-time smart city surveillance platform requires more than simply connecting CCTV cameras. Efficient parallel stream processing, scalable cloud infrastructure, asynchronous APIs, and real-time frontend communication are essential for handling large camera networks.
Our implementation demonstrates how AWS, FastAPI, WebSockets, and React can work together to create a scalable foundation for real-time video analytics.
Loading article