Problem Statement:
AEM Bulk Replication allows you to activate a series of pages and/or assets.
How can we make sure workflow won’t impact AEM performance (CPU or Heap memory) / throttle the system?
Introduction:
AEM bulk replication or activation is performed on a series of pages and/or assets. We usually perform bulk replication on tree structures or lists of paths.
Use case:
- MSM (Multi-site management) – rolling out a series of pages or site
- Editable template – add/remove new components on template structure and activate existing pages
- Bulk Asset ingests into the system
- Bulk redirect//vanity path update
ACS Commons Throttled Task Runner is built on Java management API for managing and monitoring the Java VM and can be used to pause tasks and terminate the tasks based on stats.
Throttled Task Runner (a managed thread pool) provides a convenient way to run many AEM-specific activities in bulk it basically checks for the Throttled Task Runner bean and gets current running stats of the actual work being done.
OSGi Configuration:
The Throttled Task Runner is OSGi configurable, but please note that changing configuration while work is being processed results in resetting the worker pool and can lose active work.

Max threads: Recommended not to exceed the number of CPU cores. Default 4.
Max CPU %: Used to throttle activity when CPU exceeds this amount. Range is 0..1; -1 means disable this check.
Max Heap %: Used to throttle activity when heap usage exceeds this amount. Range is 0..1; -1 means disable this check.
Cooldown time: Time to wait for CPU/MEM cooldown between throttle checks (in milliseconds)
Watchdog time: Maximum time allowed (in ms) per action before it is interrupted forcefully.
JMX MBeans
Throttled Task Runner MBean
This is the core worker pool. All action managers share the same task runner pool, at least in the current implementation. The task runner can be paused or halted entirely, throwing out any unfinished work.

How to use ACS Commons throttled task runner
Add the following dependency to your pom
Create a custom service or servlet as shown below:

inside the custom workflow process method check for the Low CPU and Low memory before starting your task to avoid performance impact on the system.
For bulk replication (publish/unpublish/delete) assets or pages, please refer to the AEM Operation Replication Tool
For best practices on the AEM servlet please refer to the link.
One thought on “AEM Performance Optimization Activation/Replication”