10 months ago
Hi Everyone,
I need help with my Slow API response, I have been using Railway for a few months now and observing this API response slowness issue.
I am using Railway to host my API codebase, which is written in Golang, with a PostgreSQL database hosted on AWS.
However, I am experiencing very slow API responses.
Here are some details:
My API server is hosted on Railway in the US West (Oregon, USA) region.
My PostgreSQL database is hosted on AWS in the Asia Pacific (Mumbai) region.
Locally, my code runs very fast.
I have implemented Golang best practices and my database queries are optimized with proper indexing.
I am currently on the Hobby Plan.
Given this setup, I am looking for advice on how to increase the performance of my API. Specifically:
Should I consider changing the regions of my services to bring them closer together?
Is there anything I might be missing that could be causing the slow response times?
Are there any tips and tricks to improve the performance of my API given my current setup?
Thank you in advance for your help!
11 Replies
10 months ago
From past experience helping other users, the round trip time for distances like US West to Asia is detrimental to database connections, here's a few options from (IMO) best to worst -
Run your database on Railway with the Pro plan so that both your service and database are in the same Singapore region and so you can connect to the database over the private network.
Stay on Hobby but still run your database on Railway so you can connect to it via the private network.
Update to Pro so that you can move your service to the Singapore region.
Move your database on AWS to the US West region.
10 months ago
Understood.
Is having different resgions is only problem or have you seen any other issues as well ?
10 months ago
For threads similar to yours it's always been the service is far away from the database.
10 months ago
Off Topic: Do you guys have good document on How to deploy barebone Next App on Railway? I want only NextJS to serve my Client Code, no DB in it.
10 months ago
For the most part deploying a next app is fairly simple, you should be able to give Railway your GitHub repo and it will build and run it, where you have any difficulties?
10 months ago
Yeah, I tried it gave Internal server error for some reason. Do you have a Sample Repo with DockerFile or share an example of DockerFile, that would be huge help?
10 months ago
I like Dockerfiles more than the next guy but you shouldn't need one in this case, nor should you need a guide since it should just work, would you mind opening up a new help post so we can try to debug what's misconfigured with your next app?
10 months ago
Sure, let me give it a try one more time, if it does not work. I will create thread.
10 months ago
@brody: Quick Update, I have purchased Pro Plan (Cancelled) Hobby. Once I used Singapore Region for my API service, API started to respond quickly. Thank you for the help.
P.S. I will create another thread for DB, wanted to understand how secure it is and do we have other feature such DR n all
Status changed to Awaiting Railway Response railway[bot] • 10 months ago
Status changed to Solved brody • 10 months ago