Earlier quoted context omitted.
The key thing I got a bit wrong was high-traffic mostly static "content", vs high-traffic "very custom" which is a) what I was used to at envato and b) what I thought we had on our hands at goodfilms. I think in a growing site with a lot of custom per-user content (like a social network) the extra complexity of a cache layer and managing expiry is more pain than it's worth while iterating the product quickly. If you'…
Absolutely. At theconversation.edu.au we run a content site—we publish the news, which is the same for everyone. This means we can cache the front page and all the articles as static HTML, and then annotate the page with user info for signed-in commenters, editorial controls for signed-in editors, and so on. (We have a separate cookie that is present for signed-in users, so the fronted knows whether it should fire th…
The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
11–20 of 42 posts
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#12"We didn’t have any page caching in place at all." Cache me if you can! If you're a high-traffic site and you are not caching static content (I recommend Varnish highly), then your are throwing money or good user experience out the window.
When you say static content, do you mean actual static content, or dynamic-but-still-kind-of-static? Actual static content like CSS files and background images doesn't get any benefit from varnish. Something like the HN front page, where it is dynamic but consistent for all users at a specific point in time, is what you need to put behind varnish.
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#131. Is it possible to spin up two apps on Heroku? 2. What load balancers are available with the above? 3. Anyone have a link to a run down of how to back up your Postgres DB periodically?
Thanks
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#14A few questions: 1. Is it possible to spin up two apps on Heroku? 2. What load balancers are available with the above? 3. Anyone have a link to a run down of how to back up your Postgres DB periodically? Thanks
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#15In addition, I allocate the workers to their own instances so that they can grow independently. Also I use Capistrano to automate deployment. Whenever additional resources are needed, simply clone the instance and add it to the load balancer.
I use 2 Nginx workers and 8 Unicorn workers in a single app instance, and they serve in HTTP at 80 and 443 (yes they respond in HTTP via port 443 and the app should assume it's HTTPS). The app instances are firewalled in a private network and they use private IP addresses.
The load balancer has two networking interfaces, one public-facing and one private-facing. It's basically a reverse proxy serving traffic in both HTTP and HTTPS (which will be forwarded to HTTP:443). So the load balancer handles the encryption entirely.
The assets get compiled during deployment, and everything gets cached. I bundle all the CSS and JS into a single package, so that there's nothing to load other than the HTML and images (natively async) in subsequent visits. The website is simply way more responsive when deployed this way. I also use CloudFront to host the assets by simply pointing the cloud distribution to the website itself as the origin. Rails will handle the assets host automatically as well.
Whenever I need to deploy or manage the database directly for any reason, I will need to connect to the private network via VPN. It's secure and just neat.
If I need to build a local mirror, I'll install another nginx box, connect to the VPN, and reverse proxy HTTPS requests to the HTTP:443 directly. This reduces the HTTPS handshaking latency while still maintaining the security. And it just works.
EDIT: Added a link to make it easier for the curious people.
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#16A few questions: 1. Is it possible to spin up two apps on Heroku? 2. What load balancers are available with the above? 3. Anyone have a link to a run down of how to back up your Postgres DB periodically? Thanks
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#17A few questions: 1. Is it possible to spin up two apps on Heroku? 2. What load balancers are available with the above? 3. Anyone have a link to a run down of how to back up your Postgres DB periodically? Thanks
To answer my own question, there is a free addon called pgbackups that will do this for you, and Heroku automatically load balances between dynos.
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#18Great job! Can you do such page for EC2 too?
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#19Earlier quoted context omitted.
Absolutely. At theconversation.edu.au we run a content site—we publish the news, which is the same for everyone. This means we can cache the front page and all the articles as static HTML, and then annotate the page with user info for signed-in commenters, editorial controls for signed-in editors, and so on. (We have a separate cookie that is present for signed-in users, so the fronted knows whether it should fire th…
Interested in what you mean by annotating the page after caching it, do you have any more info on this?
An extra AJAX request grabs the users logged in status, CSRF token and similar data as JSON and then modifies the page so the user sees what they expect (a logout button, a comment form, etc).
Re: The Minimum Viable Rails Stack, Now Reddit Frontpage Approved
#20Earlier quoted context omitted.
When you say static content, do you mean actual static content, or dynamic-but-still-kind-of-static? Actual static content like CSS files and background images doesn't get any benefit from varnish. Something like the HN front page, where it is dynamic but consistent for all users at a specific point in time, is what you need to put behind varnish.
In high traffic caching css and images in varnish as well makes sense as it is much faster at evaluating and responding to the HTTP request than say Apache which will be busy building dynamic requests.