Learn about Centmin Mod LEMP Stack today
Become a Member

My optimized settings for centminmod (high traffic)

Discussion in 'System Administration' started by STN, Jun 17, 2020.

  1. STN

    STN CentMaxMod Premium Member

    9
    4
    3
    Jun 9, 2020
    Ratings:
    +6
    Local Time:
    7:38 PM
    1.19.0
    Mariadb 10.3
    Centminmod is optimized from install but you can get a lot more out of it. I have been doing a lot of loader.io testing on my server with centminmod and these are the settings that worked the best. Keep in mind i am a complete newb to centminmod and just found it out couple weeks back.

    Server: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz 32 core/threads. With 16GB ram.
    Results
    centminmod.PNG centminmod 3.PNG centminmod 2.PNG

    Pretty cool, huh?. :D With cpanel, my server would choke at 150+ users, now 2k feels nothing.

    Settings:

    Enable Nginx thread pools.


    In nginx.conf, enable these

    make them equal to cores on your cpu
    worker_processes 32;

    events {
    <Add this in event>
    accept_mutex off;
    }
    http {
    include mime.types;
    default_type application/octet-stream;

    <Add these>
    access_log off;
    sendfile on;
    sendfile_max_chunk 512k;

    Then in your domain name conf file in location block, just add this

    location / {
    aio threads;
    }

    Done, see the performance increase!

    Mysql settings

    I didn't bother much with mysql as i have no clue and centminmod claims it's already optimized. Just changed one thing
    max_connections = 5000

    PHP-FPM settings

    These make a huge difference. I have seen on apache cpanel how my server performed badly when they weren't set right.

    pm = ondemand
    pm.max_children = 200
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 8
    pm.min_spare_servers = 4
    pm.max_spare_servers = 12
    pm.max_requests = 5000

    Maybe dynamic is better as there will be processes hanging around, i just stick with ondemand.

    Memcached!

    The number one thing that helped take some load off mysql and manage so much user was memcache. Maybe i could get more out of it but i was pretty happy with the results, i don't know if i will ever have a site with more than 2k active users LOL. These settings made the site fly for 2k users.

    CON=2048
    BACKLOG=2048
    MAXREQ=4000
    THREADS=30 // set to number of cores on your cpu
    MEMSIZE=1024

    Lastly, put this in your domain conf file if you're using Xenforo. XF provides it already.
    location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    Feel free to critique/suggest how you think i could do better.
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    12:38 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Nice thanks for sharing. E5620 @ 2.40GHz is a very very ancient server cpu model too !

    Reminds me of @bitserver shared experience but with Centmin Mod Wordpress installed site at Wordpress - 2000 req/sec wordpress 1GB/1VCU DO VPS - impressed :)

    That isn't really required to have a .php location only need Xenforo 2 rewrite rules as per Xenforo - Updated Xenforo 2 Nginx Friendly Url Rules Configuration as default Centmin Mod nginx vhost has php.conf include file which has pretty optimal setup

    That is dependent on how many cpu core/threads to service PHP requests. See PHP-FPM - How to troubleshoot & optimize PHP-FPM server?

    would need to play with that as too low or high values can impact your Nginx server's download speed for files served to visitors - especially for large multi mega byte files served from Nginx.
     
  3. dce

    dce New Member

    23
    6
    3
    Feb 21, 2018
    Ratings:
    +6
    Local Time:
    10:38 AM
    A 32 core VPS is a significant expense! Maybe STN is running dedicated server? I am chugging along with 2 cores on a Linode VPS
    (E5-2680 v3 @ 2.50GHz).

    Default worker_processes in nginx.conf is 2. So in STN's case, adjusting worker_processes to 32 would have a big effect compared to default.
     
  4. STN

    STN CentMaxMod Premium Member

    9
    4
    3
    Jun 9, 2020
    Ratings:
    +6
    Local Time:
    7:38 PM
    1.19.0
    Mariadb 10.3
    Yes, it's a dedi. I got it pretty cheap last year.

    You're not wrong. It's an overkill of a machine. I thought i needed it. When i was on shared hosting, the suggestion my host gave me was to upgrade to a VPS whenever i would get some traffic spike. When i upgraded to VPS, the suggestion was to upgrade to a dedicated because VPS can't handle my traffic. When i got a cheap dedicated and installed cpanel myself, it started to have problems, i thought i need an upgrade and got this machine pretty cheap thankfully.


    I just believed handling traffic is really hard for web servers and you need really powerful machines. I also thought you just install cpanel and it does what it's supposed to do. After all they charge so much for their license.

    Oh boy :D seeing what a 5$ digitalocean droplet do with centminmod that my dedicated can has been an eye opener. I am not going to renew cpanel license next month and in process of switching already.

    Centminmod is making hosting companies lose a lot of money :ROFLMAO: i am going to be on a cheap VPS now.
     
  5. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    12:38 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Centmin Mod auto tunes nginx worker_processes in nginx.conf based on detected server cpu threads available, so default will differ depending on your server specs ;) :)

    haha (y):cool:
     
  6. dce

    dce New Member

    23
    6
    3
    Feb 21, 2018
    Ratings:
    +6
    Local Time:
    10:38 AM
    Good info to know eva2000. I just assumed that STN had to make that change he detailed which we now know was not
    necessary. Centminmod would automatically detect his 32 cores and make the correct adjustment in the config.

    I checked mine and saw it was set to 2 and again made the assumption that I got lucky and my cores matched what I though was the default!

    I ended up learning another important detail. Thanks for setting the record straight.
     
  7. pamamolf

    pamamolf Premium Member Premium Member

    3,826
    370
    83
    May 31, 2014
    Ratings:
    +712
    Local Time:
    5:38 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    Do we need to add the aio threads; on main Nginx config file also?
     
  8. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    12:38 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Yeah with Centmin Mod no 2 installs will be the same for base optimisation/tuned settings unless both installs had exact same server specs/hardware - even then there maybe slight differences as some auto detected formulas take into account free memory at time of install to set some buffers/settings which are impacted by memory availability. Though for initial installs, there wouldn't be that many services other than base ones that would eat into free memory.

    No not needed in nginx.conf if you have it in specific location context within your nginx vhost
     
  9. STN

    STN CentMaxMod Premium Member

    9
    4
    3
    Jun 9, 2020
    Ratings:
    +6
    Local Time:
    7:38 PM
    1.19.0
    Mariadb 10.3
    That's correct. I think centminmod had set some of the variables for nginx thread pooling already as well. Can't remember but for the purpose of this guide, i mentioned the needed variables.

    No, it should be in domain config only. I believe in nginx conf, it will enable server wide

    Edit: nvm, eva replied^. Follow his advice.
     
  10. pamamolf

    pamamolf Premium Member Premium Member

    3,826
    370
    83
    May 31, 2014
    Ratings:
    +712
    Local Time:
    5:38 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    I have it only at Nginx config file.... If that enables it on server wide i think it;s ok ... no problem....

    Or it doesn't work at all there?
     
  11. eva2000

    eva2000 Administrator Staff Member

    44,731
    10,197
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,805
    Local Time:
    12:38 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Generally you don't want to enabled server wide, only for locations which would benefit from aio threads i.e. Boosting NGINX Performance 9x with Thread Pools