@tramvai/module-request-limiter 1.85.0 → 1.89.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lib/server.es.js +4 -4
- package/lib/server.js +4 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -57,6 +57,9 @@ const provider = {
|
|
|
57
57
|
};
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
The basic settings should work well for most applications, as there is a system built in to adapt and automatically change the parameters relative to the loads. As a result, change the settings after you have done a load test and know that the changes will definitely improve the situation
|
|
61
|
+
|
|
62
|
+
|
|
60
63
|
## Explanation
|
|
61
64
|
|
|
62
65
|
After the server starts, request limiter can handle `options.limit` parallel connections.
|
package/lib/server.es.js
CHANGED
|
@@ -80,7 +80,7 @@ class RequestLimiter {
|
|
|
80
80
|
this.queue = new DoubleLinkedList();
|
|
81
81
|
const { limit = DEFAULT_OPTIONS.limit, queue = DEFAULT_OPTIONS.queue, maxEventLoopDelay = DEFAULT_OPTIONS.maxEventLoopDelay, error = DEFAULT_OPTIONS.error, } = options;
|
|
82
82
|
this.activeRequestLimit = limit;
|
|
83
|
-
this.minimalActiveRequestLimit = Math.
|
|
83
|
+
this.minimalActiveRequestLimit = Math.round(limit / 3);
|
|
84
84
|
this.queueLimit = queue;
|
|
85
85
|
this.error = error;
|
|
86
86
|
this.maxEventLoopDelay = maxEventLoopDelay;
|
|
@@ -95,12 +95,12 @@ class RequestLimiter {
|
|
|
95
95
|
if (Number.isNaN(this.eventLoopDelay))
|
|
96
96
|
this.eventLoopDelay = Infinity;
|
|
97
97
|
this.eventLoopHistogram.reset();
|
|
98
|
-
if (this.currentActive >= this.activeRequestLimit
|
|
99
|
-
this.activeRequestLimit > this.minimalActiveRequestLimit) {
|
|
98
|
+
if (this.currentActive >= this.activeRequestLimit) {
|
|
100
99
|
if (this.eventLoopDelay <= this.maxEventLoopDelay) {
|
|
101
100
|
this.activeRequestLimit++;
|
|
101
|
+
// We need to have minimalActiveRequestLimit
|
|
102
102
|
}
|
|
103
|
-
else {
|
|
103
|
+
else if (this.activeRequestLimit > this.minimalActiveRequestLimit) {
|
|
104
104
|
this.activeRequestLimit--;
|
|
105
105
|
}
|
|
106
106
|
}
|
package/lib/server.js
CHANGED
|
@@ -88,7 +88,7 @@ class RequestLimiter {
|
|
|
88
88
|
this.queue = new DoubleLinkedList();
|
|
89
89
|
const { limit = DEFAULT_OPTIONS.limit, queue = DEFAULT_OPTIONS.queue, maxEventLoopDelay = DEFAULT_OPTIONS.maxEventLoopDelay, error = DEFAULT_OPTIONS.error, } = options;
|
|
90
90
|
this.activeRequestLimit = limit;
|
|
91
|
-
this.minimalActiveRequestLimit = Math.
|
|
91
|
+
this.minimalActiveRequestLimit = Math.round(limit / 3);
|
|
92
92
|
this.queueLimit = queue;
|
|
93
93
|
this.error = error;
|
|
94
94
|
this.maxEventLoopDelay = maxEventLoopDelay;
|
|
@@ -103,12 +103,12 @@ class RequestLimiter {
|
|
|
103
103
|
if (Number.isNaN(this.eventLoopDelay))
|
|
104
104
|
this.eventLoopDelay = Infinity;
|
|
105
105
|
this.eventLoopHistogram.reset();
|
|
106
|
-
if (this.currentActive >= this.activeRequestLimit
|
|
107
|
-
this.activeRequestLimit > this.minimalActiveRequestLimit) {
|
|
106
|
+
if (this.currentActive >= this.activeRequestLimit) {
|
|
108
107
|
if (this.eventLoopDelay <= this.maxEventLoopDelay) {
|
|
109
108
|
this.activeRequestLimit++;
|
|
109
|
+
// We need to have minimalActiveRequestLimit
|
|
110
110
|
}
|
|
111
|
-
else {
|
|
111
|
+
else if (this.activeRequestLimit > this.minimalActiveRequestLimit) {
|
|
112
112
|
this.activeRequestLimit--;
|
|
113
113
|
}
|
|
114
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-request-limiter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.89.1",
|
|
4
4
|
"description": "Enable different rendering modes for pages",
|
|
5
5
|
"main": "lib/server.js",
|
|
6
6
|
"module": "lib/server.es.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@tinkoff/dippy": "0.7.39",
|
|
35
|
-
"@tramvai/core": "1.
|
|
36
|
-
"@tramvai/tokens-server": "1.
|
|
35
|
+
"@tramvai/core": "1.89.1",
|
|
36
|
+
"@tramvai/tokens-server": "1.89.1",
|
|
37
37
|
"express": "^4.17.1",
|
|
38
38
|
"tslib": "^2.0.3"
|
|
39
39
|
}
|