Server slowing, trying to figure out why - php includes
Posted: Tue Jun 21, 2011 8:14 pm
I have a blog network that is pretty connected, and possibly to a fault. Every time my traffic spikes to even mediocre numbers (50+ visitors at a time or so), my cpu spikes and the network crawls. I am checking out server issues, hardware, etc, but I am also looking to make sure my code is clean. I'm a huge php newbie.
My blogs are cached, but I noticed when I loaded it, my sidebar was a bit delayed, which made me wonder if php was an issue. Right now my sidebar is pretty "include-heavy", as I have quite a few php files I'll call cross server so I can quickly alter banners and what not.
Right now I'm using file_get_contents, and doing it like this (which I already realized is wrong)
I already see one problem that I'm opening and closing php like crazy, so I'll correct that. Another problem is I appear to be using the same variable.... now that I am learning php a bit, I would like to put this in the header:
Then on the sidebar call
I'm still not sure that would even help the situation at all, isn't there an easier include feature that doesn't put all the data into a variable before it's called? To me that seems to be the biggest strain right there.
Sorry if this is a dumb question.
My blogs are cached, but I noticed when I loaded it, my sidebar was a bit delayed, which made me wonder if php was an issue. Right now my sidebar is pretty "include-heavy", as I have quite a few php files I'll call cross server so I can quickly alter banners and what not.
Right now I'm using file_get_contents, and doing it like this (which I already realized is wrong)
Code: Select all
<?
$c = file_get_contents("http://www.url.net/includes/file1.php");
echo ($c);
?>
<?
$c = file_get_contents("http://www.url.net/includes/file2.php");
echo ($c);
?>
Code: Select all
$url1 = file_get_contents("http://www.url.net/includes/file1.php");
$url2 = file_get_contents("http://www.url.net/includes/file2.php");
Code: Select all
<?php echo $surl1 ?>
blah blah blogroll
<?php echo $url2 ?>
Sorry if this is a dumb question.