背景 最近遇到一个问题,线上老集群下线时,node节点全部下线,只剩下ingress的节点,流量已全部切走,理论上应该没什么请求量,但ingress经常负载飙高导致容器挂掉。分析过程出问题的时候,可以看到nginx error.log 里面有很多 connection refused 的请求2019/09/23 03:39:02 [error] 587#587: *5038285
要点:sync.Once 的应用高并发场景下读写锁 package singleton import "sync" var ( p *Pet once sync.Once ) func init(){ once.Do( func() { p = &Pet{} }) } func GetInstance() *Pet
package fatory import "fmt" type Device interface{ StartDevice() } type KeyBoard struct { } func (k *KeyBoard) StartDevice(){ fmt.Println("Keyboard is ready to work!") } type Mouse struct
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号