benchmarks for implementation of servers which support 1 million connections

Benchmark for implementation of servers that support 1m connections

inspired by handling 1M websockets connections in Go

Servers

  1. 1_simple_tcp_server: a 1m-connections server implemented based on goroutines per connection
  2. 2_epoll_server: a 1m-connections server implemented based on epoll
  3. 3_epoll_server_throughputs: add throughputs and latency test for 2_epoll_server
  4. 4_epoll_client: implement the client based on epoll
  5. 5_multiple_client: use multiple epoll to manage connections in client
  6. 6_multiple_server: use multiple epoll to manage connections in server
  7. 7_server_prefork: use prefork style of apache to implement server
  8. 8_server_workerpool: use Reactor pattern to implement multiple event loops
  9. 9_few_clients_high_throughputs: a simple goroutines per connection server for test throughtputs and latency
  10. 10_io_intensive_epoll_server: an io-bound multiple epoll server
  11. 11_io_intensive_goroutine: an io-bound goroutines per connection server
  12. 12_cpu_intensive_epoll_server: a cpu-bound multiple epoll server
  13. 13_cpu_intensive_goroutine: an cpu-bound goroutines per connection server

Test Environment

  • two E5-2630 V4 cpus, total 20 cores, 40 logicial cores.
  • 32G memory

tune the linux:

sysctl -w fs.file-max=2000500
sysctl -w fs.nr_open=2000500
sysctl -w net.nf_conntrack_max=2000500
ulimit -n 2000500

sysctl -w net.ipv4.tcp_tw_recycle=1
sysctl -w net.ipv4.tcp_tw_reuse=1

client sends the next request only when it has received the response. it has not used the pipeline style to test.

Benchmarks

1m connections

throughputs (tps) latency
goroutine-per-conn 202830 4.9s
single epoll(both server and client) 42495 23s
single epoll server 42402 0.8s
multiple epoll server 197814 0.9s
prefork 444415 1.5s
workerpool 190022 0.3s

中文介绍:

  1. 百万 Go TCP 连接的思考: epoll方式减少资源占用
  2. 百万 Go TCP 连接的思考2: 百万连接的服务器的性能
  3. 百万 Go TCP 连接的思考3: 低连接场景下的服务器的吞吐和延迟
Owner
smallnest
Author of 《Scala Collections Cookbook》
smallnest
Similar Resources

A scanner for running security-related configuration checks such as CIS benchmarks

Localtoast Localtoast is a scanner for running security-related configuration checks such as CIS benchmarks in an easily configurable manner. The scan

Dec 15, 2022

Benchmarks to compare Go Generics

This is a collection of various sorts implemnted both as []int only and as const

Dec 8, 2022

Sqlbench runs benchmarks on an SQL database

sqlbench runs benchmarks on an SQL database. Right now this works for PostgreSQL

Oct 13, 2022

Cloud-Z gathers information and perform benchmarks on cloud instances in multiple cloud providers.

Cloud-Z Cloud-Z gathers information and perform benchmarks on cloud instances in multiple cloud providers. Cloud type, instance id, and type CPU infor

Jun 8, 2022

An operator that helps you perform benchmarks

Camunda-Benchmark-Operator 🏋️‍♀️ An operator that helps you perform benchmarks. Your first benchmark This requires that you know how to run the opera

Mar 2, 2022

Advanced benchmarks for +15 Go ORMs.

Go ORM Benchmarks Advanced benchmarks for +10 Go ORMs. Originally forked from orm-benchmark. ORMs All package run in no-cache mode. beego/orm bun gorm

Dec 11, 2022

Go session management for web servers (including support for Google App Engine - GAE).

Session The Go standard library includes a nice http server, but unfortunately it lacks a very basic and important feature: HTTP session management. T

Oct 10, 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

Lobby - A Nox game lobby which exposes a simple HTTP API for both listing and registering Nox game servers

Nox lobby server This project provides a Nox game lobby which exposes a simple H

Mar 6, 2022

Database wrapper that manage read write connections

rwdb Database wrapper that manage read write connections Install go get github.com/andizzle/rwdb Create connections package main import "github.com/

Dec 10, 2022

A little library for turning TCP connections into go channels.

netutils By Tim Henderson ([email protected]) This is a little library that was part of a larger project that I decided to pull out and make public.

Aug 13, 2020

handling 1M websockets connections in Go

Going Infinite, handling 1M websockets connections in Go This repository holds the complete implementation of the examples seen in Gophercon Israel ta

Jan 8, 2023

rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.

rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.

rconn (r[everse] conn[ection]) is a multiplatform program for creating reverse connections. It lets you consume services that are behind NAT and/or fi

Jan 1, 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

UDP Transport: compress, encrypt and send any data reliably over unreliable UDP connections

udpt UDP Transport Compresses, encrypts and transfers data between a sender and receiver using UDP protocol. Features and Design Aims: Avoid the overh

Nov 5, 2022

Tooling to validate HTTPS Certificates and Connections Around Web 🕷️

Tooling to validate HTTPS Certificates and Connections Around Web 🕷️

Cassler - SSL Validator Tool If your read fast, it's sounds like "Cassia Eller" Tooling to validate HTTPS Certificates and Connections Around Web 🕷️

Sep 14, 2022

CLI Tool to remove unwanted connections from your Chia Node based on Geo IP Location.

chia-bouncer Tiny CLI tool to remove unwanted connections from your Chia Node based on the Geo IP Location (Country). The Tool is written in golang an

Jun 25, 2021

Multiplexer over TCP. Useful if target server only allows you to create limited tcp connections concurrently.

tcp-multiplexer Use it in front of target server and let your client programs connect it, if target server only allows you to create limited tcp conne

May 27, 2021

Interactive terminal user interface and CLI for database connections. MySQL, PostgreSQL. More to come.

Interactive terminal user interface and CLI for database connections. MySQL, PostgreSQL. More to come.

🗄 dbui dbui is the terminal user interface and CLI for database connections. It provides features like, Connect to multiple data sources and instance

Jan 5, 2023
Comments
  • Connection need to set nonblock?

    Connection need to set nonblock?

    https://github.com/smallnest/1m-go-tcp-server/blob/000556e59c21ac729f8f313b407127552721471f/2_epoll_server/epoll_linux.go#L36 Before we use unix.EpollCtl() to add a connection to the event loop,Is it necessary to use unix.SetNonblock() to set the connection to nonblock?

  • epoller wait failed in golang 1.14

    epoller wait failed in golang 1.14

    in 5_multiple_client, line 99 the poll.waiter() failed with error: "interrupted system call" connections, err := epoller.Wait() if err != nil { log.Printf("failed to epoll wait %v", err) continue }

    with go version 1.13 OK

    any suggestion?

Benchmarks of common basic operations for the Go language.

gocostmodel This package was inspired by Brian W. Kernighan and Rob Pike's book "The Practice of Programming" (Addison-Wesley, 1999). In Chapter 7 on

Dec 23, 2022
Go micro-benchmarks for calculating the speed of language constructs

== About == Gospeed is a library of micro-benchmarks for Go which evolved from the GoLightly project. It's main utility is for understanding and reas

Sep 27, 2022
Designed to support DNS brute-forcing with a minimal number of network connections

Fast Use of DNS Resolvers Designed to support DNS brute-forcing with a minimal number of network connections. Installation go get -v -u github.com/caf

Dec 8, 2022
Go-postgres - go-postgres library provide NoSQL functionality which can execute queries with pool of connections

GO Postgres go-postgres library provide NoSQL functionality which can execute queries with pool of connections. What is this repository for? Establish

Dec 31, 2021
cmd tool for automatic storage and comparison of benchmarks results

prettybenchcmp prettybenchcmp is cmd tool for storage and comparison of benchmarks results. There is a standard tool benchcmp, but I don't think that

Apr 6, 2021
Benchmarks of Go serialization methods

Benchmarks of Go serialization methods This is a test suite for benchmarking various Go serialization methods. Tested serialization methods encoding/g

Jan 1, 2023
Benchmarks of common basic operations for the Go language.

gocostmodel This package was inspired by Brian W. Kernighan and Rob Pike's book "The Practice of Programming" (Addison-Wesley, 1999). In Chapter 7 on

Dec 23, 2022
Go micro-benchmarks for calculating the speed of language constructs

== About == Gospeed is a library of micro-benchmarks for Go which evolved from the GoLightly project. It's main utility is for understanding and reas

Sep 27, 2022
Go Machine Learning Benchmarks
Go Machine Learning Benchmarks

Benchmarks of machine learning inference for Go

Dec 30, 2022
Robust framework for running complex workload scenarios in isolation, using Go; for integration, e2e tests, benchmarks and more! 💪

e2e Go Module providing robust framework for running complex workload scenarios in isolation, using Go and Docker. For integration, e2e tests, benchma

Jan 5, 2023