fasthttp:一个比官方net/http 快10 倍的http server

By ego008 at 2015-11-24 17:40:01 • 2629次点击

Fast HTTP implementation for Go.

Currently fasthttp is successfully used in a production serving up to 1M concurrent keep-alive connections doing 50K qps from a single server.

In short, fasthttp is up to 10 times faster than net/http.

项目地址 https://github.com/valyala/fasthttp 90

这家伙写了好多'fast' 系列:

fasthttp: Fast HTTP package for Go
ybc: Fast in-process BLOB cache with persistence support
gorpc: Simple, fast and scalable golang rpc library for high load
goloris: Slowloris for nginx DoS. Written in go
gheap: Fast generalized heap tree algorithms in C++ and C. Provides simultaneous support for D-heap and B-heap.

fasthttp, , net, http, server


这个库最近发展的很捉急,一下收了1171 颗星。

作者在后面给出了go 程序优化的建议。

有人问道:为什么不去优化net/http?
他说:本来想去优化net/http 的,但它的设计思想只能让我重写。

youbbs at 2015-12-04 16:08:14
1

这个发图片怎么样?

小马 at 2015-12-08 09:53:34
2

这个很轻量啊!!!!!!!!!!!!!!!!!!

小马 at 2015-12-08 09:55:31
3

加上路由的例子

package main

import (
    "fmt"
    "log"

    "github.com/buaazp/fasthttprouter"
    "github.com/valyala/fasthttp"
)

func Index(ctx *fasthttp.RequestCtx, _ fasthttprouter.Params) {
    fmt.Fprint(ctx, "Welcome!n")
}

func Hello(ctx *fasthttp.RequestCtx, ps fasthttprouter.Params) {
    fmt.Fprintf(ctx, "hello, %s!n", ps.ByName("name"))
}

func main() {
    router := fasthttprouter.New()
    router.GET("/", Index)
    router.GET("/hello/:name", Hello)

    log.Fatal(fasthttp.ListenAndServe(":8080", router.Handler))
}

ego008 at 287.2天前
4

地地道道的

闻讯 at 280.2天前
5

fasthttp-postgresql 在最新一轮跑分中脱颖而出

https://www.techempower.com/benchmarks/ 18
https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Go/fasthttp-postgresql 19

新出的一个模版引擎也很牛(20x faster than html/template)
https://github.com/valyala/quicktemplate 16
上面的库会编译为一个go 文件,不能动态载入,如果要动态载入可以用
https://github.com/valyala/fasttemplate 17 也是这个牛人写的

ego008 at 263.7天前
6

test

最acg at 261.7天前
7

test1

d2fan at 260.1天前
8
登录 后发表评论