Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3405

Go THttpClient misuses http.Client objects

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.3
    • Fix Version/s: 0.10.0
    • Component/s: Go - Library
    • Labels:
      None
    • Environment:

      Any

      Description

      THttpClient:Flush creates an http.Client object every time it is called. From the Go docs regarding the use of these client objects:

      "Clients and Transports are safe for concurrent use by multiple goroutines and for efficiency should only be created once and re-used."

      I suggest that the client used by the THttpTransport default to using either the http.DefaultClient or a package scoped default client. The transport should also accept a http.Client as an optional parameter so users of the library are free to control this behavior.

      With the current implementation I have run into issues when spinning up ~1000 separate instances of the THttpClient for a load test application I have written. Switching to using a single shared http client resolved all connection issues I had.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                justinlarrabee Justin Larrabee
                Reporter:
                justinlarrabee Justin Larrabee
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified