How much to host a Rails app in production

Without comparing apples to pears, Heroku/Render, I wanted to know how much I should be spending.

For all my life, “localhost” apps are super fast so I’m used to those speeds :joy:. I’ve also been using Heroku for many years (hobby apps) and the speed is relatively ok. I’ve never had a production app before but now I’m in the process of having one. I dont believe render is the issue here but the more data I add, the slower my website gets, only on render.

Been having a look on Google, what’s the minimum RAM for a rails app, I see 1GB. Should I be hosting my app on a 1GB server? I mean, I’m the only user, for now. Im using my own app for few months before inviting the world. So, on render, should my plan be “Starter Plus” or “Standard”? Free plan is getting shower with the more data being added to database.

Hi there,

Thanks for reaching out.

Free services aren’t really intended for production use, so there are likely going to be noticeable performance differences between free and plans with more resources. Projects are usually super fast locally as there are no network connections at play, no real user load and your home machine likely has a lot more CPU/RAM than lower-end cloud plans.

So unfortunately, the question you are asking can only be answered with “it depends”. A Rails app is not a finite thing, you could have 100 gems loading at boot doing all sorts of crazy intensive stuff or be in a barebones API mode, and it would be a lot lighter. And then

The only way to truly know what resources your app requires at a certain load is to test it. In its most basic form, just spin up a testing environment, and throw some requests at it. But to make that worthwhile you’ll need to make you have visibility of the metrics you want to check to know where any bottlenecks lay. For example, some common things to monitor:

  • Does the database struggle when requests increase? Can queries be optimized? Does your DB need more resources? Are your connection pooling numbers set optimally?

  • If CPU of the instance is running high, maybe your thread count is set too high. If so, reduce the count or increase the plan and retest.

  • If RAM use is high, check how many puma workers are running. Again, reduce the count or increase the plan an retest.

  • Are views rendering the same content dynamically over and over, would caching help?

  • If you find the app works as you want for the most part, but needs increased resource in peaks of traffic, maybe auto-scaling would help.

  • And so on…

Optimizing an application for production is another part of the development process, and what is “optimal” will depend on what your app does and how it’s implemented. You’ll want to find a balance so that your configuration uses as much resource of your chosen plan without overloading it. If you then need more resource you can scale horizontally (more instances). However, if you find you need more resource overall, you can pick a higher plan, which would likely need configuration changes to again ensure you using the available resource efficiently.

Hope that helps


1 Like