For performance reasons, should I maintain a http.Session structs pool when sending lots of HTTP request in Golang

Written by
reddit
Link to Post

https://www.reddit.com/r/golang/comments/botpod/for_performance_reasons_should_i_maintain_a/ by 

Hello everyone, I want to ask some experience for you about Golang HTTP request

I tried to write a library which wraps the Golang HTTP std library. Github

But I have a question about performance. In my lib, every times sending a request the lib will create a new structure nic.Session, then call the structure’s method like Get/Post… “`go // Get implemented by Session.Get func Get(url string, options H) (Response, error) { session := &Session{} return session.Get(url, options) }

// Post implemented by Session.Post func Post(url string, options H) (Response, error) { session := &Session{} return session.Post(url, options) } “`

I want to ask: in this way I have to create a new local variable each time, will it affect performance? should I create a session pool by using sync.Pool, to reuse these session structures?

submitted by /u/EddieIvan
[link] [comments]

Article Tags:
· ·
Article Categories:
reddit

Leave a Reply