🚀 Scaling Python AI & Long-Running Tasks with Rust: Introducing RestWs >> Sync Simplicity, Async Power: REST-Call in, WebSocket-Stream out << Are you struggling with REST API timeouts during heavy AI inference or complex data processing? Traditional task queues add significant infrastructure overhead, while standard async Python can still hit bottlenecks. I’m excited to share RestWs, a high-performance web server engine built in Rust (and Python) designed specifically to decouple heavy workloads from the HTTP lifecycle. ❓ The Problem: Modern APIs face scalability challenges when handling long-running tasks. These workloads block the request-response cycle, leading to client timeouts and resource exhaustion. 💡 The Solution: RestWs implements the ASGI standard to bridge the gap between low-level systems performance and high-level Python logic. It allows you to write synchronous Python while the Rust engine manages the heavy lifting through a unique "Process Split." 🔑 Key Features: The Split: Trigger a background task that automatically pipes stdout/logs directly to a persistent WebSocket while the initial HTTP request resolves. Zero-Downtime Hot-Reload: Deploy new Python code without dropping active WebSocket connections. Compatibility: Works seamlessly with FastAPI and other ASGI compatible frameworks. ⚡ RestWs is currently in the experimental phase and is perfect for developers looking to simplify their stack while maintaining massive throughput for streaming data and AI applications. Links to the source code, binary and a working demo application (Python FastAPI backend and JavaScript frontend) can be found in the comments. #Python #Rust #WebSockets #BackendEngineering #RestWs #AI #Scalability #OpenSource
Interesting project! I’ve been considering Rust for backends many times but always fallback to the safe/proven/convenient python/fastapi stack. Mainly for dev productivity reasons. This could be a nice hybdrid solution for heavy background tasks.
Source code: https://github.com/asderix/RestWs Demo application: https://github.com/asderix/RestWsDemo