Decaflon

Welcome to Decaflon! Where the geeks hang out: Signup or Login Here
Decaflon is proudly hosted by (mt) Media Temple.  We recommend them for your web hosting needs.
Clips: Popular Clips Upcoming Clips Notes: All Notes

I can't mention the parties involved here but my employer is having a hell of a time with their hosting company and since I'm the lone developer, I have to figure out the right solution.

We were moved to a new server last week because the old server we were on was occasionally crashing, more than once each week. The host said it had hard drive issues so they moved the sites. This server has 3 sites that all receive very high traffic.

Since we moved we started seeing issues with the sites running slow. There were lots of things that happened during this time so it's hard to tell exactly where the problem was. I'll try and lay out the different issues:

- one of our sites doubled in traffic. it is a PHP/MySQL site and has zero caching. It was developed externally and I told the developers to cache the pages. It should be done by next week.

- we moved to a new advertising service and to make the management of adds easy, I wrote some scripts with PHP to use a MySQL database and serve up the ads. At first this slowed the server down a lot so I cached all the scripts so that they wouldn't have to do any queries. These files currently look like this:

<?php
if(file_exists...)
include('xxx');
exit;
?>

2 of our sites use these scripts, they make up about 80% of the traffic.

- I added a feature to one of the sites that meant an extra database request on some of the highest-traffic pages for that site. We then had some issues with performance so as an extra measure I implemented Perl's MemoryCache module (this is a Perl/MySQL site). So I was caching some of the results of various functions in memory and these caches were set to last for an hour. I was also auto-purging every hour.

Last Monday our server had 1 gig of RAM. the host recommended we increase that... now we have 3 gigs. We were at 90% memory consumption when we had 1 gig. Today, with 3 gigs, we suddenly hit 99% consumption. The sites have been slow all day.

In the morning the host was saying that it was MySQL eating up all the memory. In the afternoon, however, they said we had too many PHP and CGI processes running. They recommended upgrading to a server with a more powerful CPU.

I can't do much on my end to verify any of this because we have a "managed" dedicated server, which means I can't do much on the command-line. It's very frustrating, and the host's support is not very good.

So, um, what do I do? Is this thing about the PHP/CGI processes really true? I know the server doesn't have a very good setup (no FastCGI). Would changing the ad system to use static HTML files improve things (since most pages have on average, 3 iframes, each running a separate PHP file)? Should I just assume that our host is problematic and look for hosting elsewhere (I'm leaning toward this right now)? At least if we were on a better server with root access, I could setup PHP/CGI better and get more performance.

I'm just looking for any advice here... this whole mess is keeping me from doing *real* work.

p.s. this is an Apache Linux server.

username Zoom

Written Oct. 18, 2007 / Edit / Report /

So, you have a run-time problem under load but your hosting company is not willing/able to provide debugging support? At the risk of stating the obvious, without low-level (ie: command-line) access to the server, there's really no hope of debugging/optimizing this. If you have the time/knowledge, I'd move to a virtual host setup and manage the sites yourself.

So, um, what do I do?

Find a new host.

Is this thing about the PHP/CGI processes really true

It could be.

Would changing the ad system to use static HTML files improve things (since most pages have on average, 3 iframes, each running a separate PHP file)?

It depends if the ad system is where the bottle-neck is.

Should I just assume that our host is problematic and look for hosting elsewhere

Either the hosting is problematic or your PHP/Perl/SQL coding is crap. You choose.

jsmart: That's what I'm beginning to think... I want to get my employer off this "managed ds" crap and get a server with root access so I can figure out what the problems are and do some optimizations on the setup.

The host said that the scripts consuming the most memory are the ones making MySQL queries, but I'm thinking it's just a combination of things.

Also, I know the PHP/Perl/SQL coding is crap... I didn't write it. I just started working here so I "inherited" all this legacy code and it's terrible stuff. I want to update all the code but that would take months. Plus, these sites were working fine yesterday so that's why I am very suspicious about the whole thing.

Here's to the possibility that we'll be using a new host soon =/

Ha, update: I just discovered that our 2 MySQL databases didn't have any indexes. Considering that all the queries we ever do are of the form:

SELECT ... FROM ... WHERE field = 'unique constant'

That's kind of a big deal.

Anyway, they have indexes now.

That's a big one, that probably solved most everything, no?

Another thing to look out for are pages that get reloaded very frequently. I had one site on my server that was using a shoutbox, despite the file and db interaction being pretty quick and clean, if it was set to refresh at 3 seconds it drove the server load up enormously. At 5 seconds I can't tell it's even running.

Ozone: That's not an issue here, but I know what you mean.

The sites are doing much better today, which I'm guessing might be a combination of the MySQL indices and some caching that's being added.

I also discovered that PHP & Perl are running as CGI, *just* CGI, so I'm having Fast CGI installed. Can't believe it wasn't already there. That should double the speed alone.

Please Login To Leave A Comment

Decaflon Sponsors Get in touch if you want in.

Hot Notes (View all »)

 

Decaflon is part of the Chawlk Network of sites.

9 Great Places To Visit, Hang Out, & Meet New People

What's new and interesting at other Chawlk Network sites: