saf application framework 高并发C++应用程序框架 项目简介
saf (saf application framework) 是一个高并发的c++应用程序框架,它以RPC为基础,提供了动态载入模块的特性,为服务端开发人员只用关注于程序的业务逻辑,就可以实现远程方法调用,而不会关心底层的通信细节,另外,它还内置了一个简单的http server,用来查看服务器的运行状态。 特点1:基于 google protobuf 的 RPC 框架2:内置简单的http server用于查看系统状态3:模块化的管理,只用在lib中增加动态库就可以达到增加rpc service的目的结构 +--------------+
+-----------+ +------------+ /| |
| | | | / | Handle Thread| --->-
|Net Thread \----->| Decode |\ / +--------------+ |
+-----------+\ +------------+ \ +-----------------+ / +--------------+ |
\ \>| |/ | | |
\ />|Dispacher Thread +-----+ Handle Thread+---->+
+-----------+ \ +------------+ / +-----------------+\ +--------------+ |
| | \ | |/ \ +--------------+ |
|Net Thread +----+>+ Decode / \ | | |
+-----------+ \+------------+ \ | Handle Thread| |
\ \ +---------+----+ |
\ \ | |
\ \ | |
\ +--\---------+ | |
\ | |<-------------------------------------+ |
\ | Encode | |
\ +------------+ |
\ +------------+ |
\| | |
\ Encode +<------------------------------------------------+
+------------+编译例子1:下载源码,它依赖与sails公共库:git clone --recursive https://github.com/sails/saf.git2:执行编辑脚本:./build.sh3:编译测试样例:cd example
./build_test.sh4:运行测试,比如运行echo_sync:./src/server
./example/echo_sync/client5:增加子模块,配置conf/sails.json:在modules里增加一行,name是子模块名,path是子模块动态库的路径性能测试一笔记本: T6400 @ 2.00GHz, cpu num:1, cpu cores:2服务端和客户端都运行在这台电脑上| server handle threads | client call threads | earch threads call num | run time |
|-----------------------+---------------------+------------------------+-----------|
| 1 | 1 | 100000 | 0m14.674s |
| 1 | 5 | 100000 | 0m30.896s |
| 1 | 10 | 100000 | 1m0.848s |
| 2 | 1 | 100000 | 0m14.409s |
| 2 | 5 | 100000 | 0m27.911s |
| 2 | 10 | 100000 | 0m50.760s |2w tps.因为客户端和服务器在同一台电脑上,所以测试结果会比实际更低.统计内置http服务器的默认绑定在端口8001上,所以可以通过输入localhost:8001/stat来查看统计信息:
+-----------+ +------------+ /| |
| | | | / | Handle Thread| --->-
|Net Thread \----->| Decode |\ / +--------------+ |
+-----------+\ +------------+ \ +-----------------+ / +--------------+ |
\ \>| |/ | | |
\ />|Dispacher Thread +-----+ Handle Thread+---->+
+-----------+ \ +------------+ / +-----------------+\ +--------------+ |
| | \ | |/ \ +--------------+ |
|Net Thread +----+>+ Decode / \ | | |
+-----------+ \+------------+ \ | Handle Thread| |
\ \ +---------+----+ |
\ \ | |
\ \ | |
\ +--\---------+ | |
\ | |<-------------------------------------+ |
\ | Encode | |
\ +------------+ |
\ +------------+ |
\| | |
\ Encode +<------------------------------------------------+
+------------+编译例子1:下载源码,它依赖与sails公共库:git clone --recursive https://github.com/sails/saf.git2:执行编辑脚本:./build.sh3:编译测试样例:cd example
./build_test.sh4:运行测试,比如运行echo_sync:./src/server
./example/echo_sync/client5:增加子模块,配置conf/sails.json:在modules里增加一行,name是子模块名,path是子模块动态库的路径性能测试一笔记本: T6400 @ 2.00GHz, cpu num:1, cpu cores:2服务端和客户端都运行在这台电脑上| server handle threads | client call threads | earch threads call num | run time |
|-----------------------+---------------------+------------------------+-----------|
| 1 | 1 | 100000 | 0m14.674s |
| 1 | 5 | 100000 | 0m30.896s |
| 1 | 10 | 100000 | 1m0.848s |
| 2 | 1 | 100000 | 0m14.409s |
| 2 | 5 | 100000 | 0m27.911s |
| 2 | 10 | 100000 | 0m50.760s |2w tps.因为客户端和服务器在同一台电脑上,所以测试结果会比实际更低.统计内置http服务器的默认绑定在端口8001上,所以可以通过输入localhost:8001/stat来查看统计信息: