1

I understand page caching isn't a good option on heroku since each dyno has an emepheral file system (so they wouldn't share files and it would get wiped out on each restart).

So I'm wondering what the best alternative is. I have a large amount of potential files that could get generated in a traditional page caching scenario (say 10GB-100GB) so redis/memcached don't seem like good options here. Redis can write out to disk, but my understanding is that once you exceed it's memory capacity, it's not the right solution to start reading off of disk.

Has anyone found a good solution here? I'm thinking maybe MongoStore. (And some way to run this in conjunction with redis since I'm using redis for some other scenarios.) Thanks!

Brian Armstrong
  • 19,707
  • 17
  • 115
  • 144
  • Looks like this question has been asked before here: http://stackoverflow.com/questions/11019032/heroku-cedar-pure-rack-static-site – maletor Sep 13 '12 at 05:26
  • Hmm, it's related but doesn't really answer my question about how to do 10-100GB of page caching. There may not be any good solution, but still curious. – Brian Armstrong Sep 14 '12 at 06:22
  • Rack::Static will allow you serve both static and dynamic content off your site. – maletor Sep 14 '12 at 06:49

1 Answers1

2

If your site is 100% static content and never going to be dynamic, S3 may be a good option. You can then create a CNAME to the s3 domain. This allows you to leverage CloudFront should you need it. Otherwise, 100GB would have to go into the database, which is in turn then pulled up by your application.

Heroku's cedar stack allows for custom buildpacks. This one vendors nginx. This would be good if you envision transitioning to a more dynamic site.

maletor
  • 7,072
  • 7
  • 42
  • 63
  • This is a good point, loading off of S3 could work well here. Hadn't thought of that. With the nginx buildpack, would my compiled slug (heroku term) have to contain all the data though? I think there is a hard limit of 100MB on the compiled slug. Thanks for the answer this is great. – Brian Armstrong Sep 17 '12 at 04:55
  • No, you'd keep that data in a database and warm various levels of cache starting from InnoDB to query cache to memcached and finally to browser cache. – maletor Sep 17 '12 at 05:16
  • At small scale, S3/CF is fine. At large scale, there are far cheaper CDNs and it becomes cost-efficient to run DIY edge CDNs in hot-spots. –  Feb 24 '15 at 05:17