X-lab2017 / od-api

A repository for transforming response data format from open-digger
5 stars 2 forks source link

[bug] API rate limit exceeded for server #14

Open zhicheng-ning opened 1 year ago

zhicheng-ning commented 1 year ago

在 #12 中设置每日凌晨 5 点更新 repo statistic 数据后,在服务器中的日志中发现 API 速率超过限制,查看 GitHub API 文档后发现,普通的授权 token 每小时只能发起 5000 次请求。因此在每小时的请求次数耗尽后,该小时内无法再进行请求。

situation:

{
"message": "API rate limit exceeded for 219.78.228.97. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
"documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
}

reason:

User-to-server requests are limited to 5,000 requests per hour and per authenticated user. All requests from OAuth applications authorized by a user or a personal access token owned by the user, and requests authenticated with any of the user's authentication credentials, share the same quota of 5,000 requests per hour for that user.

image

zhicheng-ning commented 1 year ago

考虑对 token 进行池化,维护一个 GitHub API 的 token 池

zhicheng-ning commented 1 year ago

目前的解决方式是通过配置文件将多个 token 注入到代码中的 token 列表,在进行请求的时候通过轮询顺序从 token 列表中取一个 token 发起请求