Hasty Briefsbeta

Show HN: Building WebSocket in Apache Iggy with Io_uring and Completion Based IO

5 days ago
  • #Rust
  • #io_uring
  • #WebSocket
  • Apache Iggy is undergoing a core architecture rewrite using io_uring and a thread-per-core, shared nothing design to improve performance and reduce latency.
  • The migration from Tokio to compio, a completion-based async runtime, presented challenges when integrating WebSocket support due to incompatible I/O models.
  • Tungstenite, a popular Rust WebSocket library, is poll-based and expects shared buffers, making it incompatible with compio's completion-based model requiring owned buffers.
  • The team developed compio-ws, a WebSocket implementation for compio, to bridge the gap between poll-based and completion-based I/O models.
  • Initial attempts using SyncStream with fixed buffer sizes led to performance issues with large messages, prompting the creation of GrowableSyncStream.
  • GrowableSyncStream dynamically adjusts buffer sizes, starting small and growing as needed, with configurable limits to prevent memory exhaustion.
  • Benchmarks comparing TCP and WebSocket performance showed WebSocket adds reasonable overhead, with producer latency increasing by ~0.8-1.0ms and consumer latency roughly doubling.
  • Future work includes optimizing buffer growth strategies, implementing buffer pooling, and developing a native WebSocket protocol with owned buffers for better performance.
  • The compio-ws implementation has been contributed to the compio project, inviting community contributions for further optimizations.