This tutorial demonstrates how to use gateway partitions in OpenResty Edge. Gateway partitions are groups of gateway clusters which may use different configurations.

It affords the user autonomous governance over the system, facilitating both the targeted dissemination of updates across the Gateway server array and the reversion to antecedent versions.

Partitions are the key to segregating internal and external applications for businesses, or isolating servers for precise A/B testing.

With OpenResty Edge, your configurations are not just released—they’re strategically deployed.

Create a new partition

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

Screenshot

First, we will go to the “Gateway Clusters" page. Here you can see a numerous gateway clusters that have been established.

Screenshot

For instance, this gateway cluster is situated in the United States.

Screenshot

There is one gateway server in it.

Screenshot

It is also part of the gateway partition “default”.

Screenshot

Now let’s create a new gateway cluster. Click on “New Gateway Cluster”.

Screenshot

Enter the name of the gateway cluster “edge-test-cluster”.

Screenshot

In OpenResty Edge, a gateway partition consists of multiple gateway clusters as shown in the picture.

Embeded image

So the next step is to add this cluster to a partition.

Click on this drop down box.

Screenshot

We won’t use an existing partition. We’ll create a new one instead.

Click the button “Add Gateway Partition”.

Screenshot

Enter the partition name “edge-test-partition”.

Screenshot

Click the “Create” button.

Screenshot

The newly created partition now appears first in the partition selection dropdown.

Screenshot

Click the “Create” button to create the cluster.

Screenshot

We can see the newly created gateway cluster appears on the cluster list page.

Screenshot

As shown in the picture, a gateway cluster consists of multiple gateway servers.

Embeded image

Now let’s see how to add a gateway server to the newly created gateway cluster.

Here we have already prepared a gateway server.

Screenshot

Click the button “Approve”.

Screenshot

Select the cluster first.

Click on the drop down box and select the cluster we just created.

Screenshot

Enter the public IP address of this server.

Screenshot

Click to approve this server.

Screenshot

The server was added to the gateway cluster successfully.

Screenshot

Create a new application in the new partition

Now let’s create an application in the newly created partition.

Go to the applications page.

Screenshot

Click “New Application”.

Screenshot

Enter the domain name.

Screenshot

Click the partition selection drop down box.

Screenshot

Unselect the partition “default”.

Screenshot

Selecte the partition we just created.

Screenshot

Click the “Create” button.

Screenshot

Create a new page rule

We need to crate a page rule to illustrate how partition works.

Go to the “Page Rules” page.

Screenshot

Click “New Rule”.

Screenshot

Let’s add a new action.

Screenshot

click the action drop down box.

Screenshot

Select the action “output response body”.

Screenshot

Click the “Create” button.

Screenshot

We need to make a new release to push out our new changes.

Screenshot

Click on this button.

Screenshot

Ship it!

Screenshot

Our new release is now synchronized to all our gateway servers.

Screenshot

Now the new page rule has been pushed to all the gateway clusters and servers.

Embeded video

Embeded video

Embeded video

Our configuration changes do NOT require server reload, restart, or binary upgrade. So, it’s very efficient and scalable.

Embeded image

Test the new partition

Let’s go to the gateways clusters page again.

Screenshot

This is the cluster we just created.

Screenshot

Please note that the IP address of the server recently added to this cluster ends with ‘67’.

Screenshot

On the terminal, we use curl to send a request to the gateway server.

curl "http://13.229.144.67" -H "Host: edge-test-partition.com"

Screenshot

You can see that the correct response body has been outputted.

We are now performing the same operation on a server that is not on this partition. Note that this server’s IP ends with .84.

Send the request.

curl "http://3.131.85.84" -H "Host: edge-test-partition.com"

Screenshot

You can see that the gateway server of the other partition returns “Page Not Found”.

What is OpenResty Edge

OpenResty Edge is a powerful distributed traffic management and private CDN software product based on OpenResty. It provides various features such as page rules, web application firewall (WAF), load balancing, and many more.

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.