Is there ever an instance of catching a bad shared server?
thomas
HOBBYOP

a year ago

I have run multiple Django apps on Railway with PostgreSQL DBs. Never had an issue until this project. It has this terrible 2+ second TTFB on Chrome on every page. I've tried everything to reduce the load. The DB is incredibly small (still in testing mode) but I've set up a Redis cache anyway. I have static and media hosted on Google Cloud Storage with a CDN, I've optimized queries and indexed tables, deferred JS scripts and preloaded stylesheets, compressed JS, increased Gunicorn workers, and nothing is touching the initial response.

Could it be something with the machine I'm allocated to?

5 Replies

brody
EMPLOYEE

a year ago

Hello,

Looks like the problem is that you are connecting to the database over the public network, connecting via the private network is going to be significantly faster, along with there not being any egress fees on the private network.

Also, I highly recommend you run gunicorn with uvicorn workers instead of sync workers.

But look on the bright side of all you've done, your application is likely far more production ready than it was before!!


thomas
HOBBYOP

a year ago

Thanks for the suggestions, Brody! I implemented both of those changes and still no luck improving that time to first bite from the server. But I've definitely learned a lot along the way. slightly_smiling_face emoji I'll continue to dig.


brody
EMPLOYEE

a year ago

Just noticed your database is in US-West GCP but your app is in US-East Metal.

Service to Database communications are extremely sensitive to geographical distance.

Since you can't yet move the database to US-East metal (Metal doesn't support volumes yet) I would recommend you moving the app to US-West GCP.


thomas
HOBBYOP

a year ago

ok, thank you. I moved app to US-West and still seeing initial server response time of 2,110 ms. If everything is looking good on the server, my next step is to hire someone to review the code.


brody
EMPLOYEE

a year ago

Next step, add tracing so you can find out what piece of code is being slow.


Loading...