Git Product home page Git Product logo

esa-restlight's Introduction

Restlight

Build codecov Maven Central GitHub license

Restlight is a lightweight and rest-oriented web framework.

Features

  • HTTP1.1/HTTP2/H2C/HTTPS support
  • SpringMVC and JAX-RS annotations support
  • High performance: 2 to 4 times Spring Web
  • Fully asynchronous: Based on CompletableFuture
  • Threading Model: Connector thread, IO thread, Biz thread
  • Thread Scheduling: Schedule requests to IO thread pool, Biz thread pool, or any custom thread pool
  • Self-Protection: Connection creation limit, CPU load overload protection
  • Spring Boot Actuator support
  • Extension: Use SPI(enhanced) to extend Restlight
  • Layered architecture: Use Restlight in Spring Boot, Spring, and embedded environment without compatibility issues
  • more...

Quick Start

Create a Spring Boot application and add dependency

Note:netty 4.1.52.Final and tcnative 2.0.34.Final are directly dependent on.

Note: Please make sure the version of tcnative matches the version of netty.

<dependency>
    <groupId>io.esastack</groupId>
    <artifactId>restlight-starter</artifactId>
    <version>${mvn.version}</version>
</dependency>

Write your Controller

@RestController
@SpringBootApplication
public class RestlightDemoApplication {

    @GetMapping("/hello")
    public String hello() {
        return "Hello Restlight!";
    }

    public static void main(String[] args) {
        SpringApplication.run(RestlightDemoApplication.class, args);
    }
}

Run your application and then you would see something like

Started Restlight server in 1265 millis on 0.0.0.0:8080

curl http://localhost:8080/hello

Performance

Test cases

  • We built an echo server by ESA Restlight and used a http client to do the requests for RPS testing with different bytes of payload(16B, 128B, 512B, 1KB, 4KB, 10KB) and different Threading-Models(IO, BIZ).
  • Also we used spring-boot-starter-web(2.3.2.RELEASE) to build a server which is same with above for RPS testing.

Hardware Used

We used the following software for the testing:

  • wrk4.1.0

  • OS CPU Mem(G)
    server centos:6.9-1.2.5(docker) 4 8
    client centos:7.6-1.3.0(docker) 16 3

JVM Options

-server -Xms3072m -Xmx3072m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -XX:+PrintTenuringDistribution -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc-${appName}-%t.log -XX:NumberOfGCLogFiles=20 -XX:GCLogFileSize=480M -XX:+UseGCLogFileRotation -XX:HeapDumpPath=.

Server Options

Framework Options
Restlight restlight.server.io-threads=8
restlight.server.core-biz-threads=16
restlight.server.max-biz-threads=16
restlight.server.blocking-queue-length=512
Spring Web server.tomcat.threads.max=32
server.tomcat.accept-count=128

RPS

16B 128B 512B 1KB 4KB 10KB
Restlight(IO) 129457.26 125344.89 125206.74 116963.24 85749.45 49034.57
Restlight(BIZ) 101385.44 98786.62 97622.33 96504.81 68235.2 46460.79
Spring Web 35648.27 38294.94 37940.3 37497.58 32098.65 22074.94

See more details in Reference Doc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.