Testing loader.io after installing NGINX (how to install loader.io & NGINX)
Edrick Ee
Posted on August 19, 2021
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
- SSH into your NGINX instance: ssh -i *.pem ubuntu@
- Install NGINX after update & upgrade: sudo apt install nginx
- Run NGINX: sudo systemctl start nginx
- get into file: sudo vim /etc/nginx/sites-enabled/default
- 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';
}
}
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);
})
Time to test using loader.io
First Attempt (5k/sec for 1 minutes using products/%{*:1-1000000})
Second Attempt (2k/sec for 1 minutes using products/%{*:1-500})
I added ip_hash above least_conn
Third Attempt (10k/sec for 1 minutes using products/%{*:1-500})
ip_has with least_conn works!!!
Fourth Attempt (10k/sec for 1 minutes using products/%{*:1-1000000})
It failed
Fifth Attempt (5k/sec for 1 minutes using products/%{*:90000-1000000})
too high error rate
Sixth Attempt (1k/sec for 1 minutes using products/%{*:1-1000000})
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
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
November 29, 2024