Skip to content

Use global persistence connection to enhance performance  #79

@s8sg

Description

@s8sg

All call to function and for next node execution are submitted via Gateway. In the current code

  • A http client was being created for each incoming message in the handler. this is a overkill, cause for every new request there will be a Handshake.
  • The http client created was using default transport. default http client does have a keep-alive setting.

We can reuse a connection instead of creating new one. We can do so by creating a global client as:

var client *http.Client

func init() {
    tr := &http.Transport{
           MaxIdleConnsPerHost: 1024,
     }
   client = &http.Client{Transport: tr }
}

When we are using common client, we also need to make sure that we

  • Read until Response is complete (i.e. ioutil.ReadAll(rep.Body))
  • Call Body.Close()

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestfaas-flow-templateIssue applies to component: fass-flow-template

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions