Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2323

When using HttpClientBuilder without setting a user agent an expensive operation seems to be used

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • 4.5.12, 5.3.1
    • None
    • HttpClient (classic)
    • None
    • Docker image using maven:3.9.1-eclipse-temurin-17-focal running in kubernetes. Spring boot 2.7.x.

    Description

      We have an application that has a fairly high outbound http call rate using Apache Http Client. We have been profiling it recently using the async profiler and I noticed that almost 10% of our cpu time is spent in VersionInfo.getUserAgent.

      We use HttpClientBuilder for each call (this seems the correct way to be able to use different connection pools and settings).

      I am guessing because we do not explicitly set the user agent that the client will go determine the client version and java version and use this... the automatically generated user agent in our case looks like:

      User-Agent: Apache-HttpClient/4.5.12 (Java/17.0.7)

      I have attached the profiler flame graph. I would imagine something like this could be checked once and used for any further calls. I have not tested it yet but I am hoping a workaround would be to make sure to set a user agent and then none of this classloader stuff would need to happen for each call.

      Attachments

        Activity

          People

            Unassigned Unassigned
            winstonwaite Rob
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: