Skip to main content

Sauce Connect Proxy Tunnel Pool Setup

Tunnel Pool enables you to run parallel tests through multiple Sauce Connect Proxy tunnels, improving test reliability and scalability. It is ideal for high-concurrency environments, allowing for automatic load balancing and increased fault tolerance.

Benefits of Tunnel Pools

  • Load balancing: Jobs are evenly distributed across available tunnels.
  • Failover: If a tunnel fails, new tests will be rerouted through another active tunnel.
  • Rolling restarts: You can restart individual tunnels without interrupting ongoing tests.

Limitations

  • If a Sauce Connect client on your side or a tunnel VM on Sauce Labs' side goes down during a test, the test may fail.
  • Tunnel pools are not self-healing or automatically restarted. If a tunnel stops, you'll need to restart it manually. This can be automated using a service manager like systemd.

Prerequisites

Before setting up a tunnel pool, ensure your environment is compatible with Sauce Connect Proxy by following the Quickstart guide.

Consider your needs:

Concurrency

Each tunnel in a pool counts toward your tunnel concurrency limit.

Architecture

The following diagram illustrates the basic architecture of a Sauce Connect Proxy setup using a tunnel pool:

Basic setup using tunnel pool

Flow:

  • A test framework requests a new Sauce Test VM, referencing a tunnel name.
  • Sauce Labs selects an available tunnel from the pool.
  • The chosen tunnel is used for proxying traffic between Sauce Test VM and your site under test.

Setup Instructions

Launching Tunnels for a Tunnel Pool

You must start multiple tunnels with the same [tunnel-name] and the --tunnel-pool flag. Each tunnel should be started from a separate VM for maximum fault tolerance.

sc run --username $SAUCE_USERNAME --access-key $SAUCE_ACCESS_KEY \
--tunnel-name tunnel_name_here \
--tunnel-pool

Avoiding Colliding Tunnels

Without --tunnel-pool, launching multiple tunnels with the same --tunnel-name will cause older instances to shut down. Always use the --tunnel-pool flag to allow multiple tunnels with the same name to coexist as a pool.

Running Tests using Tunnel Pool

In your test script, specify the tunnel pool name using the tunnelName capability:

"tunnelName": "tunnel_pool_name_here"

Tips for Production Use

Load Balancing and Failover

Tunnel pools use a round-robin algorithm to distribute test traffic evenly. If a tunnel fails, traffic is routed to another in the pool. For optimal resilience run Sauce Connect Proxy on separate machines.

Monitoring and Maintenance

Summary

Tunnel pools increase test capacity, reliability, and performance by enabling multiple tunnels to operate under the same name. With proper configuration and monitoring, tunnel pools provide a powerful solution for high-concurrency test environments.