Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Docker High Performance

You're reading from   Docker High Performance Complete your Docker journey by optimizing your application's work?ows and performance

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher
ISBN-13 9781789807219
Length 174 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Russ McKendrick Russ McKendrick
Author Profile Icon Russ McKendrick
Russ McKendrick
Allan Espinosa Allan Espinosa
Author Profile Icon Allan Espinosa
Allan Espinosa
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Balancing load with NGINX


Now that we have a pool of Docker applications to forward traffic to, we can prepare our load balancer. In this section, we will briefly cover NGINX, a popular web server that has high concurrency and performance. It is commonly used as a reverse proxy to forward requests to more dynamic web applications, such as the Node.js one we wrote earlier. By configuring NGINX to have multiple reverse proxy destinations, such as our pool of Docker applications, it will balance the load of requests coming to it across the pool.

The following steps will deploy NGINX to our Docker Swarm cluster for load balancing:

  1. First, let's prepare an NGINX configuration file called nginx.conf:
events { }

http {
  resolver 127.0.0.11 valid=5s ipv6=off;

  server {
    listen 80;
    location / {
      set $backend application;
      proxy_pass http://$backend:8000;
    }
  }
}

Note that we used NGINX's DNS service discovery to send traffic to our application via its network alias application...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image