Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38937

GitHub API cache is not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • Jenkins 2.19.1 (LTS)
      GitHub API Plugin 1.7.7
      GitHub plugin 1.22.1

      After moving to Jenkins new LTS release, we found that we were constantly running into our rate limit with github. To start the investigation of this issue, I contacted github support, and requested any information they could provide about our use of the API over the last week.

      This was the information github support sent back. (Org and projects redacted)

      Hi Greg,
      
      Here are some stats for your account, for the past week.
      
      The top 10 API endpoints being hit:
      
      /repositories/:repository_id/contents/?*        196,620 25.632%
      /repositories/:repository_id    109,038 14.215%
      /repositories/:repository_id/collaborators      103,631 13.51%
      /user   79,102  10.312%
      /       78,743  10.265%
      /repositories/:repository_id/branches   77,789  10.141%
      /repositories/:repository_id/pulls      77,474  10.1%
      /user/:user_id  14,014  1.827%
      /repositories/:repository_id/git/refs/* 11,154  1.454%
      /repositories/:repository_id/pulls/:id  10,582  1.38%
      
      Top 10 specific resources:
      
      /       97,571  10.37%
      /user   96,932  10.302%
      /repos/{org}/{projectA}/contents/        22,552  2.397%
      /repos/{org}/{projectB}/contents/   21,249  2.258%
      /repositories/{repoA}/collaborators    20,004  2.126%
      /repositories/{repoB}/collaborators    18,058  1.919%
      /users/{org}   17,241  1.832%
      /repositories/{repoC}/collaborators    16,538  1.758%
      /repos/{org}/{projectC}/contents/   10,657  1.133%
      /repos/{org}/{projectD}/contents/      9,751   1.036%
      
      There are some very interesting things there, as I'm sure you notice. Over 20% of your total quota is wasted on fetching and re-fetching resources which either never change or change very rarely -- the root endpoint of the API / (which has only links to other resources) and the resource for the current user /user (which changes very rarely). And that /user endpoint is sometimes being called 100 times per minute. I can't imagine why you'd need to fetch those resources so often. Reducing or completely removing that would keep you well below the rate limit.
      

      After getting this report back from GitHub support directly, I started to investigate, and found that it does not appear that the cache file is currently being used, or written to at all.

      On my System Configuration page, I have configured GitHub to use the default 20mb cache, but my system has no normal cache directory. (I know it was there before I moved to LTS version, which was recent)

      My creds are on the System Configuration page, and verified, and when I click test, I can see what my current rate is. But no cache is being used, and I imagine that is why over 20% of our api requests to github are to static, unchanged values.

      This could be related to JENKINS-38935, which I also found while investigating this problem

            Unassigned Unassigned
            gregcovertsmith Greg Smith
            Votes:
            1 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: