JRPC是一个轻量级的java RPC框架。它支持服务注册和发现。

目前它开源了,地址为:https://github.com/dinstone/jrpc。

Quick Start

step 1:

git clone https://github.com/dinstone/jrpc.git

step 2:

maven install.

step 3:

select transport implement,add 'mina' or 'netty' dependency:

<dependency>
<groupId>com.dinstone.jrpc</groupId>
<artifactId>jrpc-transport-mina</artifactId>
<version>${jrpc.version}</version>
</dependency>

or

<dependency>
<groupId>com.dinstone.jrpc</groupId>
<artifactId>jrpc-transport-netty4</artifactId>
<version>${jrpc.version}</version>
</dependency>

if you need service registry and discovery, please add dependencies :

<dependency>
<groupId>com.dinstone.jrpc</groupId>
<artifactId>jrpc-registry-zookeeper</artifactId>
<version>${jrpc.version}</version>
</dependency>

If you are integrated with Spring, please add dependencies :

<dependency>
<groupId>com.dinstone.jrpc</groupId>
<artifactId>jrpc-spring</artifactId>
<version>${jrpc.version}</version>
</dependency>

Example

For more details, please refer to the example project : jrpc-example

java programming by API

export service:

Server server = new Server("localhost", 4444);
ServiceExporter serviceExporter = server.getServiceExporter();
serviceExporter.exportService(HelloService.class, new HelloServiceImpl()); System.in.read(); server.destroy();

import service:

Client client = new Client("localhost", 4444);
ServiceImporter serviceImporter = client.getServiceImporter();
HelloService helloService = serviceImporter.importService(HelloService.class);
helloService.sayHello("dinstone"); client.destroy();

declarative programming by Spring

export service:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jrpc="http://www.dinstone.com/schema/jrpc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.dinstone.com/schema/jrpc http://www.dinstone.com/schema/jrpc-3.0.xsd"> <jrpc:server>
<jrpc:registry schema="zookeeper">
<jrpc:property key="zookeeper.node.list" value="localhost:2181" />
</jrpc:registry>
<jrpc:transport schema="mina" address="-:2001" />
</jrpc:server>
<jrpc:service interface="com.dinstone.jrpc.example.HelloService" implement="helloService" group="product-v1.0" timeout="2000" /> <bean id="helloService" class="com.dinstone.jrpc.example.HelloServiceImpl" />
</beans>

import service:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jrpc="http://www.dinstone.com/schema/jrpc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.dinstone.com/schema/jrpc http://www.dinstone.com/schema/jrpc-3.0.xsd"> <jrpc:client name="netty-client">
<jrpc:registry schema="zookeeper">
<jrpc:property key="zookeeper.node.list" value="localhost:2181" />
</jrpc:registry>
<jrpc:transport schema="netty">
<jrpc:property key="rpc.serialize.type" value="2" />
</jrpc:transport>
</jrpc:client>
<jrpc:reference id="rhsv1" interface="com.dinstone.jrpc.example.HelloService" group="product-v1.0" />
</beans>

Test Result

JVM Parameter

-server -Xmx1g -Xms1g -Xmn712m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70

Case: Server[netty5] Client[netty5]

1 Threads,  500 Bytes,  4824 ms,    AVG: 2072 tps
10 Threads, 500 Bytes, 17325 ms, AVG: 5772 tps
20 Threads, 500 Bytes, 13456 ms, AVG: 14863 tps
32 Threads, 500 Bytes, 11134 ms, AVG: 28740 tps
1 Threads, 1024 Bytes, 1101 ms, AVG: 9082 tps
10 Threads, 1024 Bytes, 5809 ms, AVG: 17214 tps
20 Threads, 1024 Bytes, 9108 ms, AVG: 21958 tps
32 Threads, 1024 Bytes, 14622 ms, AVG: 21884 tps
40 Threads, 1024 Bytes, 17692 ms, AVG: 22609 tps

Case: Server[netty5] Client[mina]

1 Threads,  500 Bytes,  994 ms, AVG: 10060 tps
10 Threads, 500 Bytes, 4516 ms, AVG: 22143 tps
20 Threads, 500 Bytes, 8555 ms, AVG: 23378 tps
32 Threads, 500 Bytes, 13801 ms, AVG: 23186 tps
1 Threads, 1024 Bytes, 1027 ms, AVG: 9737 tps
10 Threads, 1024 Bytes, 6488 ms, AVG: 15413 tps
20 Threads, 1024 Bytes, 12776 ms, AVG: 15654 tps
32 Threads, 1024 Bytes, 20318 ms, AVG: 15749 tps
40 Threads, 1024 Bytes, 26149 ms, AVG: 15296 tps

Case: Server[mina] Client[mina]

1 Threads,  500 Bytes,  919 ms, AVG: 10881 tps
10 Threads, 500 Bytes, 2437 ms, AVG: 41034 tps
20 Threads, 500 Bytes, 4149 ms, AVG: 48204 tps
32 Threads, 500 Bytes, 6694 ms, AVG: 47804 tps
1 Threads, 1024 Bytes, 957 ms, AVG: 10449 tps
10 Threads, 1024 Bytes, 3168 ms, AVG: 31565 tps
20 Threads, 1024 Bytes, 6071 ms, AVG: 32943 tps
32 Threads, 1024 Bytes, 9485 ms, AVG: 33737 tps
40 Threads, 1024 Bytes, 11735 ms, AVG: 34086 tps

Case: Server[mina] Client[netty5]

