Hi, when i implement rails to k8s, it seems takes too slow to boot up till http server is fully ready. there are 2 case currently happens:
- with existing ec2 node → takes 20-30s to ready for serve http requests
- non existing ec2 node → the pod will remain in pending state around 30s. new node comes in, and the next 60s pod is ready to serve http requests. so the total is around 90s.
i already do these things:
- Profiling my boot time
- Removing unused gems
- Removing specific rail component, such as action-cable that unnecessary in our prod
- Using smaller ruby image → ruby:3.0.0-alpine
so, the result not significant, only reducing around 4 seconds for both cases. im targeting
FYI, this is my setup:
ruby '3.0.0'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
gem 'puma', '~> 4.3'
For running the server im using puma clustered mode, that run:
1 worker, 5 threads
Notes: above setup is for my PoC only, so i need to test it on our staging server first. if we successfully achieve our target for faster boot time, we can proceed to production environment.
and, one last thing. just curious. how fast/ how long do you guys for your rails in production environment to boot up when scaling happens (on peak load) ?