How to Use Gateway Partitions in OpenResty Edge
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.
First, we will go to the “Gateway Clusters" page. Here you can see a numerous gateway clusters that have been established.
For instance, this gateway cluster is situated in the United States.
There is one gateway server in it.
It is also part of the gateway partition “default”.
Now let’s create a new gateway cluster. Click on “New Gateway Cluster”.
Enter the name of the gateway cluster “edge-test-cluster”.
In OpenResty Edge, a gateway partition consists of multiple gateway clusters as shown in the picture.
So the next step is to add this cluster to a partition.
Click on this drop down box.
We won’t use an existing partition. We’ll create a new one instead.
Click the button “Add Gateway Partition”.
Enter the partition name “edge-test-partition”.
Click the “Create” button.
The newly created partition now appears first in the partition selection dropdown.
Click the “Create” button to create the cluster.
We can see the newly created gateway cluster appears on the cluster list page.
As shown in the picture, a gateway cluster consists of multiple gateway servers.
Now let’s see how to add a gateway server to the newly created gateway cluster.
Here we have already prepared a gateway server.
Click the button “Approve”.
Select the cluster first.
Click on the drop down box and select the cluster we just created.
Enter the public IP address of this server.
Click to approve this server.
The server was added to the gateway cluster successfully.
Create a new application in the new partition
Now let’s create an application in the newly created partition.
Go to the applications page.
Click “New Application”.
Enter the domain name.
Click the partition selection drop down box.
Unselect the partition “default”.
Selecte the partition we just created.
Click the “Create” button.
Create a new page rule
We need to crate a page rule to illustrate how partition works.
Go to the “Page Rules” page.
Click “New Rule”.
Let’s add a new action.
click the action drop down box.
Select the action “output response body”.
Click the “Create” button.
We need to make a new release to push out our new changes.
Click on this button.
Ship it!
Our new release is now synchronized to all our gateway servers.
Now the new page rule has been pushed to all the gateway clusters and servers.
Our configuration changes do NOT require server reload, restart, or binary upgrade. So, it’s very efficient and scalable.
Test the new partition
Let’s go to the gateways clusters page again.
This is the cluster we just created.
Please note that the IP address of the server recently added to this cluster ends with ‘67’.
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"
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"
You can see that the gateway server of the other partition returns “Page Not Found”.
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.