Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Server: limit actions for each request between pods

Chocobozzzb359546358c3
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 55c555d04c..32fe1645f6 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -24,6 +24,9 @@ const PODS_SCORE = {
// Number of requests in parallel we can make
const REQUESTS_IN_PARALLEL = 10
+// How many requests we put in request (request scheduler)
+const REQUESTS_LIMIT = 10
+
// Number of requests to retry for replay requests module
const RETRY_REQUESTS = 5
@@ -71,6 +74,7 @@ module.exports = {
PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT,
PODS_SCORE: PODS_SCORE,
REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL,
+ REQUESTS_LIMIT: REQUESTS_LIMIT,
RETRY_REQUESTS: RETRY_REQUESTS,
SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS,
SORTABLE_COLUMNS: SORTABLE_COLUMNS,
diff --git a/server/models/request.js b/server/models/request.js
index 7fdf5bd31e..248ab33030 100644
--- a/server/models/request.js
+++ b/server/models/request.js
@@ -102,7 +102,7 @@ function makeRequest (toPod, requestsToMake, callback) {
function makeRequests () {
const self = this
- list.call(self, function (err, requests) {
+ listWithLimit.call(self, constants.REQUESTS_LIMIT, function (err, requests) {
if (err) {
logger.error('Cannot get the list of requests.', { err: err })
return // Abort
@@ -269,8 +269,8 @@ function updatePodsScore (goodPods, badPods) {
})
}
-function list (callback) {
- this.find({ }, { _id: 1, request: 1, to: 1 }).sort({ _id: 1 }).exec(callback)
+function listWithLimit (limit, callback) {
+ this.find({ }, { _id: 1, request: 1, to: 1 }).sort({ _id: 1 }).limit(limit).exec(callback)
}
function removeAll (callback) {