Splitting up a Rails/Ruby app onto multiple servers
- by craig.kaminsky
We recently moved a large application to two machines, both running the same codebase.
I. Machine A
Web server for public facing application
Receives web hook call backs from our ESP
Handles a few large, list-processing jobs (uploaded spreadsheets with data)
II. Machine B
Manages a massive set of (background) jobs but, primarily, focuses on building and assembling newsletters
Runs all integration with our NetSuite platform
Runs all system maintenance (read: DB) jobs
To me, having these two apps running the same codebase (a large, monolithic Rails application) seems 'wrong'.
I am wondering if anyone has advice on how to better break up the code for these two apps. While they both need the same DB and, ultimately, the same model code, Machine B has no need for Controllers and Views and it feels wasteful running a full-stack Rails app for its tasks.
A couple things came to mind but I'm not sure if I'm trying to solve a problem that doesn't exist:
Break the models out into a sub-module on git and include into both apps
Build out the Mahcine B app in plain Ruby or a lighter framework like Sinatra (where I could use ActiveRecord with Sinatra in combo with a sub-module for the model folder).
I'm new to this scenario and appreciate any and all feedback or direction! Thank you.