Katkat

Design an SSH-Based Cloud Development Environment

OpenAISoftware Engineer · Onsite

Last updated

This question tests your ability to design a distributed system that manages stateful, long-running compute resources while ensuring isolation, high availability, and secure remote access.

Problem Statement

Design a cloud-based development environment service where users can connect via SSH to persistent, containerized workspaces. These workspaces need to support scheduled background tasks (builds, tests, and runners) and maintain state across sessions.

Functional Requirements

  • Users can spin up and tear down development workspaces.
  • Users must be able to securely SSH into their specific container or virtual machine.
  • Support for cron-like scheduling of background tasks (e.g., automated builds or linting) that run within the workspace context.
  • workspaces must persist filesystem state when stopped or after network reconnection.

Non-Functional Requirements

  • Reliability: The system must handle host failure gracefully; a workspace should be restartable on a different node without data loss.
  • Isolation: Users should not be able to access the host OS or other users' workspaces.
  • Performance: Minimize SSH latency during initial connection and reconnection.
  • Fairness: Implement resource quotas (CPU, Memory, Disk) to prevent single-user resource exhaustion.

Deliverables

  1. High-level architecture diagram and component interaction flow.
  2. API definition for managing workspaces and scheduling tasks.
  3. Data model for tracking workspace state, user ownership, and task logs.
  4. Detailed strategy for secure SSH tunnel establishment and authentication.
  5. Handling of fleet failures: How do we detect a host crash and recover the workspace state?

Hints

Hint 1

Consider using an SSH proxy (like a bastion or jump host) to handle authentication and routing to the specific container hosting the workspace.

Hint 2

Decouple the storage layer from the compute layer using network-attached block storage or distributed file systems to ensure durability during host reboots.

Hint 3

Think about the orchestration layer (e.g., Kubernetes) for handling container lifecycle management and resource constraints.

Follow-up questions

  • How would you implement 'sleep' or 'hibernate' modes for workspaces to optimize cost when no active SSH session is detected?
  • If a user is working in a high-security environment, how would you enforce ephemeral credentials that expire automatically after the session ends?
  • How do you handle real-time log streaming for scheduled background tasks back to the user's dashboard?