高性能golang後端處理網絡模塊包

高性能golang後端處理網絡模塊包

一個用golang寫的高性能後端處理模塊包

  • 支持常見的網絡協議, 包括HTTP, TCP, UDP等.
  • Job\Worker 網絡處理模型, 同時並行異步處理
  • 使用原生的golang channel來做異步鎖

https://github.com/halokid/MonRabit

有需要更新功能可以提,能用的話記得start一下哈,謝謝

獲取

# 項目地址爲 http://github.com/r00tjimmy/high-performance-net-handler

# go get獲取

go get github.com/r00tjimmy/high-performance-net-handler

一個後端HTTP handler的範例

package main

import (
  "github.com/r00tjimmy/high-performance-net-handler/worker"
)

var (
  max_worker = 3
  max_job = 10
  handle_type = "http"   // set network protocol type
)

func main() {
  // make the worker, listening work_pool channel
  dispatcher := worker.NewDispatcher(max_worker, handle_type)
  dispatcher.Run()

  // get requet
  request := worker.NewRequest(max_job, handle_type)
  request.Run()

}

編譯、測試、運行範例目錄examples裏面的http例子


cd examples

# just build
make build

after build, you can run with ./hpnh in current folder

# just test
make gotest

# auto build and run 
make all

性能對比報告

硬件信息: 4C 16G

操作系統版本: CentOS 7.4 x64

同樣的硬件, 同一個操作系統,對比 Apache/2.4.12 和 hpnh 作爲 HTTP後端服務器的性能, 使用該網絡模塊比原生的apache默認配置性能要高三倍以上,詳細的性能報告文件在 preformance_reports 文件夾裏面。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章