shimingyah / pool Goto Github PK
View Code? Open in Web Editor NEWConnection pool for Go's grpc client with supports connection reuse.
License: Apache License 2.0
Connection pool for Go's grpc client with supports connection reuse.
License: Apache License 2.0
p.RLock()
current := atomic.LoadInt32(&p.current)
p.RUnlock()
请问一下,使用了atomic为什么还需要加锁?加锁和原子化是不是其中有一个多余了呢?
如题:应用层调用 Conn.Value() 获取到的 *grpc.ClientConn 如果执行了一个 Close 方法,这个池子里就存在了一个不可用连接。
当并发请求数从少变多时,连接池物理连接数从 MaxIdle
翻倍扩容,一直达到 MaxActive
;
当并发请求数从多变少时,却需要等到逻辑连接数为 0
时从当前物理连接数降到 MaxIdle
。
连接池缩容机制能否按扩容机制一般逐步下降?
从代码可以看出index在每次get获取连接的时候会自动加1,而且是uint32类型,
但是没有在请求后进行原子性的-1操作,会造成隐患,那就是index的值一直增加最终将会导致超出范围异常的局面。
还请你检查一下,是不是可以在conn.close的时候进行即使的-1操作会更加合理。
看来一下你在知乎上的文章,感觉很不错,悄悄问一下,有Java版实现吗?(逃
现在链接的时候,没法改grpc的参数,最好可以自定义grpc参数
连接池初始化时定义了MaxActive和MaxConcurrentStream,当达到MaxActive及MaxConcurrentStream时,若连接池reuse=true,那么还会使用Round-Robin算法选择已创建的连接进行数据传输,这个不是对已定义的MaxConcurrentStream矛盾了吗?是否应该追踪每一个线程的连接使用状态?
options.go return value is a question
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.