1 Threads,  500 Bytes,  1046 ms,    AVG: 9560 tps
10 Threads, 500 Bytes, 5234 ms, AVG: 19105 tps
20 Threads, 500 Bytes, 6962 ms, AVG: 28727 tps
32 Threads, 500 Bytes, 9193 ms, AVG: 34809 tps
1 Threads, 1024 Bytes, 1096 ms, AVG: 9124 tps
10 Threads, 1024 Bytes, 5069 ms, AVG: 19727 tps
20 Threads, 1024 Bytes, 6591 ms, AVG: 30344 tps
32 Threads, 1024 Bytes, 10526 ms, AVG: 30400 tps
40 Threads, 1024 Bytes, 12216 ms, AVG: 32743 tps

JRPC 轻量级RPC框架的更多相关文章

  1. 微博轻量级RPC框架Motan

    Motan 是微博技术团队研发的基于 Java 的轻量级 RPC 框架,已在微博内部大规模应用多年,每天稳定支撑微博上亿次的内部调用.Motan 基于微博的高并发和高负载场景优化,成为一套简单.易用. ...

  2. C# 的轻量级 RPC 框架

    Redola.Rpc 的一个小目标 Redola.Rpc 的一个小目标 Redola.Rpc 的一个小目标:20000 tps. Concurrency level: 8 threads Comple ...

  3. 微博轻量级RPC框架Motan正式开源:支撑千亿调用

    支撑微博千亿调用的轻量级 RPC 框架 Motan 正式开源了,项目地址为https://github.com/weibocom/motan. 微博轻量级RPC框架Motan正式开源 Motan 是微 ...

  4. 轻量级RPC框架开发

    nio和传统io之间工作机制的差别 自定义rpc框架的设计思路 rpc框架的代码运行流程 第2天 轻量级RPC框架开发 今天内容安排: 1.掌握RPC原理 2.掌握nio操作 3.掌握netty简单的 ...

  5. 基于Netty和SpringBoot实现一个轻量级RPC框架-协议篇

    基于Netty和SpringBoot实现一个轻量级RPC框架-协议篇 前提 最近对网络编程方面比较有兴趣,在微服务实践上也用到了相对主流的RPC框架如Spring Cloud Gateway底层也切换 ...

  6. 基于Netty和SpringBoot实现一个轻量级RPC框架-Server篇

    前提 前置文章: Github Page:<基于Netty和SpringBoot实现一个轻量级RPC框架-协议篇> Coding Page:<基于Netty和SpringBoot实现 ...

  7. 基于Netty和SpringBoot实现一个轻量级RPC框架-Client篇

    前提 前置文章: <基于Netty和SpringBoot实现一个轻量级RPC框架-协议篇> <基于Netty和SpringBoot实现一个轻量级RPC框架-Server篇> 前 ...

  8. 基于Netty和SpringBoot实现一个轻量级RPC框架-Client端请求响应同步化处理

    前提 前置文章: <基于Netty和SpringBoot实现一个轻量级RPC框架-协议篇> <基于Netty和SpringBoot实现一个轻量级RPC框架-Server篇> & ...

  9. Netty + Spring + ZooKeeper搭建轻量级RPC框架

    本文参考 本篇文章主要参考自OSCHINA上的一篇"轻量级分布式 RPC 框架",因为原文对代码的注释和讲解较少,所以我打算对这篇文章的部分关键代码做出一些详细的解释 在本篇文章中 ...

随机推荐

  1. ntp-keygen.c

    这个程序产生加密数据文件使用的的密码,遵循Autokey security protocol和NTPv4.文件名被名字和创建时间组成的头部当做前缀,后面跟有一个类型定义的描述符标签和PEM加密的数据结 ...

  2. android下m、mm、mmm编译命令的使用

    android下m.mm.mmm编译命令的使用 通过查看android源码目录下的build/envsetup.sh文件,可知: - m:       Makes from the top of th ...

  3. c# 去除文本的html标签

    public static string ContentReplace(string input) { input = Regex.Replace(input, @"<(.[^> ...

  4. MOSFET与MOSFET驱动电路原理及应用(转)

    源:http://www.micro-bridge.com/news/news.asp?id=258 在使用MOS管设计开关电源或者马达驱动电路的时候,大部分人都会考虑MOS的导通电阻,最大电压等,最 ...

  5. angular Jsonp的坑

    angular 为了解决跨域问题 一些第三方接口会提供jsonp来调用,需要使用callback=JSON_CALLBACK来处理 这个时候问题来了,有些借口是不支持callback里面带有点语法的, ...

  6. POj-3104 Drying 二分+贪心

    题目大意:有n件湿的衣服,每件衣服都有相应的湿度,每分钟每件衣服的湿度减1(除了在烘干机里的衣服),现在有一个烘干机,烘干机一分钟可以让一件衣服的湿度降低k,问至少要花多少分钟才能使每件衣服的湿度为0 ...

  7. 基于Redis的在线用户列表解决方案

    前言: 由于项目需求,需要在集群环境下实现在线用户列表的功能,并依靠在线列表实现用户单一登陆(同一账户只能一处登陆)功能: 在单机环境下,在线列表的实现方案可以采用SessionListener来完成 ...

  8. js获取屏幕和窗口的信息

    <html><script>function a(){document.write("屏幕分辨率为:"+screen.width+"*" ...

  9. android — JNI注册方法说明

    Jni中还可以采用RegisterNatives来注册jni的方法,注册以后的jni函数的命名可以不需要符合类似javah命令生成的函数的规则 RegisterNatives为JNIEnv的成员函数, ...

  10. CSS中的浮动清除

    先来看一个实验:现在有两个div,div身上没有任何属性.每个div中都有li,这些li都是浮动的. 理想的效果:可实际的效果: 这个地方就涉及到浮动,因为两个父元素div都没有高度(或者小于子元素的 ...