1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Add middleware for request prioritization (#33951)

This adds a middleware for overload protection that is intended to help protect against malicious scrapers.
It does this via [`codel`](https://github.com/bohde/codel), which will perform the following:

1. Limit the number of in-flight requests to some user-defined max
2. When in-flight requests have reached their begin queuing requests.
    Logged-in requests having priority above logged-out requests
3. Once a request has been queued for too long,
    it has a probabilistic chance to be rejected based on how overloaded the entire system is.

When a server experiences more traffic than it can handle,
this keeps latency low for logged-in users and rejects just
enough requests from logged-out users to not overload the service.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
Rowan Bohde
2025-04-14 09:25:48 -05:00
committed by GitHub
parent 3a9fcac11b
commit c57304ac3f
10 changed files with 301 additions and 2 deletions

12
templates/status/503.tmpl Normal file
View File

@@ -0,0 +1,12 @@
{{template "base/head" .}}
<div role="main" aria-label="503 Service Unavailable" class="page-content">
<div class="ui container">
<div class="status-page-error">
<div class="status-page-error-title">503 Service Unavailable</div>
<div class="tw-text-center">
<div class="tw-my-4">{{ctx.Locale.Tr "error503"}}</div>
</div>
</div>
</div>
</div>
{{template "base/footer" .}}