aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-06 19:59:01 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-06 19:59:01 +0200
commitb359546358c39b839867ca920e10221979c65424 (patch)
tree03d9f57d9480ac4fba5d5f7ccf0f1311c92faafc /server
parent4fea95df04738290232bdc51696fb2233aa1a65e (diff)
downloadPeerTube-b359546358c39b839867ca920e10221979c65424.tar.gz
PeerTube-b359546358c39b839867ca920e10221979c65424.tar.zst
PeerTube-b359546358c39b839867ca920e10221979c65424.zip
Server: limit actions for each request between pods
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.js4
-rw-r--r--server/models/request.js6
2 files changed, 7 insertions, 3 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 55c555d04..32fe1645f 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -24,6 +24,9 @@ const PODS_SCORE = {
24// Number of requests in parallel we can make 24// Number of requests in parallel we can make
25const REQUESTS_IN_PARALLEL = 10 25const REQUESTS_IN_PARALLEL = 10
26 26
27// How many requests we put in request (request scheduler)
28const REQUESTS_LIMIT = 10
29
27// Number of requests to retry for replay requests module 30// Number of requests to retry for replay requests module
28const RETRY_REQUESTS = 5 31const RETRY_REQUESTS = 5
29 32
@@ -71,6 +74,7 @@ module.exports = {
71 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT, 74 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT,
72 PODS_SCORE: PODS_SCORE, 75 PODS_SCORE: PODS_SCORE,
73 REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL, 76 REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL,
77 REQUESTS_LIMIT: REQUESTS_LIMIT,
74 RETRY_REQUESTS: RETRY_REQUESTS, 78 RETRY_REQUESTS: RETRY_REQUESTS,
75 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS, 79 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS,
76 SORTABLE_COLUMNS: SORTABLE_COLUMNS, 80 SORTABLE_COLUMNS: SORTABLE_COLUMNS,
diff --git a/server/models/request.js b/server/models/request.js
index 7fdf5bd31..248ab3303 100644
--- a/server/models/request.js
+++ b/server/models/request.js
@@ -102,7 +102,7 @@ function makeRequest (toPod, requestsToMake, callback) {
102function makeRequests () { 102function makeRequests () {
103 const self = this 103 const self = this
104 104
105 list.call(self, function (err, requests) { 105 listWithLimit.call(self, constants.REQUESTS_LIMIT, function (err, requests) {
106 if (err) { 106 if (err) {
107 logger.error('Cannot get the list of requests.', { err: err }) 107 logger.error('Cannot get the list of requests.', { err: err })
108 return // Abort 108 return // Abort
@@ -269,8 +269,8 @@ function updatePodsScore (goodPods, badPods) {
269 }) 269 })
270} 270}
271 271
272function list (callback) { 272function listWithLimit (limit, callback) {
273 this.find({ }, { _id: 1, request: 1, to: 1 }).sort({ _id: 1 }).exec(callback) 273 this.find({ }, { _id: 1, request: 1, to: 1 }).sort({ _id: 1 }).limit(limit).exec(callback)
274} 274}
275 275
276function removeAll (callback) { 276function removeAll (callback) {