Skip to content

Commit fa2064e

Browse files
authored
Merge pull request #43535 from github/repo-sync
Repo sync
2 parents e602312 + 0884378 commit fa2064e

File tree

7 files changed

+287
-27
lines changed

7 files changed

+287
-27
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: Best practices for configuring API rate limits
3+
shortTitle: API rate limits best practices
4+
intro: 'A data-driven approach to API rate limits protects your {% data variables.product.prodname_ghe_server %} instance from excessive usage without disrupting critical integrations.'
5+
permissions: Site administrators can configure rate limits for a {% data variables.product.prodname_ghe_server %} instance.
6+
versions:
7+
ghes: '*'
8+
contentType: how-tos
9+
category:
10+
- Enable GitHub features for your enterprise
11+
---
12+
13+
## About a data-driven approach to rate limits
14+
15+
Without rate limits, a single CI integration making tens of thousands of requests per hour can slow down your entire instance for every user. But setting limits too aggressively can break the integrations your teams rely on. A data-driven approach helps you find the right balance—start by observing real usage patterns, then gradually enforce limits based on the data you collect.
16+
17+
The approach follows these phases:
18+
19+
1. **Observe**: Enable log forwarding and analyze API traffic patterns.
20+
1. **Baseline**: Enable rate limits with a high initial value to start collecting rate limit data.
21+
1. **Refine**: Adjust limits based on observed usage and communicate with affected teams.
22+
1. **Maintain**: Continuously monitor and adjust limits over time.
23+
24+
For information about enabling rate limits through the {% data variables.enterprise.management_console %}, see [AUTOTITLE](/admin/configuring-settings/configuring-user-applications-for-your-enterprise/configuring-rate-limits).
25+
26+
## Prerequisites
27+
28+
Before you begin, make sure you have:
29+
30+
* Admin access to the {% data variables.enterprise.management_console %}
31+
* Access to log forwarding configuration
32+
* The ability to analyze centralized logs
33+
* An understanding of your organization's API usage patterns and critical integrations
34+
35+
## Step 1: Enable log forwarding
36+
37+
Use log forwarding to centralize API request logs for monitoring and analysis. For more information, see [AUTOTITLE](/admin/monitoring-activity-in-your-enterprise/exploring-user-activity-in-your-enterprise/log-forwarding).
38+
39+
When analyzing forwarded logs, focus on these key fields:
40+
41+
| Field | Description |
42+
|-------|-------------|
43+
| `Timestamp` | Tracks when requests are made |
44+
| `user` / `gh.actor.login` | Identifies the user or integration making requests |
45+
| `path_info` / `gh.request.api.route` | The API route being accessed |
46+
| `status` | HTTP response code (for example, `200` for success or `429` when rate limited) |
47+
| `user_agent` | Identifies the client or integration sending the request |
48+
49+
## Step 2: Analyze API trends before enabling limits
50+
51+
Before enabling rate limits, analyze your overall usage trends to establish a baseline:
52+
53+
* **Identify top consumers.** Find users or integrations making the highest number of requests.
54+
* **Review high-demand endpoints.** Highlight API routes (`path_info`) that receive the most traffic and may benefit from optimization.
55+
* **Detect inefficient patterns.** Look for signs of heavy or inefficient usage, such as frequent polling without caching or redundant requests.
56+
57+
This baseline data will help you set rate limits that are informed by actual usage rather than guesswork.
58+
59+
## Step 3: Enable rate limits with a high initial value
60+
61+
When you're ready to enable rate limits, start with a high threshold so you can gather additional data without disrupting existing workflows.
62+
63+
1. In the {% data variables.enterprise.management_console %}, set the primary API rate limit to a high value, such as 25,000 requests per hour. For more information, see [AUTOTITLE](/admin/configuring-settings/configuring-user-applications-for-your-enterprise/configuring-rate-limits#enabling-rate-limits-for-the-github-enterprise-server-apis).
64+
1. After enabling rate limits, monitor the `gh.rate_limit` fields that appear in your forwarded logs:
65+
66+
| Field | Description |
67+
|-------|-------------|
68+
| `gh.rate_limit.primary.max` | Maximum allowed requests |
69+
| `gh.rate_limit.primary.remaining` | Remaining requests in the current period |
70+
| `gh.rate_limit.primary.used` | Requests already made in the period |
71+
| `gh.rate_limit.primary.reset` | Unix timestamp when the rate limit period resets |
72+
73+
## Step 4: Refine limits and address heavy usage
74+
75+
Use the data from the `gh.rate_limit` fields to make informed decisions:
76+
77+
* **Identify users nearing the limit.** Find users or integrations that are frequently approaching or exceeding the threshold.
78+
* **Determine appropriate limits.** Set rate limits based on observed usage trends rather than arbitrary values.
79+
* **Communicate with affected teams.** Work with teams to optimize their API usage through techniques like request batching, response caching, and conditional requests.
80+
81+
## Step 5: Reduce limits and maintain over time
82+
83+
Once you have a clear picture of your API usage, gradually reduce the rate limit to align with your instance's capacity and actual usage patterns. Monitor for unintended disruptions after each adjustment.
84+
85+
As you refine limits, work with teams whose integrations are affected. Techniques like request batching, response caching, and conditional requests can help teams reduce their API usage. You can also exempt specific users from rate limits using the `ghe-config` utility. For more information, see [AUTOTITLE](/admin/administering-your-instance/administering-your-instance-from-the-command-line/command-line-utilities#ghe-config).
86+
87+
Review your rate limit data periodically, since usage patterns change as new integrations are added and workflows evolve.
88+
89+
## Additional considerations
90+
91+
* **GraphQL API limits.** The GraphQL API has a separate rate limit (default: 5,000 points per hour) that cannot be bypassed through the exemption list. For more information, see [AUTOTITLE](/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api).
92+
* **Secondary rate limits.** You can also enable secondary rate limits to protect the overall level of service. For more information, see [AUTOTITLE](/admin/configuring-settings/configuring-user-applications-for-your-enterprise/configuring-rate-limits#enabling-secondary-rate-limits).
93+
94+
## Further reading
95+
96+
* [AUTOTITLE](/rest/overview/rate-limits-for-the-rest-api)

content/admin/configuring-settings/configuring-user-applications-for-your-enterprise/configuring-rate-limits.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,43 @@ category:
1717

1818
## About rate limits for {% data variables.product.prodname_ghe_server %}
1919

20-
To prevent excessive use of resources on {% data variables.location.product_location %} that could affect the instance's availability or performance for all users, you can configure rate limits. Rate limits are configurable for the {% data variables.product.prodname_enterprise_api %} and {% data variables.product.prodname_actions %}.
20+
Rate limits help prevent excessive resource use on {% data variables.location.product_location %} that could affect availability or performance for all users. You can configure rate limits for the {% data variables.product.prodname_enterprise_api %} and {% data variables.product.prodname_actions %}.
2121

22-
Implement rate limits carefully and communicate frequently with your users as you tune the limits. To avoid interrupting your users' work, {% data variables.product.company_short %} recommends that you start with permissive rate limits, and gradually tune the limits to suit your environment.
22+
Implement rate limits carefully and communicate with your users as you tune them. Start with permissive rate limits and gradually adjust them to suit your environment.
2323

2424
You can also configure rate limits for authentication attempts to the {% data variables.enterprise.management_console %}. For more information, see [AUTOTITLE](/admin/configuration/administering-your-instance-from-the-management-console/managing-access-to-the-management-console#configuring-rate-limits-for-authentication-to-the-management-console).
2525

2626
## Enabling rate limits for the {% data variables.product.prodname_enterprise_api %}
2727

28-
Excessive numbers of requests to the {% data variables.product.prodname_enterprise_api %} can affect the availability and performance of your instance. For more information about how rate limits for the API affect your users, see [AUTOTITLE](/rest/overview/rate-limits-for-the-rest-api).
28+
Too many requests to the {% data variables.product.prodname_enterprise_api %} can slow down your instance or make it unavailable. For more information about how API rate limits affect your users, see [AUTOTITLE](/rest/overview/rate-limits-for-the-rest-api).
2929

30-
You can exempt a list of users from API rate limits using the `ghe-config` utility in the administrative shell. For more information, see [AUTOTITLE](/admin/configuration/configuring-your-enterprise/command-line-utilities#ghe-config).
30+
You can exempt specific users from API rate limits using the `ghe-config` utility in the administrative shell. For more information, see [AUTOTITLE](/admin/configuration/configuring-your-enterprise/command-line-utilities#ghe-config).
3131

3232
> [!NOTE]
3333
> The {% data variables.enterprise.management_console %} lists the time period (per minute or per hour) for each rate limit.
3434
3535
{% data reusables.enterprise_site_admin_settings.access-settings %}
3636
{% data reusables.enterprise_site_admin_settings.management-console %}
3737
1. Under "Rate Limiting", select **Enable HTTP API Rate Limiting**.
38-
1. Type limits for authenticated and unauthenticated requests for each API, or accept the pre-filled default limits.
38+
1. Enter limits for authenticated and unauthenticated requests for each API, or accept the prefilled default limits.
3939
{% data reusables.enterprise_management_console.save-settings %}
4040

4141
## Enabling secondary rate limits
4242

43-
Setting secondary rate limits protects the overall level of service on {% data variables.location.product_location %}.
43+
Secondary rate limits help keep {% data variables.location.product_location %} stable for all users.
4444

4545
{% data reusables.enterprise_site_admin_settings.access-settings %}
4646
{% data reusables.enterprise_site_admin_settings.management-console %}
4747
1. Under "Rate Limiting", select **Enable Secondary Rate Limiting**.
48-
1. Type limits for Total Requests, CPU Limit, and CPU Limit for Searching, or accept the pre-filled default limits.
48+
1. Enter limits for Total Requests, CPU Limit, and CPU Limit for Searching, or accept the prefilled default limits.
4949
{% data reusables.enterprise_management_console.save-settings %}
5050

5151
## Enabling rate limits for Git
5252

53-
If a member of {% data variables.product.company_short %}'s staff has recommended it, you can apply Git rate limits per repository network or per user ID. Git rate limits are expressed in concurrent operations per minute, and are adaptive based on the current CPU load.
53+
If a member of {% data variables.product.company_short %}'s staff has recommended it, you can apply Git rate limits per repository network or per user ID. Git rate limits are measured in concurrent operations per minute and adapt to the current CPU load.
5454

5555
> [!WARNING]
56-
> We encourage you to leave this setting disabled unless directly recommended by a member of {% data variables.product.company_short %}'s staff. Git operations are rarely the leading driver of CPU and RAM usage. Enabling this feature can make Git operations more likely to fail under high load conditions but does not address the underlying cause of those conditions.
56+
> Leave this setting disabled unless directly recommended by {% data variables.product.company_short %}'s staff. Git operations are rarely the leading driver of CPU and RAM usage. Enabling this feature can make Git operations more likely to fail under high load but doesn't address the underlying cause.
5757
5858
{% data reusables.enterprise_site_admin_settings.access-settings %}
5959
{% data reusables.enterprise_site_admin_settings.management-console %}
@@ -68,15 +68,15 @@ You can apply a rate limit to {% data variables.product.prodname_actions %} work
6868

6969
### About rate limits for {% data variables.product.prodname_actions %}
7070

71-
Your {% data variables.product.prodname_ghe_server %} instance assigns each {% data variables.product.prodname_actions %} workflow job to a runner. If your instance cannot immediately assign a job to an available runner, the job will wait in a queue until a runner is available. If {% data variables.product.prodname_actions %} experiences sustained high load, the queue can back up, and the performance of {% data variables.location.product_location %} may degrade.
71+
Your {% data variables.product.prodname_ghe_server %} instance assigns each {% data variables.product.prodname_actions %} workflow job to a runner. If your instance can't immediately assign a job to an available runner, the job waits in a queue. If {% data variables.product.prodname_actions %} experiences sustained high load, the queue can back up and the performance of {% data variables.location.product_location %} may degrade.
7272

73-
To avoid this performance degradation, you can configure a rate limit for {% data variables.product.prodname_actions %}. This rate limit is expressed in job runs per minute. {% data variables.product.prodname_ghe_server %} calculates and applies the rate limit for the sum total of all job runs on the instance. If runs exceed the rate limit, additional runs will fail instead of entering the queue. The following error will appear in the run's annotations.
73+
To avoid this, you can configure a rate limit for {% data variables.product.prodname_actions %}. This rate limit is measured in job runs per minute. {% data variables.product.prodname_ghe_server %} applies the rate limit across all job runs on the instance. If runs exceed the rate limit, additional runs fail instead of entering the queue. The following error appears in the run's annotations.
7474

7575
> You've exceeded the rate limit for workflow run requests. Please wait before retrying the run.
7676
77-
An appropriate rate limit protects {% data variables.location.product_location %} from abnormal usage of {% data variables.product.prodname_actions %} without interfering with day-to-day operations. The exact threshold depends on your instance's available resources and overall load profile. For more information about the hardware requirements for {% data variables.product.prodname_actions %}, see [AUTOTITLE](/admin/github-actions/getting-started-with-github-actions-for-your-enterprise/getting-started-with-github-actions-for-github-enterprise-server#review-hardware-requirements).
77+
A good rate limit protects {% data variables.location.product_location %} from unusual spikes in {% data variables.product.prodname_actions %} usage without interfering with day-to-day operations. The right threshold depends on your instance's available resources and typical workload. For more information about hardware requirements for {% data variables.product.prodname_actions %}, see [AUTOTITLE](/admin/github-actions/getting-started-with-github-actions-for-your-enterprise/getting-started-with-github-actions-for-github-enterprise-server#review-hardware-requirements).
7878

79-
By default, the rate limit for {% data variables.product.prodname_actions %} is disabled. Because {% data variables.product.prodname_ghe_server %} can handle temporary spikes in usage without performance degradation, this rate limit is intended to protect against sustained high load. We recommend leaving the rate limit disabled unless you are experiencing performance problems. In some cases, {% data variables.contact.github_support %} may recommend that you enable a rate limit for {% data variables.product.prodname_actions %}.
79+
By default, the rate limit for {% data variables.product.prodname_actions %} is disabled. {% data variables.product.prodname_ghe_server %} can handle temporary usage spikes without problems, so this rate limit protects against sustained high load. Leave it disabled unless you experience performance problems. In some cases, {% data variables.contact.github_support %} may recommend enabling a rate limit for {% data variables.product.prodname_actions %}.
8080

8181
### Enabling or disabling rate limits for {% data variables.product.prodname_actions %}
8282

@@ -88,7 +88,7 @@ By default, the rate limit for {% data variables.product.prodname_actions %} is
8888
ghe-config actions-rate-limiting.queue-runs-per-minute RUNS-PER-MINUTE
8989
```
9090

91-
1. To disable the rate limit after it's been enabled, run the following command.
91+
1. To disable the rate limit, run the following command.
9292

9393
```shell
9494
ghe-config actions-rate-limiting.enabled false
@@ -104,10 +104,10 @@ By default, the rate limit for {% data variables.product.prodname_actions %} is
104104

105105
## Controlling the rate for the live update service
106106

107-
If the number of AJAX requests to your {% data variables.product.prodname_ghe_server %} instance causes problems, then you may need to edit the rate limit for the WebSockets controller used by these live updates. For details of how to view Alive requests, see [AUTOTITLE](/admin/monitoring-and-managing-your-instance/monitoring-your-instance/about-the-monitor-dashboards).
107+
If the number of AJAX requests to your {% data variables.product.prodname_ghe_server %} instance causes problems, you may need to adjust the rate limit for the WebSockets controller used by these live updates. For details on how to view Alive requests, see [AUTOTITLE](/admin/monitoring-and-managing-your-instance/monitoring-your-instance/about-the-monitor-dashboards).
108108

109-
When primary rate limits are enabled, by default a maximum of 100 requests is allowed per minute for each IP address. Administrators with access to the administrative shell can use the [ghe-config](/admin/administering-your-instance/administering-your-instance-from-the-command-line/command-line-utilities#ghe-config) utility to set `app.github.web-sockets-rate-limit` with the number of requests allowed per minute for each IP address or disable this rate limit. Setting the limit to any value that is not a positive integer (for example, `0`, `-1`, `disabled`) disables rate limiting on the WebSockets controller for live updates.
109+
With primary rate limits enabled, the default limit is 100 requests per minute per IP address. Use the [ghe-config](/admin/administering-your-instance/administering-your-instance-from-the-command-line/command-line-utilities#ghe-config) utility in the administrative shell to set `app.github.web-sockets-rate-limit` to the number of requests allowed per minute per IP address, or to disable this rate limit. Setting the limit to any non-positive-integer value (for example, `0`, `-1`, `disabled`) disables rate limiting on the WebSockets controller.
110110

111111
{% data reusables.github-connect.rate-limit-live-dotcom-requests %}
112112

113-
After you make any changes to the values of these settings, run [ghe-config-apply](/admin/administering-your-instance/administering-your-instance-from-the-command-line/command-line-utilities#ghe-config-apply) to apply the settings.
113+
After you change these settings, run [ghe-config-apply](/admin/administering-your-instance/administering-your-instance-from-the-command-line/command-line-utilities#ghe-config-apply) to apply them.

content/admin/configuring-settings/configuring-user-applications-for-your-enterprise/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ children:
1010
- /configuring-email-for-notifications
1111
- /configuring-github-pages-for-your-enterprise
1212
- /configuring-rate-limits
13+
- /best-practices-for-configuring-api-rate-limits
1314
- /configuring-web-commit-signing
1415
- /configuring-interactive-maps
1516
- /managing-github-mobile-for-your-enterprise

0 commit comments

Comments
 (0)