AWS Builder Center
Optimizing Parallel RTSP Stream Decoding for Smart City Dashboards

Optimizing Parallel RTSP Stream Decoding for Smart City Dashboards

Learn how we optimized the processing of multiple RTSP camera streams using AWS, FastAPI, WebSockets, and React to build a scalable real-time smart city surveillance dashboard.

Working at the intersection of AI, backend systems, and Solana to build scalable Products
  1. 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:
  • GPU-based EC2 instances
  • Stream-to-worker assignment
  • Load balancing
  • Dedicated AI inference workers
  • Event-based processing
  • 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.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article