• Stars
    star
    3,608
  • Rank 12,281 (Top 0.3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast, lightweight and more productive microservices framework

A fast, lightweight and cloud-native microservices framework.

Stack Overflow | Google Group | Gitter Chat | Subreddit | Youtube Channel | Documentation | Contribution Guide |

Build Status codecov.io

Why call it Light-4J

Light means lightweight, lightning fast and shedding light on how to program with modern Java SE for cloud-native deployment.

Why am I doing it

I had been working on the Java EE platforms since early 2000 and suffered the performance and productivity issues. In 2014, I realized that the IT industry was moving from Monolithic to Microservices and from on-premise data centers to the public clouds.

To reduce the production cost for my applications, I need to find a lightweight platform that has a small memory footprint, high throughput, and low latency in Java. Java EE and Spring/Spring Boot are too heavy to be considered. Other lightweight Java platforms all have different issues on the separation between the business logic and technical cross-cutting concerns. Moreover, they are not cloud-native or designed for container/cloud.

Without finding anything suitable, I started to build my open-source platform light-4j on top of the Undertow HTTP core by following the principles. Because my approach is very radical, and it is against products from big corporations, I have been attacked by some entities online and offline constantly. However, I am so convinced that my approach is the future direction and spend all my effort to continue the development. Today, a lot of companies are using light-4j on production with very positive feedback. It further encourages me to devote myself to the framework and to extend the platform to build an ecosystem.

For users who benefit from the platform, you can become a sponsor for me so that I can put all my effort into the open-source projects.

Why use this framework

Fast and small memory footprint to lower production cost.

It is 44 times faster than the most popular microservices platform Spring Boot embedded Tomcat and use only 1/5 of memory. Here are the benchmark results compare with Spring Boot and other microservices frameworks. Here is the third party comparison with other Web frameworks.

Provide an embedded gateway to address cross-cutting concerns.

  • Plugin architecture for startup/shutdown hooks and middleware components
  • Distributed OAuth2 JWT security verification as part of the framework
  • Request and response validation against OpenAPI specification at runtime
  • Metrics collected in Influxdb/Prometheus and viewed from Grafana Dashboard for both services and clients
  • Global exception handling for runtime exception, API exception, and other checked exceptions
  • Mask sensitive data like the credit card, sin number, etc. before logging
  • Sanitize cross-site scripting for query parameters, request headers and body
  • Audit to dump important info or entire request and response.
  • Body parser to support different content types
  • Standardized response code and messages from the configuration file
  • Externalized configuration for all modules for the dockerized environment
  • CORS pre-flight handler for SPA (Angular or React) from another domain
  • Rate limiting for services that exposed outside to the Internet
  • Service registry and discovery support direct, Consul and Zookeeper
  • Client-side discovery and load balance to eliminate proxies
  • A client module that is tightly integrated with Light-OAuth2 and supports traceability

Design and Test driven development to increase productivity

Design OpenAPI specification and generate the service from it. The specification is also part of the framework to drive security verification and request validation at runtime.

Unit/End-to-End test stubs are generated to enable test driven approach for quality product.

Debugging within IDE just like standalone application for better developer productivity.

Built-in DevOps flow to support continuous integration to production

Dockerfile and DevOps supporting files are generated to support dockerization and continuous integration to production.

Multiple frameworks for different type of microservices

  • light-rest-4j is a RESTful microservice framework with OpenAPI specification for code generation and runtime security and validation
  • light-graphql-4j is a GraphQL microservice framework that supports schema generation from IDL and plugin.
  • light-hybrid-4j is a hybrid microservice framework that takes advantages of both monolithic and microservice architectures.
  • light-eventuate is a messaging based microservice framework based on Kafka, event sourcing and CQRS

Multiple languages support

All the open sourced frameworks are built in Java and we are working on Nodejs framework internally. In the future, we might provide Golang framework as well and all them are sharing the same eco-system and market place.

OAuth2 server, portal and services to form ecosystem

OAuth2 Server for security and Portal for production monitor and management. The portal is also a marketplace to link clients and services together.

Getting Started

There are two ways to start your project:

Light-codegen generator

You can use light-codegen to generate a working project. Currently, it supports light-rest-4j, light-graphql-4j, light-hybrid-server-4j and light-hybrid-service-4j. light-eventuate code generator is coming.

The light-codegen project README.md describes four ways to use the generator with examples.

  • Clone and build the light-codgen and use the codegen-cli command line utility
  • Use docker image networknt/light-codegen to run the codegen-cli command line utility
  • Use generate.sh from model-config repo to generate projects based on conventions.
  • Generate code from web site with codegen-web API. (API is ready but UI needs to be built)

Starting from an example project

The other way to start your project is to copy from light-example-4j.

You can find the description of these examples

Also, there are some tutorials

Debugging

To run/debug from IDE, you need to configure a Java application with main class "com.networknt.server.Server" and working directory is your project folder. There is no container and you are working on just a standalone Java application.

Start Server

In IDE

create a Java application that main class is com.networknt.server.Server and working directory is your project root folder. You can debug your server just like a POJO application.

From Maven

mvn exec:exec

Command Line

java -jar target/demo-0.1.0.jar

Stop Server

you can use Ctrl+C to kill the server but for production use the following command

kill -s TERM <pid>

The server has a shutdown hook and the above command allow it to clean up. For example, complete in-flight requests and close the database connections etc. If service registry and discovery is used, then the server will send shutdown event to service registry and keep processing requests for 30 seconds until all clients refreshes their local cache before shutting down.

Appreciation

License

Light-4j and all light-*-4j frameworks are available under the Apache 2.0 license. See the LICENSE file for more info.

More Repositories

1

json-schema-validator

A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
Java
821
star
2

microservices-framework-benchmark

Raw benchmarks on throughput, latency and transfer of Hello World on popular microservices frameworks
C++
702
star
3

react-schema-form

react form based on json schema for form generation and validation
JavaScript
358
star
4

light-oauth2

A fast, light and cloud native OAuth 2.0 authorization microservices based on light-4j
Java
312
star
5

light-example-4j

Example APIs or services to demo all feature of the light-4j framework
Java
149
star
6

light-rest-4j

A RESTful framework built on top of light-4j with both Swagger 2.0 and OpenAPI 3.0 supports
Java
119
star
7

light-eventuate-4j

An eventual consistency framework based on Event Sourcing and CQRS on top of light-4j and Kafka
Java
59
star
8

light-codegen

A code generator based on rocker that can be used as an utility or web service
Java
40
star
9

light-graphql-4j

GraphQL implementation based on light-4j
JavaScript
31
star
10

light

A lightning fast light weight Omni-Channel Application framework based on Angularjs, Undertow, RuleEngine and Orientdb
Java
31
star
11

light-saga-4j

A saga implementation to manage distributed transaction across multiple microservices
Java
22
star
12

light-workflow-4j

A state machine based light-weight workflow engine for microservices orchrestration
Java
20
star
13

light-proxy

A fast reverse proxy with an embedded gateway to wrap third-party APIs and bring them to the ecosystem of light platform
Java
16
star
14

light-rule

A rule engine or rule as a service based on Kotlin DSL
Kotlin
15
star
15

light-docker

Dockerfile and compose to bring everything up together with your APIs
TSQL
13
star
16

light-spring-boot

Spring Boot customizers that allow light-4j middleware handlers to be injected in Undertow core
Java
13
star
17

model-config

A repository contains all model definition and light-codegen config for different frameworks
Shell
11
star
18

react-schema-form-rc-select

An add-on of react-schema-form that support multiple select and a demo for extending react-schema-form with new components.
JavaScript
11
star
19

light-email

An email sender based on Kafka Streams for Event Sourcing
Java
11
star
20

json-schema-validator-perftest

A performance test project that compares networknt, fge and everit json-schema-validator
Java
10
star
21

openapi-bundler

A utility that merges multiple OpenAPI specification files into a single file with all external references resolved to local reference.
Java
10
star
22

light-hybrid-4j

A hybrid between monolithic and microservices to take advantages of both
Java
10
star
23

light-doc

The hugo documents and templates repo that will be built to https://doc.networknt.com
CSS
10
star
24

light-session-4j

Distributed session managers (Redis, Hazelcast, JDBC) that support web server cluster for light-4j framework
Java
8
star
25

openapi-parser

A light-weight, fast OpenAPI 3.0 parser and validator with minimum third party dependencies
Java
8
star
26

jsontoken

google jsontoken with gson, joda and google collection removed. Work with java8 only.
Java
8
star
27

light-bot

A microservice based DevOps agent that handles multiple repositories and dependencies
Java
7
star
28

light-scheduler

a scalable event scheduler based on transactional Kafka streams and interactive queries
Java
7
star
29

http2client-benchmark

HTTP/2 client raw benchmark against light-4j server
Java
6
star
30

light-router

A client side service mesh router designed for legacy system that cannot leverage client module
Java
5
star
31

light-config-test

Default config files of light-4j for test environment on light-config-server
JavaScript
4
star
32

light-spa-4j

Middleware handlers for Single Page Application
Java
4
star
33

light-kafka

Components that help with light-4j and Kafka integration
Java
4
star
34

light-eventuate-example

Example projects based on light-eventuate framework
Java
4
star
35

light-tram-4j

Transactional Messaging framework for message/event/command driven interaction style
Java
4
star
36

light-aws-lambda

Aws lambda extensions for cross-cutting concerns
Java
3
star
37

light-consumer-4j

Light 4J Client Framework Dependency Module
Java
3
star
38

react-file-manager

A react remote file manager with Light Framework as back end file system. This is one of the admin tools that our customers manage their static files on shared host.
3
star
39

light-gateway

A standalone gateway combined both light-router and light-proxy
Java
3
star
40

taiji-blockchain

light block chain end user and merchant components
Java
3
star
41

light-lambda-native

A Lambda native gateway with cross-cutting concerns implemented in Java
Java
3
star
42

light-example-graal

Native Java Applications with GraalVM
Java
2
star
43

light-cms

Undertow and Angularjs based light weight CMS
JavaScript
2
star
44

swagger-bundler

A utility that merges multiple swagger files into a single file with all external references resolved to local reference.
Java
2
star
45

http-sidecar

HTTP sidecar of light-mesh to provide cross-cutting concerns for Kubernetes service
Java
2
star
46

light-mesh

A service mesh implementation based on the light-proxy and light-router with SMI support
2
star
47

kafka-sidecar

Kafka sidecar of light-mesh to provide cross-cutting concerns for Kubernetes service to interact with Kafka
Java
2
star
48

lambda-market

A demo market api consists several Lambda functions
Java
2
star
49

light-tram-kafka

light-tram-4j with Kafka transactional producer and consumer only
Java
1
star
50

light-workflow

A workflow engine or workflow as a service based on Kotlin DSL
1
star
51

light-supergloo

Middleware handlers that integrate with Solo.io SuperGloo ecosystem
1
star
52

light-hash

A command line utiltity that hashes the key or password with PBKDF2WithHmacSHA1
Java
1
star
53

yaml-rule-plugin

A repo that contains all the plugins for the light-gateway request and repsonse transformer
Java
1
star
54

http-client

An HTTP client based on JDK 11 http-client to invoke APIs with client-side cross-cutting concerns addressed
Java
1
star
55

light-example-kotlin

Light-4j example services implemented in Kotlin
Kotlin
1
star
56

light-commerce

An E-Commerce plugin on top of Light Framework to give users omni-experience for online shopping
JavaScript
1
star
57

portal-view

A react light-portal UI as a template for single page applications that interact with back end APIs
JavaScript
1
star
58

maven-plugin

plugins to load rule, form and page from file system through REST APIs
Java
1
star
59

doc.maproot.net

Document site for the maproot.net application based on Hugo
CSS
1
star
60

light-rfcs

Generic request for comments related to light platform
1
star
61

light-test

Testing rules
Java
1
star
62

json-overlay

A fork of RepreZen JsonOverlay with all dependencies and code generation removed
Java
1
star
63

yaml-rule

A simple rule engine with rules defined in YAML or JSON
Java
1
star
64

lambda-petstore

A petstore demo api consists of sever Lambda functions
Java
1
star