Welcome to Centmin Mod Community
Register Now

How to avoid downtime due to change of CPU and recompiling Nginx for a new Linode?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by vandelay, May 29, 2022.

Tags:
  1. vandelay

    vandelay New Member

    14
    0
    1
    Mar 4, 2019
    Ratings:
    +3
    Local Time:
    5:52 AM
    1.15.9
    Hi!

    Last time I was upgrading my Linode, I had to recompile my Nginx because of a different CPU and it caused significant downtime. I've been using Centmin for 5 years and I love it, but I'm not a sysadmin and I'm wondering if someone could point me in the direction of doing this as smoothly as possible?


    thanks,
    J
     
  2. eva2000

    eva2000 Administrator Staff Member

    48,899
    11,189
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,423
    Local Time:
    8:52 AM
    Nginx 1.21.x
    MariaDB 10.x
    Nice 5yrs :D

    The downtime was due to Linode CPU change and not Nginx recompile right? As Centmin Mod centmin.sh menu option 4 Nginx recompiles do not generally impact site downtime as the newly built Nginx binary is not switched over to until end of recompilation. So during recompile, your site will usually run fine with the existing/older Nginx binary.

    How old is your Centmin Mod installation and when was last time you updated it? Are you using 123.08stable, 123.09beta01, 124.00stable or 130.00beta01 versions ? If you're using 123.09beta01 and newer, running below command will list your version history
    Code (Text):
    cminfo versions
    

    For past 4yrs, Centmin Mod has had a march_hostcheck function (see Github blame here and commit here 4yrs old and latest for 124.00stable here) which handles some VPS hosts changing CPUs like linode and during initial Centmin Mod install or subsequent running of centmin.sh menu will auto add to persistent config file at /etc/centminmod/custom_config.inc the variable
    Code (Text):
    MARCH_TARGETNATIVE='n'

    This tells Centmin Mod to not compile Nginx and PHP-FPM with specific CPU native march optimizations for this very reason when VPS host nodes change CPUs and/or you move your VPS to a different VPS host node with a different CPU model.

    Now if your Centmin Mod install is >4yrs old, it might not have MARCH_TARGETNATIVE='n' but it would of been automatically added the next time you ran centmin.sh menu on an updated Centmin Mod installation that is at least 4yrs old.

    So in future, update to at least 124.00stable https://community.centminmod.com/threads/centmin-mod-124-00stable-130-00beta01-releases.22673/ and running centmin.sh menu once should apply MARCH_TARGETNATIVE='n' to your persistent config file at /etc/centminmod/custom_config.inc. So next time you recompile/update Nginx or PHP-FPM via centmin.sh menu option 4 or 5 respectively, will not compile with specific CPUs in mind but a general CPU march profile. So switching VPS host node CPUs should in theory not be an issue.

    You can verify your Nginx compilation via command
    Code (Text):
    nginx -V

    when compiled for specific CPU = -march=native
    when not compiled for specific CPU i.e. Linode VPS will have -march=x86-64
     
  3. vandelay

    vandelay New Member

    14
    0
    1
    Mar 4, 2019
    Ratings:
    +3
    Local Time:
    5:52 AM
    1.15.9
    wow thanks for the extensive answer. the downtime was both due to Linode being down (I don't mind, it's not that long), and me having to recompile Nginx.

    I've been upgrading the codebase and packages, Nginx, PHP monthly.

    I'm running 123.09beta01

    Code:
    nginx -V
    nginx version: nginx/1.21.6 (030422-134951-centos7-kvm-ff9de1e-br-9aec15e)
    built by gcc 10.2.1 20210130 (Red Hat 10.2.1-11) (GCC)
    built with OpenSSL 1.1.1n  15 Mar 2022
    TLS SNI support enabled
    configure arguments: --with-ld-opt='-Wl,-E -L/usr/local/zlib-cf/lib -L/usr/local/nginx-dep/lib -ljemalloc -Wl,-z,relro -Wl,-rpath,/usr/local/zlib-cf/lib:/usr/local/nginx-dep/lib -flto=2 -fuse-ld=gold' --with-cc-opt='-I/usr/local/zlib-cf/include -I/usr/local/nginx-dep/include -m64 -march=x86-64
    
    I've used Centmin before so 5 years is probably a bit more than the age of this server.

    I think before this upgrade it was compiled with the previous flag. thanks. I will update my Centmin anyway.
     
    Last edited: May 29, 2022
  4. eva2000

    eva2000 Administrator Staff Member

    48,899
    11,189
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,423
    Local Time:
    8:52 AM
    Nginx 1.21.x
    MariaDB 10.x
    Yes that should take care of this for the future :)