Big array, a big problem?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    Big array, a big problem?

    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"]["ArrayPrope rty"][] = "Other Value 1";
    $myArray["item1"]["ArrayPrope rty"][] = "Other Value 2";
    $myArray["item1"]["ArrayPrope rty"][] = "Other Value 3";
    $myArray["item1"]["ArrayPrope rty"][] = "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

    #2
    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 =--

    Comment

    • Chung Leong

      #3
      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.0 401200836.cea86 ba@posting.goog le.com...[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"]["ArrayPrope rty"][] = "Other Value 1";
      > $myArray["item1"]["ArrayPrope rty"][] = "Other Value 2";
      > $myArray["item1"]["ArrayPrope rty"][] = "Other Value 3";
      > $myArray["item1"]["ArrayPrope rty"][] = "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]


      Comment

      Working...