TechTalks - Speeding up deployments by 31 times with minor tweaks

My CI was occasionally stacking up deployments. I wanted to share some simple optimisations that improved the deployment time of TechTalks from ~13 min to just 25 sec.

For context TechTalks is a Ruby on Rails app that runs Puma and Sidekiq on two t2.medium servers deployed with Capistrano by GitHub Actions.

1. Cache node_modules

🚀 Time saved ~4 min (I'm not sure why so much TBH)

append :linked_dirs, 'node_modules'

2. Cache webpacker output

🚀 Time saved ~6 min

I use Webpacker for packaging. All JS was being compiled everytime even if no changes had been made. I was vaguely aware this was a known issue. I didn't however know it was fixed but since my manifest.json and builds weren't retained between builds then it still built.

append :linked_dirs, 'public/packs'

3. Limit node memory

Our servers have 4GB RAM and currently no swap space (probably something I should look into).

Occasionally pre-compiling webpacker assets would run out of memory and cause the deploy to silently fail due to a default setting of webpack_compile_output: false in webpacker.yml which I changed. I also set an enviroment variable to tame this in the future:

NODE_OPTIONS=--max-old-space-size=512

Comments

No comments

It's a bit quiet here. Why not be the first to post something?

Subscribe to our newsletter

No spam. Just simple and infrequent platform updates when something big happens.

© 2024 TechTalks.io Limited. All rights reserved.