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

What is the Networknt Light 4J analysis report?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how the Networknt Light 4J analysis report is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Networknt Light 4J Analysis report

I. overall introduction

Light 4J is the core product of networknt.com. A fast, lightweight and efficient micro-service framework based on Java SE. It contains more than a dozen sub-modules for different styles of API construction, including infrastructure services such as OAuth3,Portal,Logging,Messaging and Metrics. In addition, there is a range of tools that can help improve the productivity of developers and operators.

1. Performance

In the official benchmark test report of Light 4J, its performance is compared with Spring Boot and other micro-service platforms. Light 4J is 44 times faster than Spring Boot's mainstream microservice framework platform with built-in Tomcat, and requires only 1can5 memory, performance side by side with the Go language, and has lower average latency.

Framework

Language

Max Throughput

Avg Latency

Transfer

Go FastHttp

Go

1396685.83

99.98ms

167.83MB

Light-4j

Java

1344512.65

2.36ms

169.25MB

Spark

Java

194553.83

13.85ms

32.47MB

Go Http

Go

170313.02

15.01ms

20.95MB

Spring Boot Undertow

Java

44260.61

38.94ms

6.42MB

Spring Boot Tomcat

Java

33086.22

82.93ms

3.98MB

2. Github situation

At present, there are 71 Github sub-projects in Light 4J, of which 39 are Java projects. The most popular project is Light 4J itself, 2167 star,354 fork, which is lower than that of Spring Boot, Spring Cloud, Dubbo and so on. The other core sub-projects, such as light-oauth3, light-rest-4j, light-proxy, etc., have only one or two hundred star.

At present, there are 23 code contributors to the Light 4J project, but the developers concerned are gradually joining in to form a development echelon.

3. Light 4J capability list

Module

Description

Server

Implementation of http request based on Undertow

Security

Implement checksum parsing of JWT based on OAuth3, and support mock

Config

Support external configuration files for stand-alone applications, and support docker configuration files

Utility

A tool set

Client

Encapsulates the capabilities of httpclient and httpasyncclient to support caching and reading of jwt information

Validator

Support sawgger-based request parameters and url path verification, support json-schema-validator-based request packet verification

Audit

Support to output request and response messages to log files in json format

Info

Provides a / server/info endpoint that can output configuration information for each component of the application

Mask

Desensitize specific data, such as card number and other information

Status

Build a http error type model and use a unique error number to help the application troubleshoot the problem

Swagger-codegen

Using swagger specification to generate API interface program

Balance

Complex equalization module, which supports polling and local priority by default, and is scalable for development.

Body

Support for formatting http body into Java Map or List

Cluster

Support for service discovery by service name

Consul

Consul registry implementation of Light 4J

Correlation 、 traceability

Link tracking module

CORS

Http CORS access control module

Zookeeper

Zookeeper registry implementation of Light 4J

Data-source

Implementation of various database access

Decryptor 、 encode-decode

Encryption and decryption module, supporting AES

Rate-limit

Request rate limit module

Prometheus

Support prometheus format data interface

Email-sender

Mail sending module

Ip-whitelist

Request whitelist

Metrics

Transaction statistics module

II. Framework design ideas and technical core

Light 4J is designed for micro-service architecture with high throughput, low latency and lightweight. Based on the core components of Undertow Core Http server, it integrates as few third-party dependent libraries as possible. In architecture design, the following design principles are mainly followed:

Specially designed for micro-services and adaptation optimization for containerized deployment

Abandon the complex JavaEE and implement it only based on pure HTTP

Based on the design principle of security first, the implementation of OAuth3.0 and distributed gateway are embedded.

How to implement distributed things on micro-services is considered in the design.

Different functions are designed in the form of plug-ins, which is easy to customize and expand the framework.

Service consumers directly support service discovery and do not need to be implemented through service gateways, service agents and other mechanisms.

Logs can be combined with ElasticSearch, LogStash and Kibana to provide monitoring and alarm capabilities.

Embedded service call statistics and link tracking functions

Implemented its own dependency injection mechanism without introducing complex frameworks such as Spring

The Light 4J framework takes the Handler request interception mechanism as the core, dealing with framework logic and business logic in Handler. Handler can be divided into two types, one is the chain type Handler, which is similar to a filter and processes each request, and the other path type Handler only handles specific http path requests.

There are two steps to configure chain handler: 1. Add the implementation class definition (external introduction) to the location of handlers in the yml configuration file, in the format of "package name." Class name @ alias "; 2. Add the alias to the chains location in the yml configuration file. The order of aliases represents the order of processing. Cross-cutting concerns processing chain is the development is the structure, users can override or add their own cross-cutting concerns processing chain to support other standards or applications, such as opentracing, istio, etc.

There are three steps to configure http handler: 1, to implement the http request processing class based on the LightHttpHandler interface; 2, to define the implementation class in the handler location in the yml configuration file, in the format of "package name. Class name"; 3. Configure the request mode, path and implementation class corresponding to the http request at the location of the paths in the yml configuration file.

Example Handlers configuration:

Example Chains configuration:

Example Paths configuration:

Example of a custom Handlers implementation:

III. Summary

1. Performance

Compared with the existing Spring Boot, Spring Cloud or Dubbo, Light 4J does bring a great improvement in performance due to functional simplification. It also provides a basic service registration and discovery mechanism, supports zookeeper, and supports cloud deployment on containers.

Unlike large-scale applications (monolithic application), each microservices application service itself handles relatively simple logic, so a large number of business logic processing and database interactions should not be placed in a single service (service API). Service to service interactions are relatively more frequent (servicemesher). A lot of complex business logic processing should be distributed among multiple services and then done through the interaction of service to service. Therefore, the performance of the framework itself and the corresponding time in the interaction of service to service are extremely important. For cloud deployments on large-scale containers, significant cost savings can be achieved.

Based on a user's test report:

For the same functionality

Framework throughput latency memory

Spring-Boot 213/s 66.07ms 1.5GB

Light-4j 2319/s 11.39ms 300MB

2. Ecological aspect

The main weakness of Light 4J lies in its relatively weak ecology. At present, Light 4J does not have a perfect ecosystem, and the popularity of the community is low. The main project has only 2.2k star, while other projects basically have only a few dozen to a few hundred star. Compared with the sound ecosystem of Spring, the capabilities will be much weaker, such as circuit breaker, current limit, configuration center, these capabilities are currently in a state of no implementation or only a simple solution, docking with different third-party middleware, all need to adapt to the secondary development of Handler mode.

3. Ability

Light 4J framework Handler request interception mechanism is transparent to developers and can be delayed configuration, developers can focus on business logic to improve work efficiency. Although Light 4J itself provides more of the capabilities required under the microservice architecture, some do not track industry standards. For example, the link tracking module provided within the Light 4J framework does not support Open Tracing. Users can design and develop extension modules (cross-cutting concerns middleware handler) according to their own standards.

On Networknt Light 4J analysis report is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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