How to set minimum RAM & CPU for a single instance?

We're relatively a new startup looking forward to trying out Railway. We'd like to run a Flask server in production using Gunicorn with at least 4GB RAM allocated for our works. There seems to be no option to vertically scale in the deployment settings page. How can we set minimum RAM, CPU? Any guidance would be helpful. Thank you.
17 Replies
Percy
Percyβ€’12mo ago
Project ID: da795de3-9cd9-4c8e-88e9-b39a4e8028af
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
da795de3-9cd9-4c8e-88e9-b39a4e8028af
Fragly
Fraglyβ€’12mo ago
a minimum RAM and CPU? <:mommy_confused:1023749002069540935> Do you mean a maximum? Also railway automatically scales vertically for you, until you reach your plan's resource limits for the service anyway
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
Two questions here: 1. We are using Heroku at the moment and looking forward to entirely ditching Heroku in favor of Railway, but our services seem to be running at lower memory available (while they're not handling any web requests) than compared to Heroku on a per instance basis. Is there a way we can set minimum memory & CPU below which it doesn't scale down, even if there's not traffic?
Fragly
Fraglyβ€’12mo ago
So you're saying on railway your app uses less resources and you don't want that?
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
In Railway each Gunicorn worker is getting less resources, compared to earlier is what I'm trying to say... So, I'm looking on how to scale it to match the performance of what we already have.
Fragly
Fraglyβ€’12mo ago
Oh I see what you mean, I'm not really sure if that's possible on railway I don't have much experience with Gunicorn, or python as a whole either Best wait for someone more knowledgable to see this thread
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
So, our service is a Flask based WhatsApp chatbot that recommends people to each other. So, the CPU & RAM usage doesn't directly co-relate to the number of HTTP requests we'll be getting. As these requests won't be from real people, but rather from WhatsApp webhooks. So, it may look like we're idling from an HTTP requests standpoint, but the server would be performing internal calculations (running a recommendation engine written in Python + SQLAlchemy). This engine is running too slow in Railway, when we tried to migrate yesterday night (Indian Standard Time)
Brody
Brodyβ€’12mo ago
the minimum amount of cpu and mem is simply the minimum amount that your app needs, the max is the max your plan allows for. if your app isnt using 4gb of ram, then it doesnt need 4gb of ram
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
I totally understand that, what I'm trying to figure out is how Railway determines what is required for my app πŸ˜… Like does it happen by the number of HTTP requests we're getting?
Brody
Brodyβ€’12mo ago
railway does not determine anything like that for you, you are over thinking this. your app is fee to use as little or as much of the plans resources it wants at any given time
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
Because right now, on Heroku we've got 4GB RAM and our Python based recommendation engine is working fine even after it's really far from database's physical location. In fact, Railway offers the same physical location to our database provider, but still Gunicorn kills the workers threads frequently and the whole performance is really slow.
Brody
Brodyβ€’12mo ago
gunicorns default timeout is 30 seconds
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
your app is fee to use as little or as much of the plans resources it wants at any given time
Ah! I see. That means my app already has 8GB memory if it wants to use right? Then I wonder how come it's slow on Railway being near to the database and faster in Heroku being farther from the database πŸ˜‚ Yup, we know that could become a problem and we changed it πŸ‘ The command we use right now in both Heroku & Railway is πŸ‘‡
gunicorn --worker-class gevent --workers 4 --timeout 3600 app:app
gunicorn --worker-class gevent --workers 4 --timeout 3600 app:app
Brody
Brodyβ€’12mo ago
That means my app already has 8GB memory if it wants to use right?
correct
Then I wonder how come it's slow on Railway being near to the database and faster in Heroku being farther from the database
sorry im not sure, railway runs yout code as is
Vasanth Srivatsa
Vasanth SrivatsaOPβ€’12mo ago
Interesting πŸ€” I'll be running some further test to determine what could be the underlying issue and get back to you by either closing the ticket, with my results posted. Or ask further questions. Thank you πŸ™‚
Brody
Brodyβ€’12mo ago
yeah it would be really hard to say what could be wrong with your code without telemetry or metrics data
Want results from more Discord servers?
Add your server