代码之家  ›  专栏  ›  技术社区  ›  DrGecko

人工-间歇性缓慢响应时间

  •  2
  • DrGecko  · 技术社区  · 7 年前

    当与本地Artifactory 5.8.4服务器集成时,我们遇到了gradle构建的问题。Gradle给出了如下例外情况: Read timed out .

    为了解决此问题,我们使用了以下(修订的)curl命令,有时需要30-60秒才能响应:

    time curl -u username:password http://localhost:8081/artifactory/libs-snapshot/com/redacted/product/maven-metadata.xml
    

    以下是 request.log 在artifactory服务器上:

    20180219144146|30190|REQUEST|172.x.x.51|username|GET|/libs-snapshot/com/redacted/product/maven-metadata.xml|HTTP/1.1|200|411
    

    价值观 30190 显示出于某种原因,处理请求需要30秒

    有什么办法可以解决这个问题吗?

    ---更新---

    根据@DrorBereznitsky的请求,我在下面附加了一个跟踪到该端点(使用curl)。请注意,延迟似乎在跟踪开始之前-这可以通过 time 显示时钟持续时间的命令: real 0m30.316s

    [root@afactory ]# time curl -u username:password http://localhost:8081/artifactory/libs-snapshot/com/redacted/product/maven-metadata.xml?trace
    Request ID: c1fdcf4f
    Repo Path ID: libs-snapshot:com/redacted/product/maven-metadata.xml
    Method Name: GET
    User: username
    Time: 2018-02-23T10:14:36.281+01:00
    Thread: http-nio-8081-exec-35
    Steps: 
    2018-02-23T10:14:36.281+01:00 Received request
    2018-02-23T10:14:36.281+01:00 Request source = 127.0.0.1, Last modified = 01-01-70 00:59:59 +01:00, If modified since = -1, Thread name = http-nio-8081-exec-35
    2018-02-23T10:14:36.281+01:00 Executing any BeforeDownloadRequest user plugins that may exist
    2018-02-23T10:14:36.281+01:00 Retrieving info from {} repository '{}' type 
    2018-02-23T10:14:36.281+01:00 Consulting the virtual repo download strategy
    2018-02-23T10:14:36.281+01:00 Trying to retrieve resource info from the local storage
    2018-02-23T10:14:36.281+01:00 Unable to find resource in libs-snapshot:com/redacted/product/maven-metadata.xml
    2018-02-23T10:14:36.281+01:00 Intercepting cached virtual resource with 'PomInterceptor'
    2018-02-23T10:14:36.281+01:00 Intercepting cached virtual resource with 'MavenMetadataInterceptor'
    2018-02-23T10:14:36.281+01:00 Searching for info in aggregated repositories
    2018-02-23T10:14:36.281+01:00 Preparing list of aggregated repositories to search in
    2018-02-23T10:14:36.281+01:00 Appending the nested virtual repository 'libs-snapshot'
    2018-02-23T10:14:36.281+01:00 Appending the nested virtual repository 'remote-repos'
    2018-02-23T10:14:36.281+01:00 Appending the nested virtual repository 'remote-repos'
    2018-02-23T10:14:36.281+01:00 Appending collective local repositories
    2018-02-23T10:14:36.281+01:00 Appending collective local cache repositories
    2018-02-23T10:14:36.281+01:00 Appending collective remote repositories
    2018-02-23T10:14:36.281+01:00 Intercepting info request with 'PomInterceptor'
    2018-02-23T10:14:36.281+01:00 Intercepting info request with 'MavenMetadataInterceptor'
    2018-02-23T10:14:36.282+01:00 The requested resource isn't pre-resolved
    2018-02-23T10:14:36.282+01:00 Target repository isn't virtual - verifying that downloading is allowed
    2018-02-23T10:14:36.282+01:00 Creating a resource handle from 'libs-snapshot-local:com/redacted/product/maven-metadata.xml'
    2018-02-23T10:14:36.282+01:00 Identified requested resource as a file
    2018-02-23T10:14:36.282+01:00 Requested resource is an ordinary artifact - using normal content handle with length '411'
    2018-02-23T10:14:36.284+01:00 Unable to find resource in ext-snapshot-local:com/redacted/product/maven-metadata.xml
    2018-02-23T10:14:36.287+01:00 Info request was intercepted by 'MavenMetadataInterceptor'
    2018-02-23T10:14:36.287+01:00 Received resource from an interceptor - returning
    2018-02-23T10:14:36.287+01:00 Returning resource as found in the aggregated repositories
    2018-02-23T10:14:36.287+01:00 Intercepting found resource with 'PomInterceptor'
    2018-02-23T10:14:36.287+01:00 Intercepting found resource with 'MavenMetadataInterceptor'
    2018-02-23T10:14:36.287+01:00 Requested resource is found = true
    2018-02-23T10:14:36.287+01:00 Request is HEAD = false
    2018-02-23T10:14:36.287+01:00 Request is for a checksum = false
    2018-02-23T10:14:36.288+01:00 Target repository is not remote or doesn't store locally = true
    2018-02-23T10:14:36.288+01:00 Requested resource was not modified = false
    2018-02-23T10:14:36.288+01:00 Responding with found resource
    2018-02-23T10:14:36.288+01:00 Executing any AltResponse user plugins that may exist
    2018-02-23T10:14:36.288+01:00 Alternative response status is set to -1 and message to 'null'
    2018-02-23T10:14:36.288+01:00 Found no alternative content handles
    2018-02-23T10:14:36.288+01:00 Retrieving a content handle from target repo
    2018-02-23T10:14:36.288+01:00 The requested resource is already resolved - using a string resource handle
    2018-02-23T10:14:36.288+01:00 Executing any BeforeDownload user plugins that may exist
    2018-02-23T10:14:36.288+01:00 Responding with selected content handle
    2018-02-23T10:14:36.300+01:00 Request succeeded
    
    real    0m30.316s
    user    0m0.002s
    sys 0m0.011s
    
    3 回复  |  直到 7 年前
        1
  •  1
  •   DrGecko    6 年前

    回答我自己的问题:

    我可以通过更改以下Artifactory LDAP设置来解决此问题:

    [1] 更改了LDAP URL,使其包含包含用户的OU的完整DN:

    ldaps://redacted-server-hostname:636/ou=company-staff,ou=company-users,dc=subdomain,dc=company,dc=com
    

    [2] 已禁用搜索子树选项。

    这似乎显著提高了性能

        2
  •  0
  •   Arnaud Jeansen    7 年前

    maven元数据。xml 是一个簿记XML文件,位于工件的根目录,列出给定工件的所有版本。

    例如,使用此层次结构

    com
      \---redacted
          \---product
                \---maven-metadata.xml
                \---2.7.5
                \---2.7.7
    

    文件将包含

    <?xml version="1.0" encoding="UTF-8"?>
    <metadata>
      <groupId>com.redacted</groupId>
      <artifactId>product</artifactId>
      <versioning>
        <latest>2.7.7</latest>
        <release>2.7.7</release>
        <versions>
          <version>2.7.5</version>
          <version>2.7.7</version>
        </versions>
        <lastUpdated>20180219142822</lastUpdated>
      </versioning>
    </metadata>
    

    当您为此工件上载新版本2.7.8时,服务器将:

    • maven元数据。xml
    • 插入新版本2.7.8
    • 使现代化 maven元数据。xml
    • 解锁 maven元数据。xml

    所以我很确定,这个文件需要时间来检索的时间是在上载同一工件的快照版本时。

    当然,这是出于设计考虑,Artifactory尽了最大努力防止您收到过时的文件。 我认为你不应该考虑修理这个。。。

        3
  •  -1
  •   rosencreuz    7 年前

    Tomcat严重依赖SecureRandom类来提供随机值。如果用于初始化SecureRandom的熵源缺少熵,则会导致启动过程中的延迟。

    通过设置以下系统属性,可以将JRE配置为使用非阻塞熵源:

    -Djava.security.egd=file:/dev/./urandom
    

    将此选项添加到当前 JAVA_OPTS 可能会解决您的超时问题。