Learn about Centmin Mod LEMP Stack today
Become a Member

Nginx Throttle Offline

Discussion in 'Feature Requests & Suggestions' started by Jimmy, Aug 2, 2020.

  1. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    11:44 AM
    Sometimes my site gets attacked and to take some of the pressure off I just do a "sitestatus offline" and it serves the html page which is an easy handle for the server.


    Would it be possible or make sense to have the "sitestatus offline" trigger at a certain CPU threshold set in the conf file?

    1. Set CPU TOP threshold in config file. CPU percent when script is triggered.
    2. Site / server gets attacked or just flooded with requests it can't handle.
    3. CPU hits a CPU TOP threshold from the config.
    4. "sitestatus offline" is activated.
    5. Set CPU LOWER threshold (in #1 but here for the list) in the config.
    6. CPU hits the LOWER threshold.
    7. "sitestatus online" is activated.

    The CPU TOP is where the script is triggerd. CPU LOWER allows the owner to decide at which point the sitestatus online is triggered.

    The script could keep going off and on for as long as needed. Would be great for smaller sites which can't afford paid plans. A down and dirty simple technique. Doesn't solve the overall problem but could save someone like me from getting throttled by SSDnodes. I'm sure other people are having the same thing happen when the CPU pegs.

    Plus when a background task runs for backup it pegs the processor on my throttled SSDNodes machine. During those times, putting the server in offline makes the process go faster. Meaning, the server sites are offline for a little bit vs. slow for a long time.

    Just an idea.
     
    Last edited: Aug 2, 2020
  2. eva2000

    eva2000 Administrator Staff Member

    54,368
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    2:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Interesting, never really intended for Centmin Mod 123.09beta01 or higher's sitestatus maintenance mode (Beta Branch - sitestatus maintenance mode) to be used that way. But guess it can work nicely in such cases :)

    @Rake-GH wrote a Cloudflare I am underattack script which is based on cpu load but I posted some comments as to why using system cpu load might not be accurate at cfautouam - CloudFlare Under Attack Mode Automation as cpu load system wide can be triggered by non-http requests i.e. backup scripts etc. So I commented that you can base cpu load only on nginx and/or php-fpm based cpu load via pidstat command

     
  3. eva2000

    eva2000 Administrator Staff Member

    54,368
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    2:44 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Guess that would be one case for system cpu load heh but then you can do the same for pidstat on mysql load like I outlined for nginx and php-fpm pidstat derived cpu loads.