A Book Smart Blood Sugar

The new diabetes treatment method known as Smart Blood Sugar teaches patients how to keep their blood sugar levels healthy over time. The following is a review of the product Smart Blood Sugar. An…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




HOW I LOAD BALANCE WITH NGINX ON AWS.

LOAD BALANCING

The act of efficiently distributing incoming network traffic across a group of servers in the server pool or server farm is called load balancing. High-traffic websites nowadays get millions of requests from clients or users who are expecting text, videos, or application data all in a quick and reliable technique. The general practice to cost-effectively scale to meet the high demands would be to add more servers. A load balancer makes sure the high traffic is evenly distributed among these servers.

FUNCTIONS OF A LOAD BALANCER

LOAD BALANCING ALGORITHMS

Related Basics with load balancing:

Load balancers, once almost exclusive to the realm of hardware devices, can now be implemented effectively in software on another server. The line between hardware and software load balancers is fading fast. The principle difference between hardware versus software load balancers lies in the available capacity and the amount of labor invested in the platform.

NGINX AS A LOAD BALANCER.

nginx load balancer

As a load balancer, NGINX receives traffic from clients/users and then distributes the traffic using configured algorithm across the servers in the pool. NGINX is also responsible for the delivery of the server responses to different clients/users.

To wrap this up, we are going to create a simple Nginx load balancer. We have already spun up three EC2 instances in AWS web App1, web App2, and NGINX Load Balancer. In each instance, Nginx has been installed and running. we have also created custom default index.html pages on web app1 and web app2 machines for the purpose of testing.

Below are the IP address details of our EC2 instances for demonstration. Take note of the public IP address which we will use for configuration and verification.

Nginx IP details
Web App1 IP details
Web App2 IP details

The load balancing configuration file is located at /etc/nginx/nginx.conf in our load balancer EC2 instance. Use the cat command to have a view of the already configured file.

Nginx upstream is used for proxy requests to other servers. Our upstream configuration name is the webserver. Note that the config setting is under HTTP simply because it is expected to operate on the application (layer 7) load balance. More parameters can be added to the server address such as custom port numbers as well as weight values. On the server settings, it basically means when a proxy request is received from port 80, Nginx will proxy pass to the webserver which contains the server IP address details, in a simple round-robin pattern. And finally, pass the log details to the log file.

Let's head over to the browser first to see the Nginx page on web app1 and web app2.

Web app1 Nginx works perfectly, let us perform the same test for web app2 Nginx.

web app2

We have confirmed that Nginx works on web app1 and web app2 by connecting through their public IP respectively on the web browser. Now we verify if the load balancer is serving the same web pages as we see above using the load balancer's public IP address on the web browser.

As expected, the load balancer serves the same web page seen from web app1 public IP on the browser. When the web browser is refreshed, the load balancer will now serve the same web page as seen from the public IP of web app2.

We can also curl the public IP address of the load balancer EC2 instance on the terminal window to further test our load balance configuration.

On the first curl command, the load balancer serves the web page from web app1 and on the second curl command, it will serve the webpage for web app2.

Lastly, if we cat the log file specified in the Nginx.conf file, we will find log records.

SUMMARY.

Thanks for reading.

Add a comment

Related posts:

2022 Genesis G70 Shooting Brake 2.0T Review

I had the pleasure of spending a week with the Genesis G70 Shooting Brake, my first experience of a car from Hyundai’s luxury brand…and oh what luxury this car provides! From the gorgeous “Bond…

Ang Pinakamahusay na Online Casino Platform sa E Bingo Online Casino

Kung ikaw ay isang naghahanap ng kaligayahan sa online na pagsusugal at kasiyahan sa mga laro, marahil ay may ilang beses ka nang naririnig ang tungkol sa E Bingo Online Casino. Sa artikulong ito…

How to stop reading the news?

How to stop reading the news when you want to control everything around, it seems that you can miss important information? If you are a person who has a high level of neuroticism, that is, sensitive…