]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Server: limit actions for each request between pods
authorChocobozzz <florian.bigard@gmail.com>
Wed, 6 Jul 2016 17:59:01 +0000 (19:59 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Wed, 6 Jul 2016 17:59:01 +0000 (19:59 +0200)
server/initializers/constants.js
server/models/request.js

index 55c555d04c086eff23236e0d5be59758506270d3..32fe1645f607792acbee50fd9cdcdd455e342c6b 100644 (file)
@@ -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,
index 7fdf5bd31ea7352343b394eecb84ea1c7391761f..248ab330306735cfd693da8bc32139bb617b8596 100644 (file)
@@ -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) {