Git Product home page Git Product logo

little_rpc's Introduction

little_rpc

by haoyifen on 2017/6/1 17:33

一个超轻量级的RPC服务注册, 发现, 调用的框架.

使用Spring Boot管理Bean以及自动配置, 使用Netty处理网络请求, 使用ProtoStuff编解码, 使用Zookeeper作为服务注册和发现. 使用Quasar替代线程进行服务的调用.

来源

源于以下两篇文章

一个轻量级分布式RPC框架--NettyRpc

http://www.cnblogs.com/luxiaoxun/p/5272384.html

轻量级分布式 RPC 框架

https://my.oschina.net/huangyong/blog/361751

改进

纤程quasar

在他们的基础之上, 将基于线程的调度方式改成了quasar纤程. 当服务调用阻塞时, 相对于线程调度的方式, 大大提高了rps.

模块划分

将模块划分开. RPC_Common模块拥有所有的服务注册, 服务扫描, 服务获取功能, 具体的业务模块将不与这些代码耦合.

Spring Boot自动配置

使用Spring Boot的自动配置来配置这些功能. 使用自定义注解@EnableServiceRegistry来启动服务端的配置和注册. 使用自定义注解@EnableServiceDiscovery来启动客户端的服务发现和连接管理功能.

范例可以见little_rpc_server模块和little_rpc_client模块.

性能对比

以下测试都是基于4核i7二代笔记本CPU, 2.2G, Win10的测试. 且服务端和客户端运行于同一台笔记本上.

little_rpc

little_rpc因为使用了协程, 能够在使用8个线程的情况下, 达到8K-1W rqs/s的速度, 而无论服务端的阻塞时间多长.

Netty_RPC

而上面文章中的Netty_RPC使用的是线程进行调用. 当服务端不阻塞, 马上返回, Netty_RPC也能到达8K-1W rqs/s的速度, 但是当服务端阻塞时间很长时, 客户端调用线程也将阻塞. 如果服务端的调用延时为t ms, 客户端的线程数为N. 那么客户端的rqs大致为N*1000/t 每秒, 当t很大时, rqs会迅速衰减. 客户端8个线程, 服务端的调用耗时10ms时, rqs会降为700-800.

little_rpc's People

Contributors

yifhao avatar

Watchers

James Cloos avatar  avatar

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.