Understanding Request Queueing in Rails Apps
The article explains how request queuing works in Rails apps and provides insights on how to build more robust services. The author shares their experience of migrating from a traditional VM infrastructure to a containerized environment managed by Kubernetes. They encountered an issue where Rails services would stop responding during high load, and after investigation, they discovered that the sockets were left in the CLOSE_WAIT state. To solve this issue, they decided to switch from Unicorn to Puma. The article then delves into the concept of request queueing, clarifying that it doesn't happen at the load balancer but rather at the OS kernel level. The socket backlog is where most of the queueing occurs. The article also explains Puma's inner workings as a pre-forking web server. Overall, this article provides valuable insights for developers working with Rails apps and offers guidance on optimizing request queuing.