LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Proxy Health

For an API built with light-4j frameworks, it has a health check endpoint exposed for third-party monitoring systems and Kubernetes probes. If http-sidecar is used, we can use the LightProxyHandler for the health check, and it has the option to collect the health status from the backend API.

Both HealthGetHandler and ProxyHealthGetHandler share the same health.yml configuration file.

In the handler.yml, we can also config two different endpoints.

handlers:
  - com.networknt.proxy.ProxyHealthGetHandler@health
.
.
.

paths:
  - path: '/adm/health/${server.serviceId:com.networknt.petstore-3.0.1}'
    method: 'get'
    exec:
      - security
      - health

  - path: '/health
    method: 'get'
    exec:
      - health

Some users may prefer K8s probes to use /health with the HealthGetHandler and others may prefer /adm/health/${server.serviceId:} to use the ProxyHealthGetHandler.

Proxy Health

If the backend API is implemented with other frameworks/languages, chances are it doesn’t have a health check endpoint. In this case, we just need to set up the proxy to return its health check result on behalf of the backend API.

The configuration is the same as the above example. Just be sure to use the backend API serviceId for the path parameter. Only the http-sidecar or light-gateway instance will be registered to the global registry for consumers to discover with this configuration. It is a standard way to bring any API service to the Light-4j ecosystem.

Pass Through

If the backend API has the health check endpoint implemented, we want to call the backend API instead of the handler on the http-sidecar or light-gateway. Here is the configuration in the handler.yml on the http-sidecar or light-gateway.

handlers:
  - com.networknt.proxy.LightProxyHandler@proxy

  .
  .
  .

paths:
  - path: '/adm/health/${server.serviceId:com.networknt.petstore-3.0.1}'
    method: 'get'
    exec:
      # - security
      - proxy

As you can see, we put the proxy handler in the exec for the /adm/health/{serviceId} endpoint so the request will be proxied to the backend API.

Aggregated

When used in the http-sidecar or light-gateway, there is another option to combine both the gateway and backend health statuses together.

You need to use ProxyHealthGetHandler and overwrite the health.yml configuration in the values.yml file.

health.downstreamEnabled: true
health.downstreamHost: http://localhost:8081
health.downstreamPath: /health

First, we enable the invocation to the backend API. Then we need to set up the backend API host and path for the health check endpoint.

Customization

The health check handler we implemented in the light-4j is just a reference implementation. I would recommend implementing customized handlers for real APIs to provide health info based on the dependencies.

For example, if an API connects to a database to serve its request, it would check the database connection before returning the OK to the health check call.

One example of a health check is the Kafka sidecar that checks the backend connectivity when Reactive Consumer is enabled. The source code can be accessed at https://github.com/networknt/kafka-sidecar/blob/master/src/main/java/com/networknt/mesh/kafka/handler/SidecarHealthHandler.java

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Proxy Health” was last updated: December 6, 2022: fixes #349 add proxy-health document under concern (#350) (e2e750a)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute