All Projects → BurgerGroup → Burger

BurgerGroup / Burger

Licence: MIT license
🍔 c++11 Server based on coroutine and reactor

Programming Languages

C++
36643 projects - #6 most used programming language
Ragel
52 projects
CMake
9771 projects
assembly
5116 projects
c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Burger

Easyswoole
swoole,easyswoole,swoole framework
Stars: ✭ 4,409 (+7501.72%)
Mutual labels:  tcp-server, coroutine
trantor
a non-blocking I/O tcp network lib based on c++14/17
Stars: ✭ 205 (+253.45%)
Mutual labels:  tcp-server, non-blocking-io
Mgx
🌈 A high performance network framework written in c++ (support tcp and http)
Stars: ✭ 15 (-74.14%)
Mutual labels:  tcp-server, coroutine
Swoft
🚀 PHP Microservice Full Coroutine Framework
Stars: ✭ 5,420 (+9244.83%)
Mutual labels:  tcp-server, coroutine
tcpserver
A TCP Server with simple and clean API
Stars: ✭ 12 (-79.31%)
Mutual labels:  tcp-server
mt4-tcp
Winsock bindings for MetaTrader 4 platform
Stars: ✭ 24 (-58.62%)
Mutual labels:  tcp-server
cAndroid
cAndroid is tool for control your PC by Android phone
Stars: ✭ 23 (-60.34%)
Mutual labels:  tcp-server
tcp-net
Build tcp applications in a stable and elegant way
Stars: ✭ 42 (-27.59%)
Mutual labels:  tcp-server
zhamao-framework
协程、高性能、灵活的聊天机器人 & Web 开发框架(炸毛框架)
Stars: ✭ 99 (+70.69%)
Mutual labels:  coroutine
ext-postgresql
🐘 Coroutine-based client for PostgreSQL
Stars: ✭ 62 (+6.9%)
Mutual labels:  coroutine
ctsTraffic
ctsTraffic is a highly scalable client/server networking tool giving detailed performance and reliability analytics
Stars: ✭ 125 (+115.52%)
Mutual labels:  tcp-server
machat
An open source chat server implemented in Go
Stars: ✭ 73 (+25.86%)
Mutual labels:  tcp-server
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-65.52%)
Mutual labels:  coroutine
trellio
Python3 asyncio based microframework for microservice architecture
Stars: ✭ 19 (-67.24%)
Mutual labels:  tcp-server
DiscordCoreAPI
A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
Stars: ✭ 104 (+79.31%)
Mutual labels:  coroutine
WebServer
C++高性能网络服务器
Stars: ✭ 53 (-8.62%)
Mutual labels:  muduo
python3-concurrency
Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别
Stars: ✭ 49 (-15.52%)
Mutual labels:  coroutine
nj
NJ is a simple script engine in golang with Lua-like syntax.
Stars: ✭ 19 (-67.24%)
Mutual labels:  coroutine
BeauRoutine
Coroutine and tweening framework for Unity3D
Stars: ✭ 88 (+51.72%)
Mutual labels:  coroutine
h5pp
A C++17 interface for HDF5
Stars: ✭ 60 (+3.45%)
Mutual labels:  spdlog
burger

c++11基于协程和reator的高性能Linux服务器框架


特征

  • 能使用协程和reactor两种模式构建网络应用
  • 现代版的C++11接口,利用c++11新的特性,利用chrono时间,thread库,非阻塞异步接口利用C++11的functional/bind形式的回调仿函数
  • 协程模式中能够用同步的方式表现出异步的特性,简化编码的逻辑
  • 封装了spdlog库,更加方便高效地使用高性能日志
  • 封装了mysql c api,使得mysql使用更加简单

⌛️ 构建

$ sudo apt install g++ cmake make libboost-all-dev mysql-server libmysqlclient-dev libcurl4-openssl-dev libbenchmark-dev
 
$ git clone https://github.com/BurgerGroup/Burger.git

$ cd Burger

$ mkdir build && cmake ..

$ make 

$ make install   

🥇 性能测试

🍭 示例

协程echo server:

#include <burger/net/CoTcpServer.h>
#include <burger/base/Log.h>
#include <burger/net/RingBuffer.h>

using namespace burger;
using namespace burger::net;

void connHandler(CoTcpConnection::ptr conn) {
    RingBuffer::ptr buffer = std::make_shared<RingBuffer>();
    while(conn->recv(buffer) > 0) {
        conn->send(buffer);
    }
}

int main() {
    LOGGER(); LOG_LEVEL_DEBUG;
    Scheduler sched;
    InetAddress listenAddr(8888);

    CoTcpServer server(&sched, listenAddr);
    server.setConnectionHandler(connHandler);
    server.start();

    sched.wait();
    return 0;
}

💎 模块

配置模块

我们采用ini作为配置文件

定义一个协程的栈大小

[coroutine]
stackSize = 3 * 1024 * 1024

利用Config::Instance去获取ini配置文件

auto& configManager = Config::Instance("/NewConfig/conf.ini");

configManager.getString("coroutine", "stackSize");

协程模块

协程:用户态的线程,更轻量级。通过hook系统函数,把复杂的异步调用,封装成同步操作。降低业务逻辑的编写复杂度。

采用boost.context里面的fcontext_t的方式实现

Coroutine::ptr co = std::make_shared<Coroutine>(func);

实际上我们没有向用户暴露co这个概念,用户是不应该自己去创建co的,而是以callback的形式告诉希望完成什么任务。

协程调度模块

schedule 负责整个系统的协程调度,Schduler带有一个线程池,而协程的运行依赖于执行器 Processor,每一个线程拥有一个Processor,可以算作一个per thread one processor模型,是一个1:N的协程调度模型。

Hook模块

hook系统底层和socket相关的API,socket io相关的API,以及sleep系列的API。hook的开启控制是线程粒度的。可以自由选择。通过hook模块,可以使一些不具异步功能的API,展现出异步的性能。

📚 文档

基于Burger的项目

  • BurgerChat - 🍔 Console-based chat IM for Linux

Maintainers

@chanchann.

@skyu98.

如有任何问题,请发送邮件 [email protected] 交流学习

讨论学习群 : 873966642

致谢

感谢[spdlog], [gtest] 等项目, Burger的reactor部分架构深度参考了muduo项目的实现和设计,为上层项目开发而保留,非常感谢Chen Shuo大佬!!!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].