preventing system crashes

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

    preventing system crashes

    Hi,

    I made a mistake in a script that completely froze my linux-based server:

    I passed an array instead of a number to a function like:

    function plg_ratingimg($ rating)
    {
    global $plug_picrank;
    for ($i=0;$i<$ratin g;$i++)
    {
    $out.=$plug_pic rank;
    }
    return $out;
    }

    where $plug_picrank is a simple HTML string.

    Where is the weakness in the apache or php setup that something like this
    can freeze the server?

    thanks

    Oliver

  • Erwin Moller

    #2
    Re: preventing system crashes

    Oliver Spiesshofer wrote:
    [color=blue]
    > Hi,
    >
    > I made a mistake in a script that completely froze my linux-based server:
    >
    > I passed an array instead of a number to a function like:
    >
    > function plg_ratingimg($ rating)
    > {
    > global $plug_picrank;
    > for ($i=0;$i<$ratin g;$i++)
    > {
    > $out.=$plug_pic rank;
    > }
    > return $out;
    > }
    >
    > where $plug_picrank is a simple HTML string.
    >
    > Where is the weakness in the apache or php setup that something like this
    > can freeze the server?
    >
    > thanks
    >
    > Oliver[/color]

    Hi Oliver,

    Are you sure it is a systemcrash?
    I think only PHP stops responding untill the scripttimeout time has elapsed.

    When I had a similar situation (a very long calculation) ONLY scripts on
    that site stopped responding.
    Apache just neatly continued to serve other sites.

    Solution? I don't know. Write better scripts? :P

    Regards,
    Erwin Moller

    Comment

    • Oliver Spiesshofer

      #3
      Re: preventing system crashes

      Erwin Moller
      <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote in
      news:420742db$0 $28989$e4fe514c @news.xs4all.nl :
      [color=blue]
      >
      > Hi Oliver,
      >
      > Are you sure it is a systemcrash?
      > I think only PHP stops responding untill the scripttimeout time has
      > elapsed.[/color]

      No it doesnt, strange enough.
      FTP and SSH to the machine dont work anymore either "Connection refused"...

      Oliver

      Comment

      • Jerry Sievers

        #4
        Re: preventing system crashes

        Oliver Spiesshofer <oliver@email.c om> writes:
        [color=blue]
        > I made a mistake in a script that completely froze my linux-based server:
        > I passed an array instead of a number to a function like:
        >
        > function plg_ratingimg($ rating)
        > {
        > global $plug_picrank;
        > for ($i=0;$i<$ratin g;$i++)
        > $out.=$plug_pic rank;[/color]

        Assuming this thing iterated a bazillion times, at least during the
        PHP configured max script execution time, it busied the CPU to 100%
        and also consumed a huge amount of memory.

        Not sure if your PHP might be configured to have large amount of
        memory available but a runaway loop like this can certainly cause a
        server to THRASH, though probably not crash (as you have suggested).

        Suspect the memory use put you over the acceptable paging limit for
        this box.

        Why don't you log into the machine interactively with telnet, SSH or
        similar, run the defective PHP script and see what happens. Does your
        Linux panic and halt? Or does the machine just go catatonic for a
        while.

        Can you see the machine physically and check for excessibe disk
        activity which would indicate rapid paging.

        If the interactive session does continue to respond, top, vmstat and
        various other diagnostic tools can help you learn what's really
        happening.

        HTH

        --
        -------------------------------------------------------------------------------
        Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
        305 321-1144 (mobile http://www.JerrySievers.com/

        Comment

        • Erwin Moller

          #5
          Re: preventing system crashes

          Oliver Spiesshofer wrote:
          [color=blue]
          > Erwin Moller
          > <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote in
          > news:420742db$0 $28989$e4fe514c @news.xs4all.nl :
          >[color=green]
          >>
          >> Hi Oliver,
          >>
          >> Are you sure it is a systemcrash?
          >> I think only PHP stops responding untill the scripttimeout time has
          >> elapsed.[/color]
          >
          > No it doesnt, strange enough.
          > FTP and SSH to the machine dont work anymore either "Connection
          > refused"...
          >
          > Oliver[/color]

          Oops... That IS bad, Oliver.

          I suggest you try Jerry Sievers suggestions in the other thread.

          Login and see what the machine is doing.
          'top' is a quick way to see what takes up the CPU time.

          As far as I know, this shouldn't be possible...
          Did you configure the machine yourself?
          If it is at some provider (shared), ask them. :P

          Regards,
          Erwin Moller

          Comment

          Working...