1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Auto restart Apache if the load is higher than x

Discussion in 'Blogging' started by HatUser, Jan 30, 2014.

  1. HatUser

    HatUser Newbie

    Joined:
    Jan 11, 2014
    Messages:
    4
    Likes Received:
    0
    Hi there,

    My VPS get high load quite frequently and the best temporary option is a script that check the load periodically and if the load is bigger than 5 (for example), auto restart the apache server.

    Can anyone help me?

    Thank you!
     
  2. tophi

    tophi Regular Member

    Joined:
    Sep 7, 2012
    Messages:
    402
    Likes Received:
    72
    I suggest you moving to Nginx, that solved ALL my problems last 2 years. Forget apache, is a history from the dark ages. More and more high volume websites are using nginx because of this reason.
     
  3. innozemec

    innozemec Jr. VIP Jr. VIP

    Joined:
    Aug 19, 2011
    Messages:
    5,288
    Likes Received:
    1,799
    Location:
    www.Indexification.com
    Home Page:
    restarting apache is probably the worst scenario you can pick. When apache is started it will get overloaded quickly due to the tons of new requests in short time. Best look how to optimize your site and make the things that cause the load less stressfull. Also consider the possibility to upgrade your VPS with more resources
     
  4. HatUser

    HatUser Newbie

    Joined:
    Jan 11, 2014
    Messages:
    4
    Likes Received:
    0
    Is a temporary solution during I re-make the website (this time more optimized).I found this script on internet:#!/bin/shcheck=`uptime | sed 's/\./ /' | awk '{print $10}'`if [ $check -gt 5 ]then/etc/init.d/apache2 restartfiI will love to talk with somebody that know to handle these things before install it on my VPS.Thank you!