-
Notifications
You must be signed in to change notification settings - Fork 110
Description
Currently, each environment instance requires its own Docker container. This creates significant resource overhead for parallel workloads:
- Running
Nparallel episodes requiresNseparate Docker containers - Each container must be managed individually
LocalDockerProvidercreates one container per client instance
For RL training with dozens or hundreds of parallel rollouts, this becomes resource-intensive and impractical.
Current Architecture
Server side: Environment classes maintain state in instance variables (self._state, self._executor). One container = one environment instance = one episode session.
Client side: HTTPEnvClient.from_docker_image() starts a dedicated container via LocalDockerProvider.
Example:
# Each creates a separate container
env1 = CodingEnv.from_docker_image("coding-env:latest") # Container 1
env2 = CodingEnv.from_docker_image("coding-env:latest") # Container 2
env3 = CodingEnv.from_docker_image("coding-env:latest") # Container 3Use Case
I was trying to create concurrent environments for the poke-env wrapper. The underlying poke-env library supports concurrency natively, but the only way to support it via the OpenEnv wrapper is by running and managing multiple containers via Docker Swarm, Docker Compose, or similar container orchestration tools. This adds significant complexity compared to the native library.
Impact
- Resource usage: Each container has overhead (memory, CPU, startup time)
- Complexity: Managing dozens of containers requires orchestration tooling
- Developer experience: Creating parallel environments is cumbersome compared to native libraries
Possible Solutions
- Multi-session per container: One server handles multiple isolated sessions via session IDs in the HTTP API
- Vectorized environments: Single container runs N environments with batch API like
VectorEnv - Something else: Open to ideas