đ Streaming Example
Demonstrates HTTP response streaming with progressive rendering. Shows how Falcon handles long-running streaming responses efficiently, perfect for progress indicators, live logs, or real-time data feeds.
đĩ Try the Streaming Demo
Click the button below to start the streaming "99 Bottles of Beer" countdown. Notice how the text appears progressively in real-time!
đ§ Technical Implementation
- Streaming Response: Uses
Rack::Responsewith a proc body for streaming. - Progressive Rendering: Browser starts rendering immediately with chunked transfer encoding.
- Non-blocking: Falcon handles streaming without blocking other requests.
- Buffer Control: Includes initial buffer padding to trigger browser rendering.
đ Key Files
app/controllers/streaming_controller.rb- StreamingController - HTTP streaming implementationapp/views/streaming/index.html.erb- streaming/index.html.erb - Documentation page
đ Performance Benefits
Traditional Ruby web servers struggle with long-running requests that block worker processes. Falcon's async architecture allows multiple streaming responses simultaneously without resource exhaustion.
đĄ Use Cases
- Progress Indicators: Long-running task progress.
- Live Logs: Real-time log streaming.
- Data Exports: Large CSV/JSON file generation.
- Live Updates: Status updates during processing.