Testing loader.io after installing NGINX (how to install loader.io & NGINX)

ehdtlaos

Edrick Ee

Posted on August 19, 2021

Testing loader.io after installing NGINX (how to install loader.io & NGINX)

Challenge
I had to connect my current servers to the NGINX and implement horizontal scaling.
Figuring out NINGX and its loadbalancers
Also testing it using loader.io

Action
How I installed nginx

  1. SSH into your NGINX instance: ssh -i *.pem ubuntu@
  2. Install NGINX after update & upgrade: sudo apt install nginx
  3. Run NGINX: sudo systemctl start nginx
  4. get into file: sudo vim /etc/nginx/sites-enabled/default
  5. delete everything and replace it with this:
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g
                 inactive=60m use_temp_path=off;

upstream sdcgroup {
  least_conn;
  keepalive 500;
  server 18.191.246.18:3000;
  server 3.22.221.100:3000;
  server 18.221.27.16:3000;
}

server {
  listen 80 backlog=4096;
  gzip on;

  location /products {
    proxy_cache_valid any 10m;
    proxy_cache_valid any 10m;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_pass http://sdcgroup;

    proxy_cache my_cache;
    add_header X-Cache-Status $upstream_cache_status;
  }

  location /loaderio-ab8120fd9cc113d34d4a5b9796fb3c65 {
    return 200 'loaderio-ab8120fd9cc113d34d4a5b9796fb3c65';
  }
}
Enter fullscreen mode Exit fullscreen mode

restart NGINX: sudo systemctl restart nginx

How to use loader.io: After sign up, you'll see verification page

In server repo, set up

  app.get(`/${LOADERIO_KEY}`, (req, res) => {
    res.send(LOADERIO_KEY);
  })
Enter fullscreen mode Exit fullscreen mode

Time to test using loader.io

First Attempt (5k/sec for 1 minutes using products/%{*:1-1000000})
Alt Text

Second Attempt (2k/sec for 1 minutes using products/%{*:1-500})
Alt Text

I added ip_hash above least_conn
Third Attempt (10k/sec for 1 minutes using products/%{*:1-500})
Alt Text

ip_has with least_conn works!!!

Fourth Attempt (10k/sec for 1 minutes using products/%{*:1-1000000})
It failed
Alt Text

Fifth Attempt (5k/sec for 1 minutes using products/%{*:90000-1000000})
Alt Text
too high error rate

Sixth Attempt (1k/sec for 1 minutes using products/%{*:1-1000000})
Alt Text

Result
Now server can handle 1k request per second with 0% error rate and it can go up to 10k request per second with 0% error rate if we are only using 500 products

💖 💪 🙅 🚩
ehdtlaos
Edrick Ee

Posted on August 19, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related