TechTalks

The official TechTalks community. We want your help on getting vital feedback to make our platform work for your communities.

What are TIL's?

TIL • acronym • Today I Learned

TIL stands for Today I Learned... it's a place to share knowledge, tips and tricks with other members in your community. Snippets are up to 1500 characters.

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

Subscribe to our newsletter

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

© 2021 TechTalks.io Limited. All rights reserved.