Jump to content


Photo

Maximum Perl Script Execution Time On Shared Hosting?


  • Please log in to reply
3 replies to this topic

#1 SteveW

SteveW

    Distant Family

  • Members
  • PipPipPip
  • 129 posts

Posted 06 December 2010 - 04:10 PM

My script tracks its execution time and quits if a specified time limit is reached.

It's currently limited to 1 second, which seems safe enough for testing but might not be sufficient later.

At what point would I be impacting server performance?

Maximum execution time for PHP scripts appears to be 30 seconds by default, but is that pushing the limit of what's acceptable?

It's also configured so that when one instance of the script starts running, it creates a flag file that prevents any other instances from being launched until it finishes.

#2 TCH-Bruce

TCH-Bruce

    Volunteer Moderator

  • Members
  • PipPipPipPip
  • 19,960 posts

Posted 06 December 2010 - 05:54 PM

Steve, only the techs would be answer this one. I would think anything less than 30 would be fine.

Bruce Richards
Forum Moderator
TotalChoice Hosting, Inc.
Webhosting by Total Choice Web Hosting - General Support Forum

I am a Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.


#3 TCH-Alex

TCH-Alex

    Technical Support

  • Staff
  • PipPipPipPip
  • 664 posts

Posted 06 December 2010 - 06:17 PM

The maximum execution time is set to 30 seconds by default configuration, you can run the php script to this time. However, please note that the usage of server resource (cpu, memory) are more sensitive than maximum execution time. Also, you can change the maximum execution time of a php file with the keyword set_time_limit() inside the script or setting max_execution_time on .htaccess or local php.ini file

Alex Spaford
Technical Support
TotalChoice Hosting, Inc.
Total Choice Hosting - Helpdesk


#4 SteveW

SteveW

    Distant Family

  • Members
  • PipPipPip
  • 129 posts

Posted 07 December 2010 - 09:43 AM

Time/CPU/Memory were all things I'm concerned about, but time is the only one I currently know how to measure and control.

I'm assuming the techs won't be shy about disabling the script and informing me if it causes any problem.

In case it's any use to someone in the future, this is how I make the script time itself out instead of waiting for the system to do it:

my $maxseconds = 1;		# time limit in seconds. 0=no limit. 
my $starttime = time();		# Now, reference time.
my $timedout = 0;		# bool flag.
my $elapsed = 0;		# elapsed time.

# Inside a loop, the program accumulates output over multiple levels of processing.
# If processing exceeds the time limit before finishing the task, it exits the loop,
# but the script will still go on to print whatever output it has.
# The task is able to partially or mostly complete, less disruptive than
# if the system forcibly terminates it (?).

for(something)
{
	do_something();

	if($maxseconds > 0)
	{
		$elapsed = time() - $starttime;
		if($elapsed > $maxseconds)
		{
			$timedout = 1;
			last;
		}
	}
}

print("$output\n");

if($timedout)
{
	print("\nOutput is partial due to time limit exceeded.\n");
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users