Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to improve Heroku App Boot Time by enabling build-in-app-dir feature in CoderDojo Japan website #1423

Closed
yasulab opened this issue Mar 25, 2022 · 1 comment
Labels
アイデア Ideas to improve business.

Comments

@yasulab
Copy link
Member

yasulab commented Mar 25, 2022

Shopify チームが開発した Bootsnap gem を使うことで、Heroku 上の初回起動時間 (Boot App Time) が最大で半分に短縮できるようになったようです 😳✨ (要件: Rails 5.2 以上でデフォルトの Bootsnap を外していないこと)

💎 Cut your Rails boot times on Heroku in half with a single command - DEV Community https://dev.to/dbackeus/cut-your-rails-boot-times-on-heroku-in-half-with-a-single-command-514d

TLDR;

$ heroku labs:enable build-in-app-dir -a <APP_NAME>

Now enjoy your Rails app booting ~twice as fast after your next deploy 🙌

現在はベータ版で、利用者のフィードバックは heroku/heroku-buildpack-ruby#979 (comment) で集約されているとのことです。

上記 Issue を確認して問題なさそうな雰囲気だったので、 https://coderdojo.jp でも前後の状態で計測をしつつ、build-in-app-dir feature を有効にしてみます 🛠💨

計測方法

  1. まずは現在の状態で計測:

     time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
    
  2. build-in-app-dir 機能を ON にして、空コミットし、デプロイを見守る(必要ならロールバック!)

    $ heroku labs:enable build-in-app-dir -a <APP_NAME>
    
  3. 無事デプロイできたら 1. と同じ方法で計測する

     time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
    
@yasulab yasulab added the アイデア Ideas to improve business. label Mar 25, 2022
yasulab added a commit that referenced this issue Mar 25, 2022
$ heroku labs:enable build-in-app-dir -a <APP_NAME>

cf. Cut your Rails boot times on Heroku in half with a single command
https://dev.to/dbackeus/cut-your-rails-boot-times-on-heroku-in-half-with-a-single-command-514d
@yasulab
Copy link
Member Author

yasulab commented Mar 25, 2022

https://coderdojo.jp/ の本番環境で計測してみました! ⏲️ ✅✨
4秒〜10秒台の App Boot Time が、2秒台になりました...!! 😻🆒✨

Before: App Boot Time

╭─○ yasulab ‹2.7.3› ~/coderdojo.jp
╰─○ heroku run bash

# 1st try
$ time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
real	0m10.353s
user	0m6.244s
sys	0m0.904s

# 2nd try
$ time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
real	0m5.248s
user	0m2.272s
sys	0m0.360s

# 3rd try
$ time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
real	0m4.031s
user	0m2.204s
sys	0m0.296s

After: App Boot Time

╭─○ yasulab ‹2.7.3› ~/coderdojo.jp
╰─○ heroku run bash

# 1st try
$ time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
real	0m2.416s
user	0m1.224s
sys	0m0.244s

# 2nd try
$ time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
real	0m2.618s
user	0m1.364s
sys	0m0.180s

# 3rd try
$ time NEW_RELIC_AGENT_ENABLED=false rails runner puts "Done"
real	0m2.397s
user	0m1.292s
sys	0m0.224s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
アイデア Ideas to improve business.
Projects
None yet
Development

No branches or pull requests

1 participant