OpenResty Edge’s global server load balancing (GSLB) distributes traffic among your gateway clusters at the DNS level, steering queries by real-time indicators such as load average, latency, and bandwidth. This tutorial shows how to configure GSLB in the OpenResty Edge Admin console: view load balancing plans, adjust the global settings, and tune per-node thresholds. If you are new to the concept, start with how global server load balancing works and why we bring it back to the application layer. GSLB steers traffic among healthy nodes; keeping failed nodes out of DNS resolution in the first place is the job of gateway server health checks.

View GSLB load balancing plans

Let’s go to the OpenResty Edge Admin web console. This is our sample deployment of the console. Every user has their own deployment.

Applications list in the OpenResty Edge Admin web console

Go to the DNS management page.

DNS tab highlighted in the OpenResty Edge Admin console navigation

Go to the “GSLB” page.

Global Server Load Balancing entry under DNS Zones on the OpenResty Edge DNS page

Select “Plans”.

Plans tab on the OpenResty Edge GSLB page

Here we can observe the traffic status after activating global server load balancing.

This pie chart displays how the current traffic is distributed among different network clusters in real-time.

Pie chart of real-time traffic distribution across gateway clusters in OpenResty Edge GSLB

As shown, this cluster handles the highest amount of traffic.

Gateway cluster handling the highest share of traffic in the GSLB pie chart

This is the traffic distribution of the previous plan.

Previous Plan tab selected in the GSLB plan comparison table

You can see that in the cluster aliyun-beijing, the traffic distribution of the previous plan was 52% and 48%.

Previous GSLB plan distributing 52% and 48% of traffic in the aliyun-beijing cluster

And the current distribution is 50% and 50%.

Current GSLB plan distributing 50% and 50% of traffic in the aliyun-beijing cluster

This is the origin plan, the first plan of GSLB.

Original Plan tab showing the first GSLB plan with even traffic splits

This is the current plan. It will be updated periodically.

Current Plan column highlighted in the GSLB plan comparison

When the traffic distribution or plan on the left is inconsistent with the GSLB plan on the right, the plan on the right side will be highlighted in red and green.

GSLB plan on the right highlighted in red and green when it differs from the current traffic distribution

Green indicates an increase, while red indicates a decrease.

Green marking traffic increases and red marking decreases in the GSLB plan comparison

Click on the previous plan.

Button for viewing the previous GSLB plan

And the next plan. You can browse historical plans.

Browsing historical GSLB plans with the Next Plan link

Configure GSLB settings in OpenResty Edge

Next, let’s take a look at the GSLB configuration.

Config tab on the OpenResty Edge GSLB page

You can use this button to enable or disable GSLB.

Toggle button for enabling or disabling GSLB in OpenResty Edge

GSLB toggle switched to the disabled state with the Submit button

This is the update interval of the plan. It means that the plan will be updated every 60 seconds.

GSLB plan update interval set to 60 seconds

Here you can set the number of results that will be returned in the DNS query.

Setting the number of results returned in each DNS query

Adjust traffic flow per Edge Node

Next, we will look at how to configure each Edge Node.

Click the edit button to enter edit mode.

Edit button on a gateway cluster row in the Node Configuration for GSLB table

You can use the drop-down list to select the indicators that will determine the DNS results. This will help you adjust the traffic flow in the system.

Metric drop-down list with load average and request per second options for a gateway cluster node

For example, select “load average in last 1 minute”.

Choosing a load average metric in the Watermark metric drop-down list

The traffic will be adjusted based on the calculated probability when the indicator reaches the lower threshold.

Low watermark input where traffic is adjusted by calculated probability

DNS resolution does not return any information about this node anymore when the indicator reaches the upper threshold.

High watermark input where DNS resolution stops returning the node

What is OpenResty Edge

OpenResty Edge is our all-in-one gateway software for microservices and distributed traffic architectures. It combines traffic management, private CDN construction, API gateway, security, and more to help you easily build, manage, and protect modern applications. OpenResty Edge delivers industry-leading performance and scalability to meet the demanding needs of high concurrency, high load scenarios. It supports scheduling containerized application traffic such as K8s and manages massive domains, making it easy to meet the needs of large websites and complex applications.

If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!

About The Author

Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..

Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.

OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.

As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.