Server: limit actions for each request between pods

This commit is contained in:
Chocobozzz 2016-07-06 19:59:01 +02:00
parent 4fea95df04
commit b359546358
2 changed files with 7 additions and 3 deletions

View 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,

View 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) {