Run Multiple Kameleo Instances on One Machine

  • Created

Running multiple Kameleo instances on the same machine can be useful when you need to:

  • Separate automation workflows.
  • Use different configurations for different purposes.
  • Enhance your workflow and stability!

Steps to Configure Multiple Instances

1. Copy Kameleo Application Folder

  • Make a copy of your existing Kameleo Application folder for each instance you want to run

2. Modify Port Settings

  • Open appsettings.json in the copied folder
  • Change the Local API port (default is 5050) to a different value (e.g., 5051)
  • Repeat for each additional instance with unique ports

3. Start Separate Instances

  • Launch Kameleo.CLI.exe from each folder
  • Log in with your credentials

Here's how to connect to different Kameleo instances:

  • // First instance using environment variable with default port 5050
    const kameleoPort1 = process.env.KAMELEO_PORT || '5050';
    const client1 = new KameleoLocalApiClient({
        baseUri: `http://localhost:${kameleoPort1}`,
        retryTotal: 0
    });
    
    // Second instance using environment variable with different port
    const kameleoPort2 = process.env.KAMELEO_PORT2 || '5051';
    const client2 = new KameleoLocalApiClient({
        baseUri: `http://localhost:${kameleoPort2}`,
        retryTotal: 0
    });
  • import os
    from kameleo.local_api_client import KameleoLocalApiClient
    
    # First instance using environment variable with default port 5050
    kameleo_port1 = os.getenv('KAMELEO_PORT', '5050')
    client1 = KameleoLocalApiClient(
        endpoint=f'http://localhost:{kameleo_port1}',
        retry_total=0
    )
    
    # Second instance using environment variable with different port
    kameleo_port2 = os.getenv('KAMELEO_PORT2', '5051')
    client2 = KameleoLocalApiClient(
        endpoint=f'http://localhost:{kameleo_port2}',
        retry_total=0
    )

Best Practices

  • Use environment variables to manage ports for different environments
  • Keep track of which instance is running on which port
  • Monitor resource usage when running multiple instances

Note: Make sure that the total number of Parallel Automated Browsers (PAB) is not exceeded

Limitations

  • System resources are shared between instances
  • Make sure your machine has enough RAM and CPU capacity to handle multiple instances
  • Running too many profiles (PABs) in a single instance may cause instability. It's recommended to distribute your profiles across fewer instances for improved performance and reliability.

This setup allows you to effectively utilize your API use. We also recommend that you review our article on Parallel Automated Browsers (PAB) for more information on how to proceed with this approach.

Was this article helpful?

0 out of 0 found this helpful