Skip to content

Commit

Permalink
FEATURE: Make batch size configurable
Browse files Browse the repository at this point in the history
To control the memory usage of single indexing jobs better the
batch size can now be configured via the:

    Flowpack:
      ElasticSearch:
        ContentRepositoryQueueIndexer:
          batchSize: 50

configuration setting. For backwards compatibility reasons a fallback
of 500 (the old hardcoded default) exists if the setting was not
configured at all.
  • Loading branch information
kitsunet committed Sep 19, 2017
1 parent a1b9ca5 commit d7beec6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Classes/Command/NodeIndexQueueCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class NodeIndexQueueCommandController extends CommandController

const BATCH_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer';
const LIVE_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer.Live';
const DEFAULT_BATCH_SIZE = 500;

/**
* @var JobManager
Expand Down Expand Up @@ -69,6 +70,12 @@ class NodeIndexQueueCommandController extends CommandController
*/
protected $nodeIndexer;

/**
* @Flow\InjectConfiguration(package="Flowpack.ElasticSearch.ContentRepositoryQueueIndexer")
* @var array
*/
protected $settings;

/**
* Index all nodes by creating a new index and when everything was completed, switch the index alias.
*
Expand Down Expand Up @@ -210,7 +217,7 @@ protected function indexWorkspace($workspaceName, $indexPostfix)
$this->outputLine('<info>++</info> Indexing %s workspace', [$workspaceName]);
$nodeCounter = 0;
$offset = 0;
$batchSize = 500;
$batchSize = $this->settings['batchSize'] ?? static::DEFAULT_BATCH_SIZE;
while (true) {
$iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $offset, $batchSize);

Expand Down
3 changes: 2 additions & 1 deletion Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Flowpack:
ElasticSearch:
ContentRepositoryQueueIndexer:
enableLiveAsyncIndexing: true

# Change size of single batch jobs via this setting (fallback default is 500)
# batchSize: 50
JobQueue:
Common:
queues:
Expand Down

0 comments on commit d7beec6

Please sign in to comment.