Go 分布式令牌桶限流 + 兜底策略
上篇文章提到固定时间窗口限流无法处理突然请求洪峰情况,本文讲述的令牌桶线路算法则可以比较好的处理此场景。
- 单位时间按照一定速率匀速的生产 token 放入桶内,直到达到桶容量上限。
- 处理请求,每次尝试获取一个或多个令牌,如果拿到则处理请求,失败则拒绝请求。
优点
可以有效处理瞬间的突发流量,桶内存量 token 即可作为流量缓冲区平滑处理突发流量。
缺点
实现较为复杂。
代码实现core/limit/tokenlimit.go
分布式环境下考虑使用 redis 作为桶和令牌的存储容器,采用 lua 脚本实现整个算法流程。
redis lua 脚本
<span class="c1">-- 每秒生成token数量即token生成速度</span>
<span class="kd">local</span> <span class="n">rate</span> <span cl ... ⌘ [Read more](https://gocn.vip/topics/20950)
🧮 USERS:1 FEEDS:2 TWTS:113 ARCHIVED:21446 CACHE:1092 FOLLOWERS:13 FOLLOWING:14
lancet - A comprehensive, efficient, and reusable util function library of go.
1 points posted by Marcel Franke ⌘ Read more
BennyKok/PxerStudio
Android open source pixel drawing tool
Language: Kotlin
Star: 40
Watch: 40 ⌘ Read more
GoCN 每日新闻(2022-01-12)
GoCN 每日新闻(2022-01-12)
- Go 实现的自动保存 Git 项目中未提交代码https://github.com/nikochiko/autosaved
- Go 中快速、简单的全栈 Web 开发入门工具包https://github.com/mikestefanello/pagoda
- Golang Redis RESP3 客户端,自动流水线并支持客户端缓存https://github.com/rueian/rueidis
- Runtime 不变性检查库[https:/ … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:112 ARCHIVED:21371 CACHE:1085 FOLLOWERS:13 FOLLOWING:14
@fastidious@arrakis.netbros.com +1 …Now just a way to come up with the $20 per twt to store the data.
stephaniewm55/1-Click-Torrent-Youtube-FFMPEG-Client
1 Click Torrent Youtube FFMPEG Client is torrent/Youtube downloader and FFMPEG video converter/player, built in Windows File Explorer, without settings and dependencies.
Language: C++
Star: 23
Watch: 23 ⌘ Read more
GoCN 每日新闻 (2022-01-11)
GoCN 每日新闻 (2022-01-11)
- 解读 Go 语言的 2021:稳定为王https://mp.weixin.qq.com/s/9LKyPfhwldgZY7H4iS7sjg
- Go 泛型的 3 个核心设计https://mp.weixin.qq.com/s/I7qysvddG4NDgtYIMMAE3g
- Golang 的 Ealstic 链接库https://mp.weixin.qq.com/s/iHIxsEZf3w06GbO2sHSuRA
- 动态调整 GOGC 优化 Go 的 GC 标记 CPU 占� … ⌘ Read more
Go 模糊测试
- 原文地址: https://tip.golang.org/doc/fuzz/
- 原文作者:Go Team
- 本文永久链接:https:/github.com/gocn/translator/blob/master/2022/w01_Go_Fuzzing.md
- 译者: fivezh
- 校对: zxmfke
从 Go 1.18 版本开始,标准工具集开始支持模糊测试。
概述模糊测试(Fuzzing)是一种自动化测试方法,通过不断地控制程序输入来发现程序错误�� … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:111 ARCHIVED:21169 CACHE:1064 FOLLOWERS:13 FOLLOWING:14
https://journalducoin-com.cdn.ampproject.org/c/s/journalducoin.com/defi/cryptomonnaies-impots-2022-fisc/?amp=1 crypto impot taxe
GoCN 每日新闻 (2022-01-10)
GoCN 每日新闻 (2022-01-10)- Minecraft 管理 K8S 集群https://eric-jadi.medium.com/minecraft-as-a-k8s-admin-tool-cf16f890de42
- go ebpf 管理包https://github.com/ehids/ebpfmanager
- Go 错误处理https://earthly.dev/blog/golang-errors/
- Go 中实现用户的每日限额(比如一天只能领三次福利) [https://jueji … ⌘ Read more
hconfig 一个可插拔的 Golang 配置管理工具 支持(etcd/k8s(kubernetes)/apollo)
hconfig 一个可插拔的 Golang 配置管理工具 支持(etcd/k8s(kubernetes)/apollo) 什么是可插拔式程序- 一个统计的可插拔内核
- 各个组件相互独立
- 在设计一个可插拔式程序时我们应该想到的是怎么把我们的需求给实现了,然后我们再搞一波抽象(统计的可插拔内核
不同的模块只要实现了� … ⌘ Read more
Decorative Constants
⌘ Read more
Decorative Constants
⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:110 ARCHIVED:21071 CACHE:1047 FOLLOWERS:13 FOLLOWING:14
🧮 USERS:1 FEEDS:2 TWTS:109 ARCHIVED:20905 CACHE:993 FOLLOWERS:13 FOLLOWING:14
GoCN 每日新闻 (2022-01-09)
- 带你探究 Go 语言的 iotahttps://mp.weixin.qq.com/s/V5iJgcLhCYMZd5l8akfbVQ
- 项目实战:使用 Fiber + Gorm 构建 REST APIhttps://mp.weixin.qq.com/s/RqUOLP-OG_wOpCzxVTAl6w
- Effective Error Handling in Golanghttps://earthly.dev/blog/golang-errors/
- 为什么不在 golang 中构建一个 redis 客户端[https://mauricio.github.io/2022/0 … ⌘ Read more
Hiring: Server Engineer - Remote (Penn Game Studios)
1 points posted by golangch ⌘ Read more
GoCN 每日新闻 (2022-01-08)
- Go 1.17.6/1.16.13 版本发布https://groups.google.com/g/golang-announce/c/95ZD3rKn4DI/m/93cyN8F1BAAJ
- 高效的 Go 错误处理https://earthly.dev/blog/golang-errors/
- 从零实现一个 RedisClient 了解 Redis 协议https://mauricio.github.io/2022/01/07/redis-protocol.html
- Golang 简洁架构实战[https://zh … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:108 ARCHIVED:20637 CACHE:974 FOLLOWERS:13 FOLLOWING:14
GoCN 每日新闻 (2022-01-07)
GoCN 每日新闻 (2022-01-07)
- 用 golang 在 tor 网络上安全的私有部署共享文件服务https://github.com/R4yGM/garlicshare
- 一个极速的 golang 全栈 web 开发包https://github.com/mikestefanello/pagoda
- ch 一个 clickhouse 客户端,比 rust 和 c++ 的都快https://github.com/go-faster/ch
- 用 gosec 扫描 go 源码的漏洞[https://jcdan3.medium. … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:107 ARCHIVED:20529 CACHE:935 FOLLOWERS:13 FOLLOWING:14
Switching to Purelymail
After long consideration, I have now moved email for all but my main domain (but that’s coming too) to Purelymail. Email without bullshit. And with the “Advanced billing mode” they really only charge by usage or $10 per year with the “Simple billing”, but even with Advanced that shouldn’t be much more than $1 per month for me. ⌘ Read more
Switching to Purelymail
After long consideration, I have now moved email for all but my main domain (but that’s coming too) to Purelymail. Email without bullshit. And with the “Advanced billing mode” they really only charge by usage or $10 with the “Simple billing”, but that shouldn’t be much more than $1 per month for me. What I like most is that there is no unnecessary limit on the number of users, aliases or custom domains. 👍 ⌘ Read more
GoCN 每日新闻 (2022-01-06)
- Golang profiler 笔记https://github.com/DataDog/go-profiler-notes/blob/main/README.md
- Bundling templates with embedhttps://osinet.fr/go/en/articles/bundling-templates-with-embed/
- Go 通过 Map/Filter/ForEach 等流式 API 高效处理数据https://gocn.vip/topics/20922
- 滴滴夜莺监控发布 v5 正式版,定位 Promet … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:106 ARCHIVED:20451 CACHE:902 FOLLOWERS:13 FOLLOWING:14
Ignite Realtime Blog: Openfire 4.5.6 is released
Openfire 4.5.6 has been released, that addresses an annoying issue that was affecting the earlier 4.5.5 release. We’ve updated the bundled log4j library to version 2.17.1 for good measure.
The changelog denotes the two Jira issues closed by this release. You can find Openfire build artifacts available for download [here](https://github.com/igniterealtime/Openfire/rel … ⌘ Read more
GoCN 每日新闻 (2022-01-05)
GoCN 每日新闻 (2022-01-05)- Rust 与 Go: 为何相得益彰https://gocn.vip/topics/20929
- 聊聊 GOLANG 中形形色色的同步原语http://vearne.cc/archives/39631
- Go 泛型的这 3 个核心设计,你都知道吗?https://segmentfault.com/a/1190000041227815
- Go 语言高效率 Web 开发四:分层领域模型和项目结构分层[https://juejin.cn/post/70492 … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:105 ARCHIVED:20383 CACHE:874 FOLLOWERS:13 FOLLOWING:14
GoCN 每日新闻(2022-01-04)
GoCN 每日新闻(2022-01-04)- 「GoCN 酷 Go 推荐」go 语言位操作库 — bitsethttps://mp.weixin.qq.com/s/UcuKgKnt4fwrg3c-UHc3sw
- Go 通过 Map/Filter/ForEach 等流式 API 高效处理数据https://mp.weixin.qq.com/s/7ATm_Zu7ib9MXf8ugy3RcA
- 优化 Go 二进制文件的大小[https://prog.world/optimizing-the-size-of-the-go-binary](https://prog.world/optimizing-the-si … ⌘ Read more
What’s new in dubbo-go-pixiu 0.4.0
Dubbo-go-pixiu 是一款高性能 API 网关,支持 Dubbo 和 Http 等多种协议。具体介绍文章可以参考 《Dubbo 跨语言调用神兽:dubbo-go-pixiu》。
近期社区发布了 0.4.0 版本,具体请查看 v0.4.0。相关改进实在太多,本文只列出相关重大 feature、bugfix 、 性能提升项。
1 动态从 Spring Cloud 和 Dubbo 注册中心拉取路由和集群配置数据Pixiu 原本依赖本� … ⌘ Read more
潘娟:Keep open,Stay tuned 开源为我打开的全新世界 | TiDB Hackathon 2021 评委访谈
距离 2022.1.8-9 比赛日,已不到两周时间,想必各位参赛选手已经摩拳擦掌,开始准备自己的项目了。\
在等待最终比赛日的这段时间,TiDB 社区采访了本届 Hackathon 中的一位女性评委,她在数据库领域中耕耘多年,从 DBA 到创业者,具有着传奇色彩的人生经历。\
我们通过访谈记录了她对开源的理解与感悟,同时探讨 Hackathon 活动的� … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:104 ARCHIVED:20305 CACHE:832 FOLLOWERS:13 FOLLOWING:14
Ignite Realtime Blog: Openfire 4.6.7 released (Log4j 2.17.1 only change)
Openfire 4.6.7 has been released with only a single change to bump the bundled log4j library to version 2.17.1. Whilst we do not believe Openfire to be vulnerable to the CVEs associated with the log4j 2.17.0 and 2.17.1 releases, we realize that many folks are running naive security scanners that are simply checking for bundled jar versions.
The [changelog](https://download.igniterealtime.org/open … ⌘ Read more
Bundling templates with embed #embed #howto href=”https://we.loveprivacy.club/search?q=%23assets”>#assets**
If you’ve been embedding assets or templates with rakyll/statik, markbates/pkger or any other bundler, you will probably want to convert to the new embed package brought by Go 1.16 to replace them all. This article, following one about pkger, explains how, going through the exact same steps to make converting easier. 1 points posted by FGM ⌘ Read more
GinAdmin 后台管理模板
GinAdmin这个项目是以 Gin 框架为基础搭建的后台管理平台,虽然很多人都认为 go 是用来开发高性能服务端项目的,但是也难免有要做 web 管理端的需求,总不能再使用别的语言来开发吧。所以整合出了 GinAdmin 项目,请大家多提意见指正!欢迎 star ⭐⭐
依赖- golang > 1.8
- Gin
- BootStrap
- LayUi
- WebUpload
- [Light Year Admin Using Ifra … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:103 ARCHIVED:20216 CACHE:822 FOLLOWERS:13 FOLLOWING:14
FreshRSS 1.19.1 ⌘ Read more
FreshRSS 1.19.1 ⌘ Read more
FreshRSS 1.19.1 ⌘ Read more
FreshRSS 1.19.1 ⌘ Read more
Excelize 2.5.0 Released – Go API for spreadsheet (Excel) #golang #Excel #excelize href=”https://we.loveprivacy.club/search?q=%23spreadsheet”>#spreadsheet**
1 points posted by xuri ⌘ Read more
FreshRSS 1.19.0 ⌘ Read more
go 语言位操作库 bitset
bitset库 实现了 bitsets 数据结构,这是一种正整数和布尔值映射关系的结构,它比 map[uint]bool 更高效
bitsets 基本思想是用一个 bit 位来标记某个元素对应的 Value,每一位表示一个数,1 表示存在,0 表示不存在
比如我要表示 1, 3, 7 这 3 个数
- 构造一个空白 bitsets:00000000
- 每位代表的值如下:76543210
- 想要表示的值标记 1:10001010
�� … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:102 ARCHIVED:19935 CACHE:795 FOLLOWERS:13 FOLLOWING:14
GoCN 每日新闻 (2022-1-1)
- https://eli.thegreenplace.net/2021/go-https-servers-with-tls/ Go HTTPS servers with TLS
- https://eli.thegreenplace.net/2020/embedding-in-go-part-3-interfaces-in-structs/ interfaces in structs
- https://mp.weixin.qq.com/s/Ec1nuR5Q_QgaC3FqeX1gLg 最简单的服务响应时长优化方法
- [https: … ⌘ Read more
🧮 USERS:1 FEEDS:2 TWTS:101 ARCHIVED:19852 CACHE:786 FOLLOWERS:13 FOLLOWING:14
喜报!GoFrame 开源项目获得,2021 年度开源中国最受欢迎开源项目奖!
喜报!GoFrame 开源项目获得,2021 年度开源中国最受欢迎开源项目奖!
感谢感谢所有社区团队小伙伴的辛勤付出!
… ⌘ Read more