Long running routine x time out

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, dam-man

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
RSLyra
Joomla! Intern
Joomla! Intern
Posts: 89
Joined: Fri Oct 08, 2010 6:19 pm
Location: Brasilia, Brazil
Contact:

Long running routine x time out

Postby RSLyra » Fri Mar 17, 2017 7:07 pm

I had two long running routines. One recover data from 500 public servants, the other many government pages to verify which one is using CMS.

Until last December, everything was allwright. But I decided to change the host, and then I got this:

"Gateway Timeout
The gateway did not receive a timely response from the upstream server or application."

I don't want to come back to my old host, and the new one said that I need to change to a bigger and expensive plan to change settings like timeout, waht is not a option either.

I tried flush() and ob_flush(), nothing changed.
Last edited by imanickam on Mon Mar 20, 2017 3:27 am, edited 1 time in total.
Reason: Moved the topic from the forum General Questions/New to Joomla! 3.x to the forum Joomla! 3.x Coding

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 32680
Joined: Sat Apr 05, 2008 9:58 pm

Re: Long running routine x time out

Postby Webdongle » Sat Mar 18, 2017 9:41 pm

You get what you pay for

RSLyra
Joomla! Intern
Joomla! Intern
Posts: 89
Joined: Fri Oct 08, 2010 6:19 pm
Location: Brasilia, Brazil
Contact:

Re: Long running routine x time out

Postby RSLyra » Sun Mar 19, 2017 12:22 am

Thanks. Very helpfull.

User avatar
ranwilli
Joomla! Master
Joomla! Master
Posts: 18901
Joined: Sun Feb 19, 2006 6:47 pm
Location: Toledo, OH
Contact:

Re: How to do a long time running routine?

Postby ranwilli » Sun Mar 19, 2017 11:36 pm

Talk to your host...
Last edited by imanickam on Mon Mar 20, 2017 3:25 am, edited 1 time in total.
Reason: Merged the responses with the topic f=706&t=948170
Don't HACK the Joomla! core. Extend and Override.
Stay ON the update path.
http://harpervance.com

User avatar
toivo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8306
Joined: Thu Feb 15, 2007 5:48 am
Location: Nottingham, UK
Contact:

Re: How to do a long time running routine?

Postby toivo » Mon Mar 20, 2017 12:16 am

You can use the sleep() function every now and then in your script to give slices of CPU time to other processes.

Ref. http://php.net/manual/en/function.sleep.php
Toivo Talikka, Global Moderator
my first programs were assembled and run in 16KB :)
http://archive.computerhistory.org/resources/text/GE/GE.GE-115SystemSoftware.1967.102646096.pdf#zoom=100

RSLyra
Joomla! Intern
Joomla! Intern
Posts: 89
Joined: Fri Oct 08, 2010 6:19 pm
Location: Brasilia, Brazil
Contact:

Re: Long running routine x time out

Postby RSLyra » Mon Mar 20, 2017 11:31 am

Hi Toivo.

My problem is to not publish anything in a long time, so I got a Timeout.

So, sleep() is not the point.

And memory don't look to be the problem.

Tahnks

User avatar
toivo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8306
Joined: Thu Feb 15, 2007 5:48 am
Location: Nottingham, UK
Contact:

Re: Long running routine x time out

Postby toivo » Mon Mar 20, 2017 12:17 pm

If your script takes a long time to run in general, the sleep() function effectively prevents timeouts caused by the script exceeding the processing time limit in PHP, set by the directive max_execution_time in php.ini, over which you do not have any control in a shared server environment.

On the other hand, if your script has to wait for a response from another server and the response takes a long time or never arrives, it is up to the developer to configure the call making the request with proper timeouts and then do the error handling, including retries, where the sleep() function could also be useful.
Toivo Talikka, Global Moderator
my first programs were assembled and run in 16KB :)
http://archive.computerhistory.org/resources/text/GE/GE.GE-115SystemSoftware.1967.102646096.pdf#zoom=100

RSLyra
Joomla! Intern
Joomla! Intern
Posts: 89
Joined: Fri Oct 08, 2010 6:19 pm
Location: Brasilia, Brazil
Contact:

Re: Long running routine x time out

Postby RSLyra » Mon Mar 20, 2017 12:40 pm

"another server response" is just the case.

I scrap site to get information. One routine collect information about 500 public servants. The other open 1600 government sites (pages) to check if they are using some kind of CMS.

RSLyra
Joomla! Intern
Joomla! Intern
Posts: 89
Joined: Fri Oct 08, 2010 6:19 pm
Location: Brasilia, Brazil
Contact:

Re: Long running routine x time out

Postby RSLyra » Mon Mar 20, 2017 12:47 pm

But I will do a small test with sleep().

RSLyra
Joomla! Intern
Joomla! Intern
Posts: 89
Joined: Fri Oct 08, 2010 6:19 pm
Location: Brasilia, Brazil
Contact:

Re: Long running routine x time out

Postby RSLyra » Mon Mar 20, 2017 1:03 pm

Sleep didn't work.


Return to “Joomla! 3.x Coding”

Who is online

Users browsing this forum: No registered users and 2 guests