Jump to content

Script Works on VPS but not on Dedicated Server


soma56

Recommended Posts

This is mind bender. I recently upgraded from a VPS to a Dedicated server. The script is a data mining tool that primarily uses cURL. It worked flawlessy on the the VPS. Because it was the same hosting company everything was migrated and done so smoothly to the new dedicated.

 

Now, the program hangs for no reason at all. The times vary but I'll usually get about an hour of the script before it hangs. It used to run for hours at a time on the VPS.

 

While I do see some 'notices' and cURL timeouts - there are no error messages echoed out when the program hangs and there is nothing within the error log on the server to indicate anything in terms of why. The program simply 'freezes'.

 

I think I've spent the last three days modifying the php.ini file. Here are some settings which may be of interest?

 

post_max_size = 16M

log_errors = On

max_execution_time = 0; (From what I understand is unlimited).

max_input_time = 0 ;

memory_limit = 128M;

 

At the top of every page within my script:

 

set_time_limit(0);

error_reporting(E_ALL);

 

The dedicated is an 8 gig Linux box running Apache. Speaking of which, here are some settings within WHM for Apache:

 

Max Clients 500

Max Requests Per Child - 0 (unlimited)

Keep-Alive - On

Keep-Alive Timeout - 50

Max Keep-Alive Requests - Unlimited

Timeout - 1000

 

Because the script works on another VPS that I have within the same hosting company can someone direct me with what I should be looking for and/or comparing between both servers?

 

What are the most common reasons for a PHP script to freeze from a server setting standpoint?

 

 

Link to comment
Share on other sites

max_execution_time = 0   

max_input_time = 0

memory_limit = 512M 

output_buffering = 1024

implicit_flush = On

 

Nothing. Still freezing. I thought upgrading to an additional 6 gigs of ram on a dedicated would be a good thing. The mystery is that there is no errors reported back.

 

VPS > Script executes and runs flawlessly

 

Dedicated > Freezes for no reason at all after about an hour

 

My next steps:

 

I'm reviewing the differences between the htaccess file, php.ini file and Apache settings within WHM to see if I can match the VPS to the dedicated.

 

Hostings next steps:

 

They're reverting the PHP version from 5.2.9 to 5.2.17 on the dedicated server to match the same version on the VPS.

 

This is a total mind f#$... :confused:

 

Suggestions and sympathies welcome...

Link to comment
Share on other sites

How are you running this script?    If this is a crawler/scraper that you intend to run for hours then you should be running it as a cli script, and not through apache.  As such your apache settings are not a factor and you may need to be editing a different php.ini.  Run php -i | grep php\.ini at a command line to find the location of the right file for cli.

 

If you are running it via cli, when it freezes use a tool like top to see what is going on.  Check how much memory and cpu it is using, see what state it is in.

 

You should probably get your PHP updated to 5.3.x, it's been the latest for quite a while now.

 

Link to comment
Share on other sites

How are you running this script?    If this is a crawler/scraper that you intend to run for hours then you should be running it as a cli script, and not through apache.

 

Perhaps, however, it runs flawlessly on the same hosting companies VPS and I don't know the first thing about cli.

 

Could you show your site's Apache config file ? I suppose you have a low level of warnings in your site_error.log ?!

 

Is this what you mean?...

 

Server Limit 1000

Max Clients 500

Max Requests Per Child - 0 (unlimited)

Keep-Alive - On

Keep-Alive Timeout - 50

Max Keep-Alive Requests - Unlimited

Timeout - 1000

 

You should probably get your PHP updated to 5.3.x, it's been the latest for quite a while now.

 

I'm spent and I'm tired of my heart palpitating and cramping because of this. It's been a week and I think I've changed just about every php.ini, hta and apache setting there is.

 

I'm going to ask the hosting company to upgrade to the latest version of PHP to see if that solves the issue but something tells me I'm just wasting my time.

Link to comment
Share on other sites

Perhaps, however, it runs flawlessly on the same hosting companies VPS and I don't know the first thing about cli.

 

Just because it might work under a specific configuration doesn't make it a good idea.  I wrote an IRC bot once, and sure it would work being run through apache, but it ties up apache worker processes and has a lot of additional unnecessary overhead.  The right way to run a long-running script is via CLI.

 

I'm assuming that you have SSH access.  Login via ssh and run the command:

php -i

 

To verify that you have a cli version of PHP installed.  If not, ask your host to install it (or do it yourself). 

 

 

Once verified, cd into the directory containing your crawler script and run the commands:

nohup php theCrawler.php >crawler.log 2>&1 &
disown

 

to start the process.  You can then logout of ssh and your script should be running.  Wait and see if you have the same problem or if it goes away.  You will be able to see the output (if any) of the process in a new file called crawler.log. You can monitor this file if desired by running:

tail -f crawler.log

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.