I'll bet that what Heroku does is precompile all the code when you push to Heroku (or doesn't), saves it to a S3 bucket, and kills the running process after a certain amount of inactivity. Once it detects a pending network request, the code gets loaded from the S3 bucket into the EC2 instance, and then your code spins up.