Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Health examination and monitoring of Kong

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

You can have the API of the Kong agent use ring-balancer and configure it by adding a upstream entity that contains one or more target entities, each pointing to a different IP address (or hostname) and port. Ring-balancer will balance the load between different target and perform health checks on targets based on uptream configuration to make them healthy or unhealthy, and ring-balancer will only route traffic to healthy target whether they respond or not.

Kong supports two health check methods, which can be used alone or in combination.

Active checks: where a specific HTTP or HTTPS endpoint in the target is periodically requested and the health status of the target is determined based on its response

Passive checks: Kong analyzes the communication being represented and determines the health status of the target based on the behavior of the target in response to the request. Healthy and unhealthy target

The goal of the health check function is to dynamically mark the target as healthy or unhealthy for a given Kong node. Without cluster-wide health information synchronization, each Kong node determines the health status of its target respectively. This is reachable because at a given point, one Kong node may be able to successfully connect to one target while the other node cannot reach it. In this way, the first node will consider it healthy, while the second node will mark it as unhealthy and start routing traffic to other target of upstream.

Whether it is an active probe (for an active health check) or an agent request (for a passive health check), data is generated to determine whether the target is healthy. Requests may generate TCP errors, timeouts, or HTTP status codes. Based on this information, the Health Checker updates a series of internal counters:

If the returned status code is configured as "healthy", the target's "Successes" counter will be incremented and all other counters will be cleared; if the connection fails, the target's "TCP failure" counter will be incremented and the "Successes" counter will be cleared; if the timeout occurs, the target's "timeouts" counter will be increased and the "Successes" counter will be cleared If the returned status code is configured as "unhealthy", it increments the target's "HTTP failures" counter and clears the "Successes" counter.

If any "TCP failure", "HTTP failure", or "timeout" counters reach their configured threshold, the target will be marked as unhealthy.

If the "success" counter reaches its configured threshold, the target is marked as healthy.

If all the target of a upstream is unhealthy, Kong will return the upstream request to 503 Service Unavailable.

The health check is performed only on target whose status is active and does not modify the active status of the target in the Kong database.

Unhealthy target is not removed from the loadbalancer, so there is no impact on the balancer layout when using the hashing algorithm (only they are skipped).

DNS warnings and Balancer warnings also apply to health checks. If you use a hostname for target, you need to make sure that the DNS server is always the full IP address and name, and that the response is not restricted. Failure to do so may result in a failure to perform a health check. Types of health check-up

There are two types of health check-ups, Active health checks and Passive health checks

Active health checks

Active health checks is to actively detect their health status. When the upstream entity enables active health checks, Kong periodically issues HTTP or HTTPS requests to the configuration path of each target of the upstream. This allows Kong to automatically enable and disable target in balancer based on the probe results.

The periodicity of Active health checks can be configured when target is healthy or unhealthy. If one of the interval values is set to zero, the check is disabled in the appropriate scene. If both are zero, the active health check is completely disabled.

Passive health checks

Whether Passive health checks performs checks based on requests (HTTP/HTTPS/TCP) brokered by Kong without generating additional traffic. When the target becomes unresponsive, the passive health checker detects this and marks the target as unhealthy. Ring-balancer will start to skip this target, so no more traffic will be routed to it.

When the problem of the destination is resolved and is ready to receive traffic again, the Kong administrator can manually notify health checker that the destination should be enabled again, through an Admin API endpoint:

$curl-I-X POST http://localhost:8001/upstreams/my_upstream/targets/10.1.2.3:1234/healthyHTTP/1.1 204 No Content

This command broadcasts a cluster-wide message to propagate the "health" status to the entire Kong cluster. This causes the Kong node to reset the health counters of the health checker running in all worker of the Kong node, allowing the ring balancer to route traffic to the destination again.

The advantage of passive health checks is that they do not generate additional traffic, but they do not automatically re-mark the target as healthy: "circuit is broken", which requires the system administrator to re-enable the target.

Monitoring of Kong

Kong supports the use of Prometheus for monitoring data collection, and officially provides the collection method and Dashboard template of Grafana

The official Kong Plugin Prometheus is updated regularly and looks active.

In addition to the official website, some netizens also provided a monitoring template, but the last update was on May 17, 2018, and there has been no update since then. You can also refer to it. Kong-prometheus-plugin

Summary

The health check of Kong mainly introduces the types of health check. These two types of health check can be turned on and off. Please refer to the official website for specific methods of opening and closing.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report