Welcome to Centmin Mod Community
Become a Member

Nginx Throttle Offline

Discussion in 'Feature Requests & Suggestions' started by Jimmy, Aug 2, 2020 at 6:54 PM.

  1. Jimmy

    Jimmy Well-Known Member

    1,704
    365
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +923
    Local Time:
    3:37 PM
    1.17.x
    MariaDB 10.3.x
    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 at 7:00 PM
  2. eva2000

    eva2000 Administrator Staff Member

    44,684
    10,193
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,792
    Local Time:
    5:37 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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

    44,684
    10,193
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,792
    Local Time:
    5:37 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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.