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

Written by
Link to Post 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:

Leave a Reply