22

GitHub - xincao9/jsonrpc: high-performance RPC framework.

 5 years ago
source link: https://github.com/xincao9/jsonrpc
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

jsonrpc

logo

high-performance RPC framework.

jsonrpc is a high-performance, Java based open source RPC framework.

JSONRPC IN ACTION

Maven dependency

<dependency>
    <groupId>com.github.xincao9</groupId>
    <artifactId>jsonrpc-spring-boot-starter</artifactId>
    <version>1.2.4</version>
</dependency>

object


public class Say {

    private Integer id;
    private String body;

    public Say(Integer id, String body) {
        this.id = id;
        this.body = body;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
    
        this.body = body;
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect);
    }
}

interface

public interface SayService {

    Say perform(Say say);
}

service

@JsonRPCService
public class SayServiceImpl implements SayService {

    @Override
    public Say perform(Say say) {
        return say;
    }

}

service provider

@SpringBootApplication
@EnableJsonRPC(server = true)
public class ApplicationProvider {

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

service consumer

@SpringBootApplication
@EnableJsonRPC(client = true)
public class ApplicationConsumer {

    @JsonRPCAutowired
    private SayService sayService;


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

    @Bean
    public CommandLineRunner commandLineRunner() {
        return (String... args) -> {
            for (int no = 0; no < 100; no++) {
                String value = RandomStringUtils.randomAscii(128);
                Say say = new Say(no, value);
                System.out.println(sayService.perform(say));
            }
        };
    }

}

application.properties

## discovery support
jsonrpc.discovery.zookeeper=localhost:2181

## consumer
jsonrpc.client.serverList=localhost:12306
jsonrpc.client.connectionTimeoutMS=5000
jsonrpc.client.invokeTimeoutMS=1000

## provider
jsonrpc.server.port=12306

benchmark

Get the pressure measurement component
wget https://oss.sonatype.org/service/local/repositories/releases/content/com/github/xincao9/jsonrpc-benchmark/1.2.4/jsonrpc-benchmark-1.2.4.jar

dubbo pressure test

java -Dspring.profiles.active=dubbo-provider -cp target/jsonrpc-benchmark-1.2.4.jar com.github.xincao9.jsonrpc.benchmark.provider.jsonrpc.JsonRPCApplication
java -Dspring.profiles.active=dubbo-consumer -cp target/jsonrpc-benchmark-1.2.4.jar com.github.xincao9.jsonrpc.benchmark.consumer.jsonrpc.JsonRPCApplication

wrk -c 16 -t 2 -d 30s 'http://localhost:9001/dubbo/stream'

Running 30s test @ http://localhost:9001/dubbo/stream
  2 threads and 16 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     4.30ms   12.93ms 294.76ms   97.36%
    Req/Sec     3.04k     1.32k    6.27k    70.67%
  181921 requests in 30.06s, 42.19MB read
Requests/sec:   6052.90
Transfer/sec:      1.40MB

wrk -c 16 -t 2 -d 30s 'http://localhost:9001/dubbo/stream'

Running 30s test @ http://localhost:9001/dubbo/stream
  2 threads and 16 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.69ms    1.88ms  54.01ms   97.53%
    Req/Sec     5.19k   810.88     6.61k    74.67%
  310323 requests in 30.03s, 71.97MB read
Requests/sec:  10332.60
Transfer/sec:      2.40MB

wrk -c 128 -t 16 -d 30s 'http://localhost:9001/dubbo/sleep'

Running 30s test @ http://localhost:9001/dubbo/sleep
  16 threads and 128 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    28.59ms   15.57ms 132.69ms   58.34%
    Req/Sec   281.17     35.11   440.00     72.15%
  134779 requests in 30.10s, 17.99MB read
Requests/sec:   4477.63
Transfer/sec:    612.09KB

wrk -c 128 -t 16 -d 30s 'http://localhost:9001/dubbo/sleep'

Running 30s test @ http://localhost:9001/dubbo/sleep
  16 threads and 128 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    29.20ms   15.51ms  71.46ms   57.97%
    Req/Sec   274.92     33.02   414.00     66.60%
  131789 requests in 30.10s, 17.59MB read
Requests/sec:   4378.68
Transfer/sec:    598.58KB

jsonrpc pressure test

java -Dspring.profiles.active=jsonrpc-provider -cp target/jsonrpc-benchmark-1.2.4.jar com.github.xincao9.jsonrpc.benchmark.provider.dubbo.DubboApplication
java -Dspring.profiles.active=jsonrpc-consumer -cp target/jsonrpc-benchmark-1.2.4.jar com.github.xincao9.jsonrpc.benchmark.consumer.dubbo.DubboApplication

wrk -c 16 -t 2 -d 30s 'http://localhost:8001/jsonrpc/stream'

Running 30s test @ http://localhost:8001/jsonrpc/stream
  2 threads and 16 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.07ms    2.39ms  45.15ms   93.64%
    Req/Sec     4.58k     2.12k    8.02k    58.33%
  273896 requests in 30.03s, 63.52MB read
Requests/sec:   9119.72
Transfer/sec:      2.12MB

wrk -c 16 -t 2 -d 30s 'http://localhost:8001/jsonrpc/stream'

Running 30s test @ http://localhost:8001/jsonrpc/stream
  2 threads and 16 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.15ms    1.24ms  46.94ms   98.75%
    Req/Sec     7.13k   460.27     8.19k    80.33%
  426195 requests in 30.01s, 98.84MB read
Requests/sec:  14200.14
Transfer/sec:      3.29MB

wrk -c 128 -t 16 -d 30s 'http://localhost:8001/jsonrpc/sleep'

Running 30s test @ http://localhost:8001/jsonrpc/sleep
  16 threads and 128 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    29.60ms   17.86ms 248.54ms   66.38%
    Req/Sec   277.16     44.00   420.00     79.63%
  132378 requests in 30.10s, 17.67MB read
Requests/sec:   4397.55
Transfer/sec:    601.16KB

wrk -c 128 -t 16 -d 30s 'http://localhost:8001/jsonrpc/sleep'

Running 30s test @ http://localhost:8001/jsonrpc/sleep
  16 threads and 128 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    28.31ms   15.43ms  68.45ms   57.67%
    Req/Sec   283.50     32.58   450.00     68.29%
  135912 requests in 30.10s, 18.14MB read
Requests/sec:   4514.74
Transfer/sec:    617.15KB

Data Form

Frame interface thread link Numbers QPS throughput Average time dubbo /dubbo/stream 2 16 1 6052.90 42.19MB 4.30ms dubbo /dubbo/stream 2 16 2 10332.60 71.97MB 1.69ms jsonrpc /jsonrpc/stream 2 16 1 9119.72 63.52MB 2.07ms jsonrpc /jsonrpc/stream 2 16 2 14200.14 98.84MB 1.15ms dubbo /dubbo/sleep 16 128 1 4477.63 17.99MB 28.59ms dubbo /dubbo/sleep 16 128 2 4378.68 17.59MB 29.20ms jsonrpc /jsonrpc/sleep 16 128 1 4397.55 17.67MB 29.60ms jsonrpc /jsonrpc/sleep 16 128 2 4514.74 18.14MB 28.31ms

Conclusion: jsonrpc outperforms dubbo 30% in compute-intensive services and easily reaches the limit of NIC throughput. Analysis of the reasons, dubbo in order to adapt to multiple protocols and coupling multiple service governance modules, resulting in performance loss. There is no gap in IO-intensive

tips

  • Welcome to see detailed examples examples
  • Not only supports the boot mode of springboot
  • Native boot mode, the default configuration file is named config.properties
  • @EnableJsonRPC(server = true, client = true) Indicates that the service is a consumer even if the provider

Contact


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK