Efficient bots deployment: Take only what you need to survive

Cesar M. González
6 min readMay 3, 2023

--

In RPA, once the bots are built, they are deployed in a virtual environment and executed based on the business rules. Usually, a Virtual Machine (VM) is set up for this purpose, but it is equally usual that the bot does not use the total resources in the VM.

Depending on the VM specifications and bot execution dependencies (applications, services, etc.). You could discover the bot uses a low percentage of the resources available, CPU, Memory, and Disk.

Does it make sense the bot uses only 5% of the CPU, 10% of the memory, and 2% of the disk in runtime?

It can be identified that there isn’t efficient resource consumption. But why is it a good idea to improve resource consumption?

These are some reasons why it is a good idea to fix it:

  • Reduces the effort, time, and cost needed to execute and maintain the bots (environment setup).
  • Simplifies the environment where the bot is deployed; the bots should only have access to what it uses, not more, not less.
  • Gains speed, flexibility, and robustness to scale the automation based on the requirements/needs.
  • Reduces bots deployment dependency and complexity with the environments. Provides high availability and high scalability.
  • From a security perspective, it reduces bot/environment exposure, the security risk is reduced, reducing bot/environment dependencies, but it doesn’t go away; it just changes.

This raises the question: What does the bot need to “survive”?

The goal is to use the resources needed to execute our bot efficiently. Two programming tools: Python and UiPath (low code), are used to explain how to do it a what tools to use.

The strategy: Divide and Counter

Divide the resources at your disposal, and fit them to the bot’s needs.

Divide the available resources.

The following technologies allow for improving the distribution of resources. Let’s explore them:

  • Serverless.
  • Docker.
  • Manage Processes.

The Bot: I Have Been Pwned Reviewer

Before exploring each one of these tools, let’s introduce the “I Have Been Pwned Reviewer” bot. The bot uses the https://haveibeenpwned.com/ website, reviews which emails have suffered exposure of information from applications where it has been subscribed and generates a report.

Yes. Maybe you want to review your email accounts.

This bot was built using both programming tools. Python and UiPath. The goal is to show that resource distribution tools can be used for different programming tools. The project source codes are in the following repositories:

Note: Both automations use Chrome Automation. The resource distribution tools mentioned above are limited to background processes and don’t allow direct interaction with the User Interface (UI).

Resource Distribution Tools

I’m not a big fan of “reinventing the wheel” (sometimes). Therefore the Resource Distribution Tool explanations are supported by documentation and tutorials. The goal of this post is to highlight their use and advantages.

1. Serverless

Serverless computing is a way to deploy bots based on demand that doesn’t requires server configuration or maintenance from the developer.

Serverless provides multiple advantages for our bot deployment, especially when it needs dynamic scalability. The resources are available based on demand, and the providers manage the resources’ consumption (AWS in this case).

To deploy a Python automation on serverless:

  1. Build the lambda Python automation. Generate a zip file of the project.
  2. For this example, add the layers in the Serverless provider, selenium and chromium. They are dependencies.
  3. Upload the zip file project.
  4. Set up the lambda function defining the programming language, resources allocation, and the layers used by the bot (dependencies).
  5. Test your automation.

In the How To Deploy Python Selenium Script in AWS Lambda in 2022 tutorial by Michael Kitas, you can learn how to deploy Python automation on Serverless.

For UiPath, read the following documentation to deploy bots on Serverless Automation Cloud™ Robots — Serverless

2. Docker

Docker is useful for deploying bots in the cloud and on-premise servers. Docker, like serverless, allows the distribution of resources to set up the dockers (environments) features and define the resources available. Review the following documentation to get more information. Docker images allow customization of environments, creating a base image.

The following images show seven containers running on a server executing the “I Have been Pwned” bot and the resource usage monitoring. The resource consumption is managed efficiently, based on bot demand, and allows for easy management and scalability.

To deploy a Python automation on docker:

  1. Build the Python automation script.
  2. Build the Docker Image. For the demo automation, make sure Chrome Driver is installed.
  3. Prepare the Docker for a run. Set up the RUN Docker instruction to execute the Python script.
  4. Deploy the Dockers based on the Docker Image built.
  5. Test your automation.

The following tutorial HubScraper, explains how to deploy automation using Selenium on Docker. The Docker file used to build the image is in the “I Have been Pwned” bot repository.

UiPath is compatible with Docker too. The UiPath Linux Robot tutorials by RPA Vanguard clearly explain how to deploy bots using Dockers.

3. Manage Processes

There are multiple tools to implement the Manage Processes. PM2 is one of them. It works over the concept of mutiproccesses. All the processes run in the same environment (there isn’t isolation between environments)

As you can see, multiple processes are executed simultaneously, distributing the resources available on the server.

To deploy a Python automation on PM2:

  1. Build the Python automation script.
  2. Execute the script on cluster mode. Using the config file or the command line.
  3. Monitor the process execution.
  4. Test your automation.

Remember, all the processes run over the same environment but in different instances, so be careful if there is any common dependency.

To execute the Python bot, check the following PM2 documentation: Manage Python Processes.

Note: UiPath doesn’t allow Deamon Process, But it has other useful alternatives, like Parallel, or High-Density Robots, to get the best advantage of the available resources.

Conclusion

From multiple viewpoints is a good inversion: it reduces the environment’s cost, reduces bot/environment dependencies, allows easy resource management, reduces bot exposition (isolation), and is the starting point to build bots focused on system integrations instead of human actions simulation.

--

--

No responses yet