IfanTsai / mgx

:rainbow: A high performance network framework written in c++ (support tcp and http)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

中文

A high performance network framework using epoll, connections pool and threads pool (support tcp and http)

The framework doesn't depend on any third party components

The framework mainly implements the following features

  • a master process and multiple subprocesses(worker processes)
    • the master process is responsible for signal processing
      • such as reviving the subprocess, log rotate (kill -USER1 master_pid) ...
    • the worker processes handle specific network requests (use epoll LT mode)
  • configuration file and log system
  • threads pool processing client messages
  • a thread and message queues handle the sending of messages
  • delay reclaiming connections in connection pool
  • heartbeat packet mechanism and detection timer queue to reclain connections
  • using specific message format to solve tcp packet sticking problem

By default, the source code is configured to http mode. If you need to configure tcp mode, please modify the variable of config.mk under the root path.

export USE_HTTP = false

In addition, this project also implements a coroutine library, and implements a set of cosocket's APIs based on this coroutine library, but note that it's not integrated into above framework. You can see their use in the test directory.

Mainly realize code:

Note: The coroutine library currently only implements x86-64 and ARM64 platforms

Quick Start

start in host machine

make -j4
./mgx
curl 127.0.0.1:8081  # or view web page in browser

start in docker

docker build -t mgx:latest .
docker run -itd -p 8081:8081 mgx:latest
curl 127.0.0.1:8081  # or view web page in browser

You can access http://127.0.0.1:8081 to view the web page in browser

image-20220211203019092

The general structure of Mgx

About

:rainbow: A high performance network framework written in c++ (support tcp and http)


Languages

Language:C++ 87.1%Language:JavaScript 5.1%Language:Makefile 3.6%Language:HTML 1.6%Language:C 1.5%Language:Shell 0.4%Language:Dockerfile 0.3%Language:CSS 0.3%