#Application failed to respond | Server Error | Postgres | Python

38 messages · Page 1 of 1 (latest)

desert turtleBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

quasi knotBOT
#

Project ID: b62b596e-1a25-4559-a32c-c74d00634378

neon veldt
#

how long would you expect the api call to take?

#

the default gunicorn timeout is 30 seconds, could you be running into that?

fast spade
#

I'd say about five minutes...

neon veldt
#

is this a post or get request?

fast spade
#

post

neon veldt
#

and how long does the request fail after

fast spade
#

after 15 or 20 seconds

#

I need the server to wait much longer until all the items are changed, and not give this error.

neon veldt
#

railway has a 5 minute time limit on post requests (you cant change this), and gunicorn has a 30 second time limit on any request (can be changed)
but if you say your requests are failing after 20 seconds, you arent running into any of those limits

#

is there anything in the deployment logs that could be useful?

fast spade
#

Locally, even if I have to import a lot of items into the database, or change them, it works smoothly. But you mentioned two possibilities. I think it could be gunicorn, because I use it as a manager.

neon veldt
fast spade
neon veldt
#

but you said the request fails after 20 seconds? was that just a guess?

fast spade
#

Well, thank you. I'll implement it and let you know if it worked or not. Thank you, Brody.

fast spade
neon veldt
#

gotcha

fast spade
#

Brody, this worked more or less well.
I did this in my Procfile and I don't used the domain recorded in Cloudflare:

web: python manage.py migrate && gunicorn myapp.wsgi --log-file - --timeout 600

Now the request wait 5 minutes. After this I get this page. You sad that Railway has a 5 minute time limit on post requests... Can you tell me where can I change it, please?

neon veldt
fast spade
neon veldt
#

no

neon veldt
fast spade
#

Sorry. I understand.

#

In that case, is there anything I can do?

#

The connection between Django/Python seems to be a bit slow with Postgres.

neon veldt
#

write more efficient sql queries?

#

10k rows doesnt seem like a lot in the grand scheme of things, and 5 minutes for that seems like you are running into inefficiencies in your code

fast spade
neon veldt
#

fair enough, django is not known for speed

fast spade
neon veldt
#

what does this post request do?
when will you typically need to make this post request?
tell me as much information about this task as you can

fast spade
#

I have some tables in my database. One of them consists of more than 100k registered products, and the other is a table of government product codes. And when there is a change in the code description, this change should replicate to all the products in the product database. Normally there aren't so many products linked to a single code, but there are about 7 that have about 12k products linked, in which case the timeout exceeds the limit and doesn't change them.

neon veldt
#

then you would want to do this as a background task when data is changed, not through a post request, and especially not holding up the post request response

fast spade
#

That's a good suggestion. I'll see about background tasks with Django.

#

Many thanks again for your help, Brody.