Connecting Tech Pros Worldwide Forums | Help | Site Map

Big array, a big problem?

Steve
Guest
 
Posts: n/a
#1: Jul 17 '05
I've a question regarding a bit of code I have. On my site I have a
set of semi-static data (changes once a month or so) that needs to be
displayed in various places around the site and integrated with
dynamic data being fed in from a MySQL database.

At the time of development I chose to put this semi-static data in to
an array and include() it where required. However, the array is now
getting quite big. It has 1200 entries of the form:

$myArray["item1"]["Property 1"] = "Value 1";
$myArray["item1"]["Property 2"] = "Value 2";
$myArray["item1"]["Property 3"] = "Value 3";
$myArray["item1"]["Property 4"] = "Value 4";
$myArray["item1"]["Property 5"] = "Value 5";
$myArray["item1"]["ArrayProperty"][] = "Other Value 1";
$myArray["item1"]["ArrayProperty"][] = "Other Value 2";
$myArray["item1"]["ArrayProperty"][] = "Other Value 3";
$myArray["item1"]["ArrayProperty"][] = "Other Value 4";

The PHP file it is in weighs in at 550KB and is used in most of the
custom data driven pages I have.

My question is how much of an effect will this design choice have on
the performance of my Linux/Apache/PHP/MySQL server that is running on
a Celeron 1.7Mhz/512MB machine?

My site is fairly busy with over 300 concurrent users at peak times
and I am currently experiencing high loads during these peak times. I
disabled the sections of the site that use this file during a peak
time and found the load to be a lot better. However, there are other
things within these sections that could be causing high loads - I
would just like to rule this out as a possibility.

Thanks for any advice you can give,

Steve

Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Big array, a big problem?


Steve wrote:
(snip)[color=blue]
> The PHP file it is in weighs in at 550KB and is used in most of the
> custom data driven pages I have.
>
> My question is how much of an effect will this design choice have on
> the performance of my Linux/Apache/PHP/MySQL server that is running on
> a Celeron 1.7Mhz/512MB machine?
>
> My site is fairly busy with over 300 concurrent users at peak times
> and I am currently experiencing high loads during these peak times. I
> disabled the sections of the site that use this file during a peak
> time and found the load to be a lot better. However, there are other
> things within these sections that could be causing high loads - I
> would just like to rule this out as a possibility.
>
> Thanks for any advice you can give,[/color]

I think that the worse for performance your current setup causes is due
to opening (and closing) of the include file. Perhaps you can put that
file in a ramdisk (at system startup?); and then include it from there.
<?php include '/ramdisk/php/static_data.inc.php'; ?>

I don't think there should be any problem for PHP to handle that amount
of data (as long as you have RAM; 300 * 550K ~= 165M).
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Chung Leong
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Big array, a big problem?


Try serializing the array and saving it into a text file. Deserialization
should be faster than PHP code parsing.

Uzytkownik "Steve" <stephenmcnabb@yahoo.co.uk> napisal w wiadomosci
news:9b1a4bb8.0401200836.cea86ba@posting.google.co m...[color=blue]
> I've a question regarding a bit of code I have. On my site I have a
> set of semi-static data (changes once a month or so) that needs to be
> displayed in various places around the site and integrated with
> dynamic data being fed in from a MySQL database.
>
> At the time of development I chose to put this semi-static data in to
> an array and include() it where required. However, the array is now
> getting quite big. It has 1200 entries of the form:
>
> $myArray["item1"]["Property 1"] = "Value 1";
> $myArray["item1"]["Property 2"] = "Value 2";
> $myArray["item1"]["Property 3"] = "Value 3";
> $myArray["item1"]["Property 4"] = "Value 4";
> $myArray["item1"]["Property 5"] = "Value 5";
> $myArray["item1"]["ArrayProperty"][] = "Other Value 1";
> $myArray["item1"]["ArrayProperty"][] = "Other Value 2";
> $myArray["item1"]["ArrayProperty"][] = "Other Value 3";
> $myArray["item1"]["ArrayProperty"][] = "Other Value 4";
>
> The PHP file it is in weighs in at 550KB and is used in most of the
> custom data driven pages I have.
>
> My question is how much of an effect will this design choice have on
> the performance of my Linux/Apache/PHP/MySQL server that is running on
> a Celeron 1.7Mhz/512MB machine?
>
> My site is fairly busy with over 300 concurrent users at peak times
> and I am currently experiencing high loads during these peak times. I
> disabled the sections of the site that use this file during a peak
> time and found the load to be a lot better. However, there are other
> things within these sections that could be causing high loads - I
> would just like to rule this out as a possibility.
>
> Thanks for any advice you can give,
>
> Steve[/color]


Closed Thread