Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【开源自荐】nbio -- Pure Go 1000k+ connections solution #2813

Open
lesismal opened this issue Sep 22, 2024 · 0 comments
Open

【开源自荐】nbio -- Pure Go 1000k+ connections solution #2813

lesismal opened this issue Sep 22, 2024 · 0 comments

Comments

@lesismal
Copy link

推荐项目

  • 类别:Go
  • 项目标题:nbio是一个golang实现的事件驱动、非阻塞IO的百万连接解决方案
  • 项目描述:
  1. 旨在解决标准库net包处理海量连接场景的巨大协程内存/GC开销和STW问题;
  2. 支持非阻塞TLS/HTTP/Websocket,HTTP基本兼容标准库,gin/echo/chi等框架的项目也可以使用nbio驱动网络IO;
  3. HTTP/Websocket支持多种IOMod,可以根据特定场景让性能与资源消耗更加平衡、让服务更加稳定。
  • 亮点:
  1. Websocket百万连接、1k payload echo测试,server 4核1G低配仍能 10w qps,相比于标准库方案百万连接8-10G内存起步,海量连接场景节约大量硬件资源、运行稳定;
  2. 相比于同类Poller框架,性能良好不低于竞品,功能更加丰富自带TLS/HTTP/Websocket支持;
  3. 虽然事件驱动异步非阻塞,但配合协程池,HTTP/Websocket或其他实现的协议,应用层业务代码仍然可以像标准库一样编写同步代码,具有良好的易用性。
  • 示例代码:(可选)
package main

import (
	"fmt"
	"net/http"

	"github.com/lesismal/nbio/nbhttp"
)

func main() {
	mux := &http.ServeMux{}
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "hello world")
	})
	engine := nbhttp.NewEngine(nbhttp.Config{
		Network: "tcp",
		Addrs:   []string{"localhost:8080"},
		Handler: mux,
	})

	err := engine.Start()
	if err != nil {
		fmt.Printf("nbio.Start failed: %v\n", err)
		return
	}
	defer engine.Stop()

	<-make(chan int)
}
  • 后续更新计划:持续维护修复各类bug、简化优化代码,希望未来有档期支持HTTP2.0/3.0。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant