Saturday, May 25, 2019

How to improve performance of Advanced agent

Advanced agent, normally we used to enable in only one node to avoid conflicts in multi-node environment (Prior to 7.3).

Now that Pega in latest versions provided an option "Run only on one node". That means even if we enable in multiple nodes, it would ensure that at a time advanced agent runs only on one node.

Suppose if we have large load of some 50000 records which would be processed by single advanced agent, it would take lot of time, and it would not fit into all the applications. To have a improvement on performance, below is one way where we share the load with n number of advanced agents instead of one using modulus approach.

For simplicity, to explain the concept we are assuming n=3 and proceeding with below. You can decide on n in your real-time scenario and follow divide and conquer algorithm.

Suppose you have below records to be processed by advanced agent activity:



We would have logic in AdvancedAgent ready and perform the below:
  • Additionally you need to take care of passing the Param.BatchID (i.e. 0, 1, 2) to the AdvancedAgentActivity.
  • And that Param.BatchID would be useful to browse only those fixed set of records (JobID%3==Param.BatchID) with respective agent for processing thus reducing the overhead. 

 Below is how we distributed the load to 3 different agents which would speed up processing.


This is one of the ways to improve performance of advanced agent.



5 comments:

  1. This is very useful information. But how do we pass the batch ID differently for different node ID? Is this is from the Agent instance?

    ReplyDelete
    Replies
    1. Hi Sandeep, we would coding three agents in this scenario as shown below:
      ProcessRecordsBatchOne
      ProcessRecordsBatchTwo
      ProcessRecordsBatchThree
      However, agent activity for the above three agents remain same: lets say
      ProcessRecordsBatchOne => ProcessRecords (Param passed will be 0)
      ProcessRecordsBatchTwo => ProcessRecords (Param passed will be 1)
      ProcessRecordsBatchThree => ProcessRecords (Param passed will be 2)

      In the above representation ProcessRecords will be the same agent activity but params will be passed differently to each agent activity w.r.t each agent.

      That way, we can ensure that advanced agent wont run into lock issues by distributing the load.
      In the latest versions of Pega, in advanced agent "Run on only one node at a time" feature is provided which is smart. You can explore that too.

      Delete
  2. But how do we pass the batch ID differently for different node ID? Is this is from the Agent instance?

    ReplyDelete
    Replies
    1. Hi, we would coding three agents in this scenario as shown below:
      ProcessRecordsBatchOne
      ProcessRecordsBatchTwo
      ProcessRecordsBatchThree
      However, agent activity for the above three agents remain same: lets say
      ProcessRecordsBatchOne => ProcessRecords (Param passed will be 0)
      ProcessRecordsBatchTwo => ProcessRecords (Param passed will be 1)
      ProcessRecordsBatchThree => ProcessRecords (Param passed will be 2)

      In the above representation ProcessRecords will be the same agent activity but params will be passed differently to each agent activity w.r.t each agent.

      That way, we can ensure that advanced agent wont run into lock issues by distributing the load.
      In the latest versions of Pega, in advanced agent "Run on only one node at a time" feature is provided which is smart. You can explore that too.

      Delete
  3. This is really helpful, but wanted to understand if we use "Delay next run of agent across the cluster by specified time period" then can we get rid of locking issue with an Advance Agent(If it is running on multi node)?

    ReplyDelete


HowToPega : All rights reserved and the contents are copyrighted to Pavan Kumar Naidu