I
I
Ivan Shalganov2020-10-15 15:22:53
go
Ivan Shalganov, 2020-10-15 15:22:53

Which connection pool to use?

The hightload project uses fasthttp. Everything is fine, but it does not have a connection pool (not to be confused with sync.Pool), which leads to the following problem: when the server needs to be restarted, you have to wait until all idle keep-alive connections close themselves .

According to the SLA (requirement) on the idle keep-alive service of the connection - 1 minute. As a result, a safe reboot of the server takes 1 minute. You also need to "thread" connections on demand - shoot only keep-alives that are idle.

Native net/http has a map-based connection pool. However, map does not work well with GC, the guys from Discord once wrote about this , and the author of fasthttp himself speaks unflatteringly about mapas a non-GC friendly object. That is, the pool of connections is needed not on the basis of map, but, apparently, on a certain list.

On the move, I did not find any implementations of the connection pool. Found an abstract go-commons-pool for any objects.

Someone bother with a pool of connections? Can you advise something?

PS The fasthttp author himself recommends setting ReadTimeout to terminate keep-alive , but changing ReadTimeout does not apply to already existing idle keep-alive connections.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uvelichitel, 2020-10-17
@uvelichitel

Use https://golang.org/pkg/context/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question