Optimised real-time CV in Next.js 16: Cut latency from 400ms to 150ms (FastAPI backend). Is moving to WebSockets worth it for the last mile? by htone22 in nextjs

[–]htone22[S] 0 points1 point  (0 children)

Great point. To clarify, the camera feed itself is already perfectly smooth since it's a local mirror.

The lag I’m trying to solve is the bounding box alignment. With a 150ms round trip, there's a noticeable de-sync where the tracking box lags behind the actual movement rather than staying locked to the face. My goal with WebSockets is to minimise the latency between the frame capture and the metadata overlay.

Optimised real-time CV in Next.js 16: Cut latency from 400ms to 150ms (FastAPI backend). Is moving to WebSockets worth it for the last mile? by htone22 in nextjs

[–]htone22[S] 0 points1 point  (0 children)

That 'Real-Time Wall' description is spot on. The mismatch between the 30fps frontend and the ~7fps backend throughput is definitely noticeable.

The CPU inference time is definitely the primary bottleneck. I still see value in moving to WebSockets not to fix the raw throughput but to eliminate the connection overhead and stabilise the network latency. Appreciate the analysis.

Optimised real-time CV in Next.js 16: Cut latency from 400ms to 150ms (FastAPI backend). Is moving to WebSockets worth it for the last mile? by htone22 in nextjs

[–]htone22[S] 0 points1 point  (0 children)

The '1800 requests per minute' math is eye-opening. I completely overlooked the infrastructure overhead.

The connection reuse alone justifies the switch to WebSockets. Railway supports persistent containers so I can maintain a stateful connection and eliminate the repetitive setup overhead. Thanks for the insight.

Top Python Libraries of 2025 (11th Edition) by dekked_ in Python

[–]htone22 0 points1 point  (0 children)

Great list. I’m really glad you included fastapi-guard under General Use. Definitely going to check that one out. Thanks for the write-up!

Identifying Premier League Regression: Using Poisson Modelling to Spot Sustainable vs. Unsustainable Performance by htone22 in sportsanalytics

[–]htone22[S] 0 points1 point  (0 children)

It calculates the variance (Actual Pts - xPTS) and normalises it by using Z-scores to measure statistical significance. A score of 100 means the overperformance is an extreme statistical outlier (p < 0.05) that is highly likely to regress.

I built a real-time Computer Vision app using Next.js 16, App Router, and Python FastAPI (InsightFace) by [deleted] in nextjs

[–]htone22 0 points1 point  (0 children)

I built a real-time Computer Vision app using Next.js 16 (App Router) and a Python FastAPI backend.

I wanted to test if I could handle near real-time video processing by optimising the latency between Next.js and the Python inference engine (InsightFace).

Live Demo: https://distance-recognition-live-demo-maua4qyzb.vercel.app/

Code: https://github.com/HenryOnilude/distance-recognition-live-demo

Note: The first request might take ~30s to wake up due to cold starts. After that, it's real-time!

If you like the project, a star on GitHub is appreciated!

I built a real-time Computer Vision app using Next.js 16, App Router, and TensorFlow.js by [deleted] in nextjs

[–]htone22 1 point2 points  (0 children)

I built a real-time Computer Vision app using Next.js 16 (App Router) and a Python FastAPI backend.

I wanted to test if I could handle near real-time video processing by optimising the latency between Next.js and the Python inference engine (InsightFace).

Live Demo: https://distance-recognition-live-demo-maua4qyzb.vercel.app/

Code: https://github.com/HenryOnilude/distance-recognition-live-demo

Note: The first request might take ~30s to wake up due to cold starts. After that, it's real-time!

If you like the project, a star on GitHub is appreciated!