An adventure of Happy Eyeballs
summary
Adds Happy Eyeballs v2 (RFC8305) to Socket.tcp by running parallel DNS resolution in per-family threads, starting staggered connections, and waiting with IO.select + IO.pipe to detect both name and socket events. Implementation is ~528 LOC (was 43), doubles some call latency but prevents hangs; a fast_fallback option lets callers disable it. Demo shows Ruby with the change connects via IPv4 when IPv6 hangs. Patch is merged as PR#9374 to master and targets Ruby 3.4; C TCPSocket.new support is pending.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 0:54Current Ruby socket issues
- 3:12Happy Eyeballs v2 explained
- 6:28Implementing in Ruby Socket
- 8:16First implementation problems
- 10:53State machine approach
- 15:24State transitions in code
- 22:04Edge case handling
- 23:40Performance impact
- 24:47Demo setup
- 26:01Demo without Happy Eyeballs
- 26:45Demo with Happy Eyeballs
- 27:36Problem case demo
- 28:39Project status and next steps
related talks
29mThe Less-Told Story of Socket Timeouts
26mTCP Sockets Programming in Ruby
01h 01mWhat I learned from sockets
36mThe Little Server That Could
21mHow to hijack, proxy and smuggle sockets with Rack/Ruby
26mConcurrency in Ruby: From fork() to Fiber
35mThe little server that could
35mLet's build a simple HTTP server with Ruby
