another technical blog...technically

Thursday, April 27, 2017

A simple Blue Prism multi-robot example

I will talk about one of the most interesting things I've seen on Blue Prism, we're talking about multi-robot and task concurrency.
As you already know, to build a process on Blue Prism, you have to use one or more queues, which are built to manage concurrency between multiple robots.
The question is: how to optimize concurrency among multiple robots?
The answer is in the process design.
Let's think about the typical producer-consumer model we deal with when we tipically work with multi-thread and let's imagine three robots up and running.
Like you see i defined a main flow which references two subprocesses: producer and consumer.
The main flow is a infinite loop that will be started from the scheduler, to stop the loop you can use a decision stage that checks a finish time, written on an environment variable.
The first subprocess is the producer and populates the work queue.
It's kinda best practice to put a environment lock before the producer starts in order to have just a robot at a time working on the producer process.
This is due to the fact we want to avoid multiple robot to do concurrently the queue population process and not so useful checks on already existing queue items.
Consumer it's a simple loop that iterates on the queue until the queue itself it's empty, no lock here, because Blue Prism deals with concurrency and locks the work item itself.
I know it's a very simple process but this is the baseline for other stuff, right now i'm working on a process which has something like 2 producers and 3 consumers, playing with environment locks on producer processes i can optimize concurrent robot performances.
I heard someone who preferred to pre-assign work item to different robot but i think this is not a good idea, this is because you cannot be sure a single work item requires the same amount of time.
For example, in one of our project we had some work item requiring up to 7 hours of robot effort.
Item name Assigned to Avg duration
1 Robot 1 7h
2 Robot 2 1h
3 Robot 3 1h
4 Robot 1 6h
5 Robot 2 2h
6 Robot 3 3h

If you work the items with pre assignation you will have this work duration
Robot 1: 13h
Robot 2:   3h
Robot 3:   4h

This means you'll have very low efficiency on Robot 2 and Robot 3. Applying the multi-robot model you'll have something like this
Robot 1: 7h (1)
Robot 2: 1h (2) + 6h (4)
Robot 3: 1h (3) + 2h (5) + 3h (6)

As you can see you will have a workforce that dinamically take in account a queue item and tries to process item as fast as possible.
If you also have more than one process (i hope for you so) on your BP server, you can also think about a main process that plays with all registered processes in order to use robot workforce in the best way.

14 comments:

  1. Ciao Valerio,

    this is a very nice article about something that is not very well explained in BP documentation. I have only one question for you, how do the token part works... I was able to lock a process but not to unlock it because i didn't give a token in the first place. I know it sounds a stupid question but i'm stuck on that :(

    ReplyDelete
    Replies
    1. Hi Dupo,

      i remember you, we were colleagues :-) . So, at first, there are not stupid questions. Mind that BP, when you lock a process, returns a token as a output which is a session variable.
      When the consumer ends working you just have to release the token.
      Before to acquire the lock you just have to query what locks are out there with that specific name.
      If you need more info please keep alive the thread :-)

      Delete
  2. Ahhh... I didn't see the output parameter! I tried on a small process and it works very well :)

    Thank you very much Valerio and best wishes on your new job ;-)

    ReplyDelete
    Replies
    1. Don't worry, shit happens :-) .
      Thank you for the wishes

      Delete
  3. If the first process specifies a Preferred Token parameter when the lock is acquired, can a second process (or second instance of the same process in a multibot environment) force the release of that lock by calling the Release Lock action using the known Preferred Token value?

    ReplyDelete
    Replies
    1. Hi Michael, never tried this but i think you can do this or at least try in your environment. Let me know.

      Delete
  4. Can anyone help me to solve the below scenario?
    In multi bot architecture, I have a work queue (200 items) with some tagging like “Business” and “Client”. And there are 2 bots. So how can I design the process in this way: BOT-1 will take the work queue item only which is “Client” tag and other bot will get items which tag is “Business” only.

    ReplyDelete
    Replies
    1. You can create s single process with a flag as input.
      So you design a unique robot which uses the flag to chose items according to the tag filter. It's up to you on how many machines you want to deploy and start the robot.

      Delete
  5. Hi Valerio,

    How to design multibot architecture and what are prerequisite for multi bot architecture?

    ReplyDelete
    Replies
    1. Ciao, you just need more than 1 BP Runtime Resource and an Application Server :)

      Delete

Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?