1. [OA] Service Health Monitor — Build a system for monitoring service health at Salesforce scale
Monitoring the health of Salesforce services is crucial for delivering uninterrupted service to millions of users worldwide. The system must detect and categorize issues swiftly. Problem statement: Design a class HealthMonitor that tracks service health statuses along with methods to update and retrieve the health of services. It should handle service down notifications and provide methods to view service health history. - Method: update_service(service_name: str, status: str) -> None — Updates the status of the specified service. - Method: get_health(service_name: str) -> str — Retrieves the current health status of a service. - Method: history(service_name: str) -> List[Tuple[str, str]] — Returns a history of all status updates for the specified service. Example 1: Input: update_service('AuthService', 'down') Output: Service AuthService marked as down Explanation: Updates the status of AuthService to down and logs the update in history. Constraints: - The monitor will handle up to 10000 services. - Each service can have a history of up to 100 status updates.
system designSeniordistributed systems#2
2. [OA] Distributed Config Manager — Design a centralized configuration manager for Salesforce
As Salesforce operates at a vast scale, a centralized configuration management system is essential to ensure consistent behavior across services. This system should provide both retrieval and dynamic update capabilities. Problem statement: Design a class ConfigManager that allows services to retrieve configuration values and listen for changes. The class should be thread-safe and handle concurrent read/write access efficiently. - Method: get(key: str) -> str — Retrieves the value associated with a key. - Method: set(key: str, value: str) -> None — Sets the value for a key and notifies listeners. - Method: subscribe(listener: Callable[[str, str], None]) -> None — Registers a listener to be notified of changes. Example 1: Input: set('featureA', 'enabled') Output: Listener notified: featureA changed to enabled Explanation: Signals all registered listeners about the updated value. Constraints: - The manager must handle 1000 concurrent clients. - Each update must be atomic.
As Salesforce continues to scale, optimizing Docker images not only reduces deployment time but also conserves resources. A refined Docker image can significantly impact CI/CD processes. Problem statement: Write a Python function to optimize a given Dockerfile by removing unused layers, minimizing the final image size, and ensuring best practices are followed. The function should also highlight areas for further improvements. - Method: optimize_dockerfile(dockerfile: str) -> str — Takes a Dockerfile as a string, optimizes it and returns the optimized Dockerfile as a string. Example 1: Input: FROM python:3.8 RUN pip install --no-cache-dir -r requirements.txt Output: FROM python:3.8 COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt Explanation: Merges RUN commands to minimize layers. Constraints: - Dockerfile will contain a maximum of 150 lines. - Follow best practices for reducing image size.
codingHardinfra#4
4. [OA] Terraform State Management — Manage shared Terraform state for Salesforce environments
In Salesforce, managing infrastructure as code is crucial for deployment consistency. You must ensure that Terraform state files are managed effectively to avoid conflicts. Problem statement: Create a Python script to manage Terraform state files across multiple Salesforce environments. The script must handle functionality to init, apply, and destroy the state, while ensuring no conflicting changes occur. - Method: init() -> None — Initializes Terraform working directory. - Method: apply() -> str — Applies the Terraform configuration and returns the output state. - Method: destroy() -> str — Destroys the configured infrastructure and returns confirmation message. Example 1: Input: apply() Output: Terraform applied successfully Explanation: Applies the Terraform configuration and returns success message. Constraints: - The script must handle at least 10,000 resources. - Each environment is treated as a separate directory. - Handle conflicts on concurrent executions gracefully.