11

I'm starting to hit a wall with my Heroku app.

I'm well aware of the normal issues with slug size, re: images, PDFs, and other materials but my problem likely revolves around other assets brought in by bower or possibly build packs.

https://devcenter.heroku.com/articles/slug-compiler Heroku Slug Size After Multiple Deployments

My Heroku compliled slug looks like so:

$ du -h --max-depth=1

4.0K    ./.bower-tmp
30M ./tmp
24K ./features
236K    ./config
195M    ./public
4.0K    ./log
34M ./bin
792K    ./db
355M    ./vendor
8.0K    ./.heroku
22M ./app
64K ./lib
8.0K    ./.bundle
136K    ./.bower-registry
22M ./.bower-cache
24M ./node_modules
12K ./.profile.d

By far the largest is Vendor (355M), but my local vendor folder is in fact empty as is public (195M).

But on heroku it looks like:

40M vendor/ruby-2.0.0
21M vendor/node
32K vendor/heroku
12K vendor/assets
103M vendor/jvm
192M vendor/bundle

195M public/assets (bower bloat?)

Which I'm guessing is one of several build packs for bower and for PDF generation.

https://github.com/heroku/heroku-buildpack-nodejs
https://github.com/heroku/heroku-buildpack-ruby
https://github.com/razorfly/wkhtmltopdf-buildpack

My app itself looks lean-ish at 22M, but my current heroku SLUG is 298.4MB! and the vendor directory alone is more than that according to du, should I not be using these build packs and instead migrate to asset compilation on my local machine between builds? I'm not sure what a good deployment strategy (/ slug diet) should look like, any ideas would be greatly appreciated.

UPDATE:

I also tried rebuilding the slug from what I read had worked for others, but to no effect. Slug size after compilation remained the same.

heroku plugins:install https://github.com/heroku/heroku-repo.git
heroku repo:rebuild -a appname

GIST of build: https://gist.github.com/holden/b4721fc798bdaddf52c6

UPDATE 2 (after following the excellent idea presented by drorb)

12K ./.profile.d
21M ./app
4.0K    ./log
812K    ./db
8.0K    ./.heroku
236K    ./config
195M    ./public
19M ./.bower-cache
60K ./lib
253M    ./vendor
4.0K    ./.bower-tmp
128K    ./.bower-registry
34M ./bin
30M ./tmp
24M ./node_modules
24K ./features
8.0K    ./.bundle

Vendor

12K vendor/assets
193M    vendor/bundle
21M vendor/node
32K vendor/heroku
40M vendor/ruby-2.0.0

Public/Assets (very long)

https://gist.github.com/holden/ee67918c79dd3d197a6b

Community
  • 1
  • 1
ere
  • 1,739
  • 3
  • 19
  • 41

3 Answers3

4

The size of vendor/jvm is 103M. Since you are not using JRuby the only reason I could find for having it is using the yui-compressor gem. Looking at the heroku-buildpack-ruby it seems that the JVM is installed in this case:

def post_bundler
  if bundler.has_gem?('yui-compressor') && !ruby_version.jruby?
    install_jvm(true)
    ENV["PATH"] += ":bin"
  end
end

If you can avoid using yui-compressor you should be able to save 103M on your slug size.

Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
  • I removed YUI and that shaved off 60MB, thanks! My slug is still overweight at 235MB, any other awesome ideas? ;-) – ere Dec 17 '14 at 09:42
  • Can you share the updated folder sizes? next candidates would be public/assets and public/assets – Dror Bereznitsky Dec 17 '14 at 09:46
  • Updated. The public/assets folder is almost all Bower related assets. The problem I've been having is that it doesn't seem to remove libraries even after I've remove them from my bower.json (for example Hexaflip is long dead but it's still in assets.) – ere Dec 17 '14 at 10:00
  • @ere Did you limit the types of assets being pre-compiled? did you try cleaning the assets or forking the app? – Dror Bereznitsky Dec 17 '14 at 19:33
  • Yup, I limited them both in the application.rb by filetype, and also in the slugignore. I tried executing bower prune after install during slug compilation, changing bower package version numbers, and I also tried recompiling the slug using the plugin and `heroku repo:rebuild` Can't seem to get a clean bower install. – ere Dec 18 '14 at 11:40
  • @ere I saw in the build log that you are using rake assets:clean, did you try to replace it with rake assets:clobber? – Dror Bereznitsky Dec 18 '14 at 13:29
2

FWIW, we removed Bower from our app and replaced it with the Rails Assets framework. We came to the conclusion that using Bower in a Rails app was somewhat pointless as Bundler essentially serves the same function.

tagCincy
  • 1,589
  • 10
  • 20
  • We also tried Rails Assets 2 or 3 months ago but found we had the same problems as with Bower but with even less control over specifics. – ere Dec 17 '14 at 15:01
1

Part of the problem may be pointing at Git repos in your Gemfile. At one point I needed to point at a Rails commit that hadn't been released and it added > 100 MB to my slug size over pointing at a released version.

abstractcoder
  • 376
  • 2
  • 5