Skip to content

feat: Add SSH connection pooling for 11x performance improvement#2

Merged
adolago merged 2 commits into
mainfrom
feat/connection-pooling
Dec 22, 2025
Merged

feat: Add SSH connection pooling for 11x performance improvement#2
adolago merged 2 commits into
mainfrom
feat/connection-pooling

Conversation

@adolago

@adolago adolago commented Dec 22, 2025

Copy link
Copy Markdown
Owner

Summary

  • Implement connection pooling in the CLI to reuse SSH connections across multiple task executions
  • Eliminates SSH handshake/authentication overhead for subsequent commands
  • Adds connections pool to CommandContext with get_connection() and close_connections() methods

Benchmark Results

Metric Rustible Ansible Speedup
10 tasks × 5 hosts 0.56s 6.20s 11.1x
Per-command latency 11.2ms 123.9ms 11.1x

How It Works

Task 1 (first command per host):
  DEBUG: Creating new SSH connection: user@host:22

Task 2-N (subsequent commands):
  DEBUG: Reusing connection for host

Test plan

  • Verified connection reuse via debug output ("Reusing connection for...")
  • Ran benchmark playbook (10 tasks × 5 hosts)
  • Confirmed connections are properly closed at playbook end

🤖 Generated with Claude Code

adolago and others added 2 commits December 22, 2025 16:59
Add comprehensive test suite for real-world integration testing using
Proxmox VE to spin up LXC containers and VMs:

- tests/infrastructure/: Provisioning scripts and configs
  - provision.sh: Deploy/destroy VM cluster on Proxmox
  - run-tests.sh: Test orchestration framework
  - test_inventory.yml: Ansible-compatible test inventory
  - ssh_config: SSH config for test hosts

- tests/real_ssh_tests.rs: Real SSH connection tests
  - Key and password authentication
  - SFTP file transfers
  - Connection pooling validation
  - Privilege escalation (sudo)

- tests/parallel_stress_tests.rs: Multi-host stress tests
  - Linear/Free/HostPinned strategy validation
  - Fork limiting under load
  - Serial batching
  - Handler deduplication

- tests/real_docker_tests.rs: Docker connection tests
  - docker exec operations
  - docker cp file transfers
  - Container lifecycle handling

- tests/chaos_tests.rs: Chaos engineering tests
  - Random failure injection
  - Network latency simulation
  - Recovery after failures
  - Block/rescue/always reliability

Test cluster uses 16 LXC containers + 1 VM (~38GB RAM, ~50 vCPUs).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement connection pooling in the CLI to reuse SSH connections across
multiple task executions, eliminating the SSH handshake/authentication
overhead for subsequent commands.

Changes:
- Add connection pool (HashMap) to CommandContext
- Add get_connection() method that caches and reuses SSH connections
- Add close_connections() method for cleanup at playbook end
- Refactor execute_remote_command() to use pooled connections

Benchmark results (10 tasks x 5 hosts = 50 commands):
- Rustible: 0.56s (11.2ms per command)
- Ansible: 6.20s (123.9ms per command)
- Speedup: 11.1x

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant