apache / openwhisk-client-go

Go client library for the Apache OpenWhisk platform
https://openwhisk.apache.org/
Apache License 2.0
35 stars 44 forks source link

Cannot reuse TCP connection across action invocations #111

Closed tokenclt closed 5 years ago

tokenclt commented 5 years ago

In the current implimentation, LoadX509KeyPair() is executed when making a new http request. As a result, a new Transport is created for each request. However, TCP connections cannot be reused across different transports. This will cause the program to reach fd limits quickly under a heavy load, e.g., invoke actions programmingly.

Here is a demo of the deficiency: When I invoke an action (host ip: 13.66.***.**) sequentially for a couple of times, several connections are established. Idealy, only one connection should be created and reused.

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:socks         0.0.0.0:*               LISTEN     
tcp        0      0 localhost:1188          0.0.0.0:*               LISTEN     
tcp        0      0 mingyu-virtual-ma:35702 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35698 13.66.***.**:https      ESTABLISHED 
tcp        0      0 mingyu-virtual-ma:35696 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35700 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35704 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35694 13.66.***.**:https      ESTABLISHED
tcp6       0      0 ip6-localhost:ipp       [::]:*                  LISTEN     
tcp6       0      0 ip6-localhost:socks     [::]:*                  LISTEN
csantanapr commented 5 years ago

Do you want to submit a PR with the fix?

tokenclt commented 5 years ago

Here is the PR #112.