百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

guard

> DevOps
开源

未维护! 一款使用 Go 编写的通用高性能电力开关和代理服务器

736 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

未维护! 一款使用 Go 编写的通用高性能电力开关和代理服务器

Guard

guard is a generic high performance circuit breaker & proxy written in Go. It has four major components:

  • radix tree & response status ring: which stores registered URLs
  • load balancer: which distributes requests(algorithms: randomized distribute, round robin, weighted round robin)
  • circuit breaker: which makes sure your backend services will not be broken down by a large quantity of requests
  • proxy server: it's based on fasthttp

Workflow

Benchmark

I've made a simple benchmark on my laptop(i5-3210M CPU @ 2.50GHz with 4 cores):

…

For now, guard's proxy performance is about 55% of Nginx 1.76x faster than Nginx, and I'm still working on it! Don't worry, it will become better and better!

By the way, thanks the suggestion from @dongzerun, by configure the GOGC in environment, guard's proxy performance is about 70% of Nginx. guard does not allocate much memory now, GOGC does not make a change, but still say thanks to @dongzerun!

TODO

moved to https://github.com/jiajunhuang/guard/projects/1

Set it up

  1. build it using go get -u:
$ go get -u github.com/jiajunhuang/guard
  1. start it
$ guard
  1. now you need to register an application by send a POST request to http://127.0.0.1:12345/app with json like this:
{
    "name": "www.example.com",
    "backends": ["127.0.0.1:80", "127.0.0.1:80", "127.0.0.1:80"],
    "weights": [5, 1, 1],
    "ratio": 0.3,
    "paths": ["/"],
    "methods": ["GET"],
    "fallback_type": "text",
    "fallback_content": "hello world"
}

I'm doing it like this:

$ http POST :12345/app < backends.json 
HTTP/1.1 200 OK
Content-Length: 8
Content-Type: text/plain; charset=utf-8
Date: Sun, 21 Jan 2018 08:51:16 GMT

success!
  1. and now, it works! whoops! try it:
$ http :23456 'Host: www.example.com'
HTTP/1.1 200 OK
...
  1. by the way, you can inspect your configuration by visit http://127.0.0.1:12345/ :
…

Changelogs

  • 2018-01-25: rewrite proxy from net/http to fasthttp, it's super fast now!
  • 2018-01-24: rewrite radix tree & statistics module, it's lock-free now!
  • 2018-01-22: add randomized distribute, naive round robin algorithms
  • 2018-01-21: rewrite status statistics module
  • 2018-01-20: guard works!
  • 2018-01-19: first commit

Thanks

  • Golang
  • fasthttp
  • httprouter

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gocircuit-breakerproxy

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理