Hasty Briefsbeta

From Zero to 35M: The struggles of scaling Laravel with Octane

6 days ago
  • #OpenSwoole
  • #Scaling
  • #Laravel Octane
  • Laravel Octane with OpenSwoole helped scale the system to handle over 35 million requests per day.
  • IdleMMO, an online multiplayer game built with Laravel and Alpine.js, experienced rapid growth, leading to scaling challenges.
  • Initial infrastructure (NGINX, MySQL, Redis, Laravel Horizon) struggled with increased traffic after launching on Google Play Store.
  • Laravel Octane significantly improved performance, reducing response times from 394ms to 172ms (95th percentile).
  • Octane's key advantage is bootstrapping the application once and keeping it in memory, reducing overhead.
  • Challenges included managing persistent database connections and unintended data sharing across requests.
  • Static variables and singletons caused issues, requiring careful code review to ensure request isolation.
  • Limited documentation on Octane and Swoole led to troubleshooting difficulties.
  • Database transaction errors occurred due to persisted connections, resolved by uncommenting a line in Octane's config.
  • Server limits (worker_connections, file descriptors) were hit, requiring configuration adjustments.
  • Monitoring worker performance was achieved using OpenSwoole's stats function.
  • Race conditions in resource-intensive operations were fixed using locks to prevent concurrent executions.
  • Octane's performance allowed handling 35 million requests/day on a 32 vCPU server, with potential for more.
  • Recommendations include using Octane for scaling, monitoring workers, and being cautious with persistent data.