Enable Automatic Healthcheck for Gateway Servers in OpenResty Edge
OpenResty Edge provides automatic health checks of gateway servers to help you identify and deal with faulty gateways in a timely manner to ensure stable system operation. From the Edge admin Console, you can easily configure automatic health checks to remove unhealthy gateway servers from DNS resolution and distributed caching, and avoid routing traffic to failed nodes.
Create a new page rule
Open the web console. This is our sample deployment of the console. Every user would have their own deployment.
First, go to the “Applications” tab.
We pre-prepared an application named “test-edge.com”.
Click to configure this application.
Go to “Page Rules” page.
Here, we can add a new rule.
For this page rule, we need to specify a condition.
Enter “/status” as the value of string.
Let’s add a new action.
Select the “output response body”.
Set the respond body as “healthy”. When the requested URI is “/status”, the response body “healthy” will be output.
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.
Enable the healthcheck for gateway server
Let’s go to the gateways clusters page again.
This is the cluster we are going to use today.
Click to copy the IP address.
On the terminal, we use the curl
command to send a request to the gateway server.
We can see the respond body is “healthy” indeed.
Click to change the configuration of this cluster.
Enable the healthcheck.
We use the HTTP protocol.
Set the HTTP Request Host as our application’s name.
Enter “/status"as the request URI .
Requires the response body to be matched as “healthy”.
We set the request interval to be smaller, 3 seconds for demonstration purposes.
Save it.
Test the result
Switch to the terminal. Let’s stop the server first.
The service is inactive now.
Refresh the table.
We can see that the current status of this node is already in red, indicating that it is offline. The IP of Node will be removed from DNS resolution, distributed cache for SSL session IDs.
Check the “Details”.
By clicking on the red block, we can see the details of the failure.
Close it.
Now, restart the gateway server service.
The server is back up.
Refresh the table again. We can see that the node status has changed back to green.
In addition, we can also enable healthcheck for all the gateway clusters and servers in in a particular partition.
Click to edit this partition.
We can enable healthcheck by this button.
The healthcheck here is not for upstream backend servers or source stations. We covered it in another video.
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.
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.