Go network programming framework, supports multiplexing, synchronous and asynchronous IO mode, modular design, and provides flexible custom interfaces

ListenRain

GitHub license

Go network programming framework, supports multiplexing, adopts full-duplex working mode, supports synchronous and asynchronous request mode, modular design, and provides flexible custom interfaces. The key is the transport layer, the application layer protocol has nothing to do.

Applicable scene

  • Business needs change quickly
  • Data flow (forwarding plane) service
  • Need to customize the transmission protocol
  • Sensitive to GC

Architecture

listenrain

The parallelogram represents the interface. It can be seen from the figure that the interface is fully reused on both the server and the client. A brief introduction to the functions of the next few interfaces:

  • EncodePacket/DecodePacket: Responsible for solving the sticky packet problem of data receiving and sending. Through this interface, memory can be reclaimed when sending and receiving data, or memory can be allocated from the memory pool, providing more options for performance optimization (such as reducing GC). Refer to benchmark test.
  • Queue: Responsible for queuing the packets to be sent.
  • Executor: Go routine pool used to execute callbacks.
  • EncodeMessage/DecodeMessage: Responsible for the serialization and deserialization of data, through the interface to standardize and standardize the behavior of serialization and deserialization, making the process more flexible and extensible. Users can not only define the communication protocol by themselves, but can also use it as long as they like. Some popular communication protocols, such as Protobuff, Thrift, json, etc.
  • Channel:Channel is responsible for providing reliable data streams, but it has nothing to do with the specific implementation. In other words, listenrain can support reliable transport layer protocols like TCP and SCTP, and can also support QUIC, a reliable transport protocol based on UDP, and can also support Unix Socket, FIFO, even mock test based on in-process communication technology.
  • ChannelGenerator:This interface is responsible for generating channels, through which scenarios such as high availability and TCP Listen can be realized.
  • TransportKey: TransportKey is the only index to the access point, so it can simulate access points under different Channel implementations.
  • TransportPool: Responsible for managing the Transport pool.
  • StatMachine: StatMachine standardizes listenrain's callbacks, allowing users to organize their own business logic through a state machine, making the entire code structure clearer, and of course, you can also use the unconstrained synchronization request SyncSend.
  • StatMachinePool: Obviously it is a pool of state machine maintenance.

For these interfaces, TCP communication-based implementations and very simple Executor and Queue implementations have been provided in the default implementations. Benchmark tests are currently also carried out using these default implementations. Of course, if users can have a better implementation, welcome to discuss them together.Also introduce other non-interface key components:

  • ProtocolRegisterTable: This is the table used to register the protocol. The protocol needs to be associated with specific serialization and deserialization implementations, to solve the implementation of sticky packets, to generate the implementation of reliable streams, etc.
  • timer: Similar to the timer function of the well-known network communication framework libevent, the implementation principle is also similar, and it is also implemented based on a small top heap.
  • SyncStatMachine: The listenrain itself is designed by event-driven, so the business code needs to be asynchronous, but considering that some complex business logic is very complicated in asynchronous scenarios, so listenrain provides a synchronous request method, and SyncStatMachine is simulated inside the framework Callback, so that the user calling SyncSend, it looks like a synchronization request.

Benchmarks

Code: benchmark

Hardware environment:

  • OS: macOS Big Sur(11.2)
  • Chip: Apple M1
  • RAM: 16 GB

Single TCP connection test

parallel payload size(KiB) tps bandwith(Gib/s) cpu(%) mem(MiB)
1 4 27500 0.911 132 48
4 4 50000 1.638 255 100
16 4 60000 1.966 275 157
1 32 18000 4.719 172 42
4 32 36000 9.437 263 84
16 32 34000 8.912 310 86
1 256 8400 17.616 176 32
4 256 9200 19.293 265 36
16 256 8300 17.406 245 40
1 4096 760 25.501 190 82
4 4096 550 18.455 260 132
1000 4096 550 18.455 255 4259

The interface implementation of the test process basically adopts the default implementation

Notice

The listenrain processing request needs to use its msgID as its unique index, so it does not currently support the repeated use of msgID in a short period of time (within the request response period)

Who is using

s3proxy : Implementation of s3 protocol, back-end docking with x object storage bottom layer

Similar Resources

Spin up a local instance of an Avalanche network to interact with the standard APIs or to test a custom VM

Spin up a local instance of an Avalanche network to interact with the standard APIs or to test a custom VM

ava-sim ava-sim makes it easy for anyone to spin up a local instance of an Avalanche network to interact with the standard APIs or to test a custom VM

Oct 24, 2022

A framework for building chat interfaces with gioui.org.

chat A framework for building chat interfaces with gioui.org. The canonical copy of this repository is hosted on Sourcehut. We also have: An issue tra

Dec 1, 2022

A golang library about socks5, supports all socks5 commands. That Provides server and client and easy to use. Compatible with socks4 and socks4a.

socks5 This is a Golang implementation of the Socks5 protocol library. To see in this SOCKS Protocol Version 5. This library is also compatible with S

Nov 22, 2022

Http-server - A HTTP server and can be accessed via TLS and non-TLS mode

Application server.go runs a HTTP/HTTPS server on the port 9090. It gives you 4

Feb 3, 2022

Subdomain scanner, asynchronous dns packets, use pcap to scan 1600,000 subdomains in 1 second

ksubdomain是一款基于无状态的子域名爆破工具,类似无状态端口扫描,支持在Windows/Linux/Mac上进行快速的DNS爆破,在Mac和Windows上理论最大发包速度在30w/s,linux上为160w/s。 hacking8信息流的src资产收集 https://i.hacking8

Dec 31, 2022

Fastest python library for making asynchronous group requests.

FGrequests: Fastest Asynchronous Group Requests Installation Install using pip: pip install fgrequests Documentation Pretty easy to use. import fgrequ

Nov 22, 2022

Crimson prober - Asynchronous TCP scanner through SOCKS5 proxies

Crimson prober - Asynchronous TCP scanner through SOCKS5 proxies

Crimson Prober v1 Alpha version of Asynchronous TCP scanner through SOCKS5 proxi

Feb 19, 2022

Fast, multithreaded, modular and extensible DHCP server written in Go

coredhcp Fast, multithreaded, modular and extensible DHCP server written in Go This is still a work-in-progress Example configuration In CoreDHCP almo

Jan 9, 2023

A TCP Server Framework with graceful shutdown, custom protocol.

xtcp A TCP Server Framework with graceful shutdown,custom protocol. Usage Define your protocol format: Before create server and client, you need defin

Dec 7, 2022
Provides the function Parallel to create a synchronous in memory pipe and lets you write to and read from the pipe parallelly

iopipe provides the function Parallel to create a synchronous in memory pipe and lets you write to and read from the pipe parallely

Jan 25, 2022
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.

gev 中文 | English gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily bui

Jan 6, 2023
network multiplexing and framing protocol for RPC

TChannel Network multiplexing and framing protocol for RPC Read the Docs Languages: Node.js, Python, Go, Java Questions: Open a Github issue Uber's OS

Nov 26, 2022
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC. Available for ARM, MIPS, 386 and AMD64。KCPプロトコルに基づく安全なトンネル。KCP 프로토콜을 기반으로 하는 보안 터널입니다。
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC. Available for ARM, MIPS, 386 and AMD64。KCPプロトコルに基づく安全なトンネル。KCP 프로토콜을 기반으로 하는 보안 터널입니다。

Disclaimer: kcptun maintains a single website — github.com/xtaci/kcptun. Any websites other than github.com/xtaci/kcptun are not endorsed by xtaci. Re

Jan 9, 2023
Magma is an open-source software platform that gives network operators an open, flexible and extendable mobile core network solution.
Magma is an open-source software platform that gives network operators an open, flexible and extendable mobile core network solution.

Connecting the Next Billion People Magma is an open-source software platform that gives network operators an open, flexible and extendable mobile core

Dec 31, 2022
Golang connection multiplexing library

Yamux Yamux (Yet another Multiplexer) is a multiplexing library for Golang. It relies on an underlying connection to provide reliability and ordering,

Jan 7, 2023
wire protocol for multiplexing connections or streams into a single connection, based on a subset of the SSH Connection Protocol

qmux qmux is a wire protocol for multiplexing connections or streams into a single connection. It is based on the SSH Connection Protocol, which is th

Dec 26, 2022
A modular is an opinionated, easy-to-use P2P network stack for decentralized applications written in Go.

xlibp2p xlibp2p is an opinionated, easy-to-use P2P network stack for decentralized applications written in Go. xlibp2p is made to be minimal, robust,

Nov 9, 2022
Zero Trust Network Communication Sentinel provides peer-to-peer, multi-protocol, automatic networking, cross-CDN and other features for network communication.
Zero Trust Network Communication Sentinel provides peer-to-peer, multi-protocol, automatic networking, cross-CDN and other features for network communication.

Thank you for your interest in ZASentinel ZASentinel helps organizations improve information security by providing a better and simpler way to protect

Nov 1, 2022
An easy-to-use, flexible network simulator library in Go.

ns-x An easy-to-use, flexible network simulator library for Go. Feature Programmatically build customizable and scalable network topology from basic n

Dec 13, 2022