2

We have a pretty sizable monolithic Rails app that has a few functions (in parenthesis is the estimated % out of the total codebase):

  • Marketing site when users are not logged in: homepage, additional landing pages, SEO pages, registration/login pages, etc (5%)
  • Logged in user facing pages: after logging in, users can see the web app and interact with our product (20%)
  • Logged in admin facing pages: after loggin in, admins can use the integrated CMS to manage everything that users can see (75%)

Over time, the admin part of the site has grown to be much bigger than everything else. All of the above still lives in one single Rails app being hosted on one Heroku Performance-M dyno.

The problem is that a lot of the time, having high "admin" usage leads to slowing down the entire server, which affects non-admin users.

Because of this, we want to split the load into multiple Heroku web dynos, but we would like to keep a single Rails app, for simplicity and development speed.

What is the best way to go about this?

Thanks!

PS - I wasn't sure if Serverfault is the best place to post this... but it was really confusing to choose one. If I chose the wrong place to post, please let me know and I'll post there instead.

criticerz
  • 71
  • 2
  • Why can't you just [scale up](https://devcenter.heroku.com/articles/scaling), then? – Michael Hampton Jan 18 '18 at 21:05
  • @MichaelHampton we have scaled up (and can keep scaling). The part that is making us contemplate this is that we believe users shouldn't be affected by the noisy neighbors (in this case, the admins). By the way, when I say admins, that means our company staff using the CMS on the app. We think that we should be able to scale the user side and the admin side separately. – criticerz Jan 18 '18 at 21:17
  • You'll end up using as many dynos anyway, or even more. It just sounds like it will introduce unnecessary complexity. – Michael Hampton Jan 18 '18 at 21:32

1 Answers1

0

Simple answer here would be to split into two dynos, and put a layer 7 router like HAProxy, Varnish, or whatever heroku provides in front of it. /admin/* goes to one dyno, everything else goes to the other. Its the same app on both, its just not calling certain parts of the site.

HOWEVER

This only helps you if this is an app performance issue. If the admin pages are, for example, killing the database - then this will NOT increase performance in the slightest.

Also, this assumes that your application can actually handle state and sessions properly - when scaling from 1 server to 2, a lot of things will probably come out of the woodwork to bite you. Make sure to test a lot, and communicate to customers when the change is happening. Plan a rollback, cause deploying that might take you a couple tries.

Ryan Gooler
  • 351
  • 1
  • 9