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.

Screenshot

First, go to the “Applications” tab.

Screenshot

We pre-prepared an application named “test-edge.com”.

Screenshot

Click to configure this application.

Screenshot

Go to “Page Rules” page.

Screenshot

Here, we can add a new rule.

Screenshot

For this page rule, we need to specify a condition.

Screenshot

Enter “/status” as the value of string.

Screenshot

Let’s add a new action.

Screenshot

Select the “output response body”.

Screenshot

Set the respond body as “healthy”. When the requested URI is “/status”, the response body “healthy” will be output.

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

Enable the healthcheck for gateway server

Let’s go to the gateways clusters page again.

Screenshot

This is the cluster we are going to use today.

Screenshot

Click to copy the IP address.

Screenshot

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

Screenshot

We can see the respond body is “healthy” indeed.

Screenshot

Click to change the configuration of this cluster.

Screenshot

Enable the healthcheck.

Screenshot

We use the HTTP protocol.

Screenshot

Set the HTTP Request Host as our application’s name.

Screenshot

Enter “/status"as the request URI .

Screenshot

Requires the response body to be matched as “healthy”.

Screenshot

We set the request interval to be smaller, 3 seconds for demonstration purposes.

Screenshot

Save it.

Screenshot

Test the result

Switch to the terminal. Let’s stop the server first.

Screenshot

The service is inactive now.

Screenshot

Refresh the table.

Screenshot

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.

Screenshot

Check the “Details”.

Screenshot

By clicking on the red block, we can see the details of the failure.

Screenshot

Screenshot

Close it.

Screenshot

Now, restart the gateway server service.

Screenshot

The server is back up.

Screenshot

Refresh the table again. We can see that the node status has changed back to green.

Screenshot

In addition, we can also enable healthcheck for all the gateway clusters and servers in in a particular partition.

Screenshot

Click to edit this partition.

Screenshot

We can enable healthcheck by this button.

Screenshot

The healthcheck here is not for upstream backend servers or source stations. We covered it in another video.

Screenshot

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.