paic Posted 8 hours ago Posted 8 hours ago Hello Support ! The endpoint on the Python backend of my project does some heavy data processing. Sometimes resulting in very long response time >1min depending on the data input. This result in the connection being "timed out" by nginx. Also when this happens it sometimes restart the server. These are the errors I get: upstream timed out (110: Connection timed out) while SSL handshaking to upstream peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream Would it be possible to change the default timeout setting and prevent restarting the server when it happens ? 180s would be enough. I've read it can be done with the following settings. proxy_connect_timeout 180s; proxy_send_timeout 180s; proxy_read_timeout 180s; fastcgi_send_timeout 180s; fastcgi_read_timeout 180s; Domain: grafolana.helioho.st Thank you, Regards Quote
wolstech Posted 7 hours ago Posted 7 hours ago This would be up to Krydos. We typically limit script runtimes to prevent users from using more than their fair share of resources and causing high load, so it's quite possible (if not likely) the answer will be no, in which case the solution will be to rewrite your code. You could either make it more efficient, or you could do the work in multiple smaller batches that finish in less than 60 seconds. Your account shows 0 load over the last 24 hours though, so I don't have any data to look at... Quote
paic Posted 7 hours ago Author Posted 7 hours ago I understand that the answer could be no and that would be totally reasonable. I was expecting to see some data in the "Account Load" dashboard but yeah it still shows 0. That would actually help address the impact my script has on the server. Maybe there is actually an issue with the memory and the CPU usage report for my server ? Quote
paic Posted 5 hours ago Author Posted 5 hours ago (edited) I whish I could make it more efficient .. It's already heavily optimized. The script's bottleneck is actually not the CPU but the external API it's calling repeatedly, which has quite a slow rate limit.. CPU processing time in the most unseen extreme cases will be like 20sec, but is usually between 1-8 seconds. Edited 5 hours ago by paic Quote
Krydos Posted 3 hours ago Posted 3 hours ago 5 hours ago, paic said: This result in the connection being "timed out" by nginx. Also when this happens it sometimes restart the server. You're not causing Nginx to restart. Nginx restarts hundreds of times per day on its own. Each time some domain gets SSL. Each time a new account is created. Each time an account goes inactive. Each time an account gets unarchived. There are tons of reasons for Nginx to restart, so if your code can't handle an Nginx restart, increasing the timeout isn't going to help and you need to get a VPS. Quote
paic Posted 2 hours ago Author Posted 2 hours ago (edited) Thanks for your answer ! Ok, then that was a really strange coincidence that every timeout was followed by a restart 😃 It's not happening again so I was wrong on that ! My code can handle Nginx restart as in it won't break anything, just cancel the current request.. I can deal with occasional restarts as they look like quite fast and seamless. And my project is just a developement demo.. So is it possible to increase the timeout ? Edited 2 hours ago by paic Quote
Krydos Posted 1 hour ago Posted 1 hour ago 19 minutes ago, paic said: So is it possible to increase the timeout ? No. That's why I suggested switching to a VPS. Another option is you can switch to Python CGI instead of Flask. The timeout on CGI can be increased if you need it. Quote
paic Posted 1 hour ago Author Posted 1 hour ago OK, I see.. I guess I need to find a better way to handle my processing or switch to a VPS. I wish I would have known about all that before ! Well, I guess I still have a free hosting for life 😃 Thanks for your support anyway Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.