Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7e6a2b67
authored
Sep 03, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: able to config rate limit (close #477)
parent
963d9a34
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
README.md
+3
-0
common/constants.go
+2
-2
No files found.
README.md
View file @
7e6a2b67
...
@@ -311,6 +311,9 @@ graph LR
...
@@ -311,6 +311,9 @@ graph LR
+
如果你遇到了数据库连接数过多的问题,可以尝试启用该选项。
+
如果你遇到了数据库连接数过多的问题,可以尝试启用该选项。
11.
`BATCH_UPDATE_INTERVAL=5`
:批量更新聚合的时间间隔,单位为秒,默认为
`5`
。
11.
`BATCH_UPDATE_INTERVAL=5`
:批量更新聚合的时间间隔,单位为秒,默认为
`5`
。
+
例子:
`BATCH_UPDATE_INTERVAL=5`
+
例子:
`BATCH_UPDATE_INTERVAL=5`
12.
请求频率限制:
+
`GLOBAL_API_RATE_LIMIT`
:全局 API 速率限制(除中继请求外),单 ip 三分钟内的最大请求数,默认为
`180`
。
+
`GLOBAL_WEB_RATE_LIMIT`
:全局 Web 速率限制,单 ip 三分钟内的最大请求数,默认为
`60`
。
### 命令行参数
### 命令行参数
1.
`--port <port_number>`
: 指定服务器监听的端口号,默认为
`3000`
。
1.
`--port <port_number>`
: 指定服务器监听的端口号,默认为
`3000`
。
...
...
common/constants.go
View file @
7e6a2b67
...
@@ -114,10 +114,10 @@ var (
...
@@ -114,10 +114,10 @@ var (
// All duration's unit is seconds
// All duration's unit is seconds
// Shouldn't larger then RateLimitKeyExpirationDuration
// Shouldn't larger then RateLimitKeyExpirationDuration
var
(
var
(
GlobalApiRateLimitNum
=
180
GlobalApiRateLimitNum
=
GetOrDefault
(
"GLOBAL_API_RATE_LIMIT"
,
180
)
GlobalApiRateLimitDuration
int64
=
3
*
60
GlobalApiRateLimitDuration
int64
=
3
*
60
GlobalWebRateLimitNum
=
60
GlobalWebRateLimitNum
=
GetOrDefault
(
"GLOBAL_WEB_RATE_LIMIT"
,
60
)
GlobalWebRateLimitDuration
int64
=
3
*
60
GlobalWebRateLimitDuration
int64
=
3
*
60
UploadRateLimitNum
=
10
UploadRateLimitNum
=
10
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment