Skip to content

mfavant/avant

Repository files navigation

Avant

Docker Image CI

A High-Performance Network Messaging Framework for Linux C++.

  • Language: C++ 20
  • Platform: Linux
  • Protocols: HTTP(S) | TCP Stream(Protobuf) | WebSocket | UDP(Protobuf)
  • TLS/SSL: OpenSSL
  • Lua: Lua 5.4.8

Overview

Avant is a modular and extensible network framework for Linux, designed to serve as a foundation for building customized network services rather than providing fixed, opinionated solutions.

It can be used to implement HTTP servers, WebSocket-based services, and high-performance TCP or UDP communication using Protocol Buffers. Avant also provides an IPC mechanism based on TCP and Protobuf for internal service communication.

A practical example built on top of Avant is mapsvr, a game server framework that supports TCP Protobuf, WebSocket Protobuf, UDP Protobuf, and IPC TCP Protobuf, with Lua scripting and hot-reload support.

Avant focuses on providing core networking components and infrastructure. Application-level logic, protocols, and workflows are intentionally left to the user, allowing maximum flexibility and customization.

Avant is particularly suitable for developers who want to build customized and experimental network applications in C++ without relying on large, opinionated frameworks such as Boost or event-driven libraries like libevent. Its clear and approachable codebase exposes core networking concepts directly, making it easier to design application-specific protocols and workflows.

For C++ beginners, Avant can also serve as a practical learning project for understanding Linux system programming, network I/O, and multi-threaded server architecture.

Docker Image

docker run --privileged \
    -p 20023:20023 \
    -v ${LOCAL_HTTP_DIR_PATH}:/avant_static \
    gaowanlu/avant:latest

Getting Started

If some dependencies are already installed on the host, you may skip them.

Ubuntu Example

docker run -it ubuntu:latest bash

apt-get update

apt-get install -y \
    apt-utils \
    cmake g++ make git \
    protobuf-compiler libprotobuf-dev \
    libssl-dev

git clone https://github.com/crust-hub/avant.git

cd avant/protocol && make

cd ..

mkdir -p build
rm -rf ./build/*

cd build
cmake ..
make -j4

See: Other Installing Third-Party Example

Configuration

sudo mkdir /avant_static
vim bin/config/main.ini

Running

cd bin
./avant
ps -ef | grep avant

Stop

ps -ef | grep avant
kill PID

Application Layer

Avant supports HTTP, WebSocket, UDP, and TCP streaming (Protobuf):

  1. framework config
  2. tcp_stream protobuf app
  3. http app
  4. websocket app
  5. other_app::on_udp_server_recvfrom

Client Implementations

Lua

Each thread (main, worker, auxiliary) runs in its own isolated Lua virtual machine.

  • Entry script: bin/lua/Init.lua

Lua Hot Reload

Lua scripts can be reloaded at runtime using SIGUSR1 without restarting the process:

ps -ef | grep avant
kill -USR1 <PID>

IPC

Benchmark

Using wrk

wrk -c {{connection_num}} -t {{threads}} -d60s \
    --header "Connection: keep-alive" \
    http://127.0.0.1:20023/

Third-Party Dependencies

  1. @nodejs/llhttp
  2. @lua/lua
  3. @protocolbuffers/protobuf
  4. @openssl/openssl
  5. @madler/zlib
  6. @homer6/url

Releases

No releases published

Packages

No packages published