High Traffic spikes



  • Hello,

    I would like to create a new nodebb forum and Need some advice for really high Traffic Spikes... The forum is about Gaming and we have Spikes like 3000 Users at the Same time. Only sometimes when some youtuber or so Gives a shoutout. I plan to use a nginx as a Proxy and i've got a 8 core Server. I dont think that the 8 Cores can handle that traffic... Any ideas? Sorry for my bad english ✌️


  • Global Moderator

    8 cores is overkill for any web server. I'd suggest running NodeBB with 4 processes across 2 cores and probably 1 GB of RAM. That should be plenty. We have a guide for how to enable clustering at docs.nodebb.org



  • @pitaj Thank you... But really only 2 cores for 3000 simultaneous users... Woow. We used on a wordpress Site 8 cores and 64 RAM and Could Not handle 800 users. Would be great ...



  • @pitaj sorry , maybe i did Not get it... The Processes are the Ports that i use... So i use 4 Processes over 2 cores, how do i config 2 cores to use... ?


  • Admin

    @jasper007 Node.js is different from php in that you don't want more processes than you have cores. Node is much more efficient because it doesn't block on I/O (and other) requests, meaning more people can be handled.


  • Global Moderator

    @jasper007 if you don't know how to configure to cores to use through creating a VM and whatnot, just run four processes and let the OS handle the rest.



  • @pitaj I'm running 8 cores, 8 GB RAM, High CPU intensive processors. (NodeBB spawns 8 process in cluster mode)

    When I post something on my social media accounts, the traffic spikes up to 1,300 users and if I do it with several posts, it makes it impossible to get into the site (CPU goes to 100% and stops responding).


  • Global Moderator

    @esteban-constante are you using Nginx for serving static assets? Are you using Mongo + redis?



  • @pitaj Using Mongo (in Atlas), redis (same instance as NodeBB).

    I haven't configured nginx to serve static assets (all images are on imgur), would this help a lot?

    I've been exploring ways to autoscale my instances on the cloud, but still working through that.


  • Global Moderator

    @esteban-constante yes using Nginx to serve static assets would absolutely help.


  • Admin

    Using nginx to serve static assets takes the load off of NodeBB to serve pre-compiled things like nodebb.min.js, module files, etc... nginx is exceedingly good at doing that.



  • So min. one core has to be used for nginx? And if that's not enough I have to use a load balancer and use something like 2 Server a 8 cores. Both servers with clustering...?



  • @julian Just checked my nginx conf, it's basically the same as the one in the tutorial:

    upstream io_nodes {
        ip_hash;
        server 127.0.0.1:4567;
        server 127.0.0.1:4568;
        server 127.0.0.1:4569;
    }
    
    > server {
        listen 80;
        server_name community.nodebb.org;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;
        # Socket.io Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        gzip            on;
        gzip_min_length 1000;
        gzip_proxied    off;
        gzip_types      text/plain application/xml text/javascript application/javascript application/x-javascript text/css application/json;
        location @nodebb {
            proxy_pass http://io_nodes;
        }
        location ~ ^/assets/(.*) {
            root /path/to/nodebb/;
            try_files /build/public/$1 /public/$1 @nodebb;
        }
        location /plugins/ {
            root /path/to/nodebb/build/public/;
            try_files $uri @nodebb;
        }
        location / {
            proxy_pass http://io_nodes;
        }
    }
    

    So yeah, it seems I'm using nginx to serve static assets :(

    (ninja'd by yariplus)


  • Global Moderator

    Could you provide your full actual nginx config? Fell free to redact anything you think is sensitive.

    Check the headers on a request to example.com/assets/nodebb.min.js. If nginx is set up correctly, they shouldn't have an X-Powered-By: NodeBB header.



  • Here it's the conf file:

    upstream io_nodes {
        ip_hash;
        server 127.0.0.1:4567;
        server 127.0.0.1:4568;
        server 127.0.0.1:4569;
        server 127.0.0.1:4570;
        server 127.0.0.1:4571;
        server 127.0.0.1:4572;
        server 127.0.0.1:4573;
        server 127.0.0.1:4574;
    
        #16 cores:
        server 127.0.0.1:4575;
        server 127.0.0.1:4576;
        server 127.0.0.1:4577;
        server 127.0.0.1:4578;
        server 127.0.0.1:4579;
        server 127.0.0.1:4580;
        server 127.0.0.1:4581;
        server 127.0.0.1:4582;
    }
    
    server {
        listen       80;
        server_name  myserver.tld;
        return       301 http://www.myserver.tld$request_uri;
    }
    server {
        listen 80;
        server_name www.myserver.tld;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;
        # Socket.io Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        gzip            on;
        gzip_min_length 1000;
        gzip_proxied    off;
        gzip_types      text/plain application/xml text/javascript application/javascript application/x-javascript text/css application/json;
        location @nodebb {
            proxy_pass http://io_nodes;
        }
        location ~ ^/assets/(.*) {
            root /home/myuser/nodebb/;
            try_files /build/public/$1 /public/$1 @nodebb;
        }
        location /plugins/ {
            root /home/myuser/nodebb/build/public/;
            try_files $uri @nodebb;
        }
        location / {
            proxy_pass http://io_nodes;
        }
    }
    

  • Global Moderator

    @esteban-constante please use triple ticks (```) around code blocks, not quotes. For future reference



  • @pitaj fixed it. Thanks! I was trying with single and double `


  • Global Moderator

    @esteban-constante have you been able to check the response headers for any static assets yet? Your nginx file looks good to me. Have you tried running with fewer NodeBB processes? It could be that your database server is being overloaded.



  • @pitaj So far I haven't been able to test the traffic spikes as I haven't had any lately :(

    I did found a typo in my nginx file which I've fixed already and it seems to run better. I'll report back as soon as I get more data.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.