College: NIT, Rourkela
Experience :6 months Internship+1 year 2 Months Full time Experience
Current Company: UKG
Role Applied SDE-1
Round R1->
Projects + current word discussion+DSA
- Given a grid of size w x h, place n office buildings such that the maximum distance from any lot to the nearest office is minimized. Movement is 4-directional (no diagonals).
Solution Approach
Since w × h ≤ 28 and n ≤ 5, brute force with optimizations is feasible:
- Generate All Possible Placements
Each cell is a possible office building.
Generate all possible ways to choose n out of w × h cells to place offices. - For Each Placement, Compute Distance Grid
For each empty cell, calculate its shortest distance to the nearest office.
This is a multi-source BFS (Breadth First Search) from all office locations. - Track the Minimum Maximum Distance
For each placement, record the largest minimum distance.
The answer is the minimum among these maxima.
Round R2;
System Design
Let’s imagine Microsoft Teams wants to offer customers a platform to train their own machine learning models using our managed GPU clusters. Customers upload code and data (as a directory), specify the number of GPUs and expected training time, and our platform schedules, provisions, and runs the job. The platform should:
Efficiently allocate GPUs to maximize utilization.
Handle priorities and fairness (e.g., waiting time, job size).
Support concurrent training jobs and track job status/logs.
Persist code and data in cloud storage, then make it available to the training job.
Support logging for billing and monitoring.
How would you design this system
1. Job Submission
Customers upload code + dataset (directory), select GPU count & max hours (“timeoff”).
On submission:
Backend receives the package.
Files are uploaded and stored in a secure GCP/Azure bucket.
Storage service returns the URLs (code & data) for the bucketed files.
Request DTO:
{
"codeUrl": "...",
"dataUrl": "...",
"numGpus": 4,
"maxHours": 10,
"priority": 1,
"submittedAt": 1693432953
}
DTO is published into a priority queue, sorted by (priority, timestamp).
2. Job Queue & Scheduler
PriorityQueue (Min-Heap):
Sorts jobs first by priority (lower = higher priority), then by earliest submission timestamp.
Scheduler polls the queue:
For each pending job, checks the GPU Service for available GPUs.
3. GPU Service
Maintains metadata: gpu_id, status (available, allocated, in-use), etc.
Exposes APIs to check availability and allocate/free GPUs.
Handles concurrent allocation requests.
4.** Fair Allocation Strategy**
If job at the head of the queue requires more GPUs than currently available:
Scheduler checks for jobs further down the queue that require fewer GPUs (greedy packing).
If any job fits, allocate GPUs and start that job, but also:
Starvation Prevention: Track waiting time for each job; if a job has waited “too long,” begin reserving GPUs for it, even if not all are free yet.
Ensures fairness and high GPU utilization.
5. Job Start & Kafka Event
Once GPUs are allocated:
Scheduler publishes a Kafka event (job started) with customer/job/gpu details.
Training Service listens for this event, pulls the code/data from storage, and launches the job (in a container, possibly via Kubernetes).
Starts GPU-based training.
6. Training Logs & Monitoring
Training process streams logs to a logging service.
Logs are ingested into a ClickHouse/OpenHouse cluster (high-volume, columnar analytics DB).
Customers can access their live logs/status via API/UI.
Each log entry contains: timestamp, job_id, gpu_id, message, etc.
7.** Billing**
Billing service monitors: GPUs allocated, total hours used.
Can bill per-GPU, per-hour, with possible surcharges for overtime.
8. Key Design Patterns & Considerations
Cloud Storage: Reliable, scalable storage for user code/data.
Priority Queue: For job fairness and utilization.
GPU Service: Decoupled resource manager.
Kafka: Event-driven; decouples job allocation, training, and logging.
ClickHouse: Analytics-grade DB for real-time logs and billing.
Starvation Prevention: Long-waiting large jobs eventually get reserved GPUs
Diagram Overview
Customer ──> API (uploads code/data) ──> Cloud Bucket (get URLs)
│
└─> Job Submission (with bucket URLs, job meta)
│
Priority Queue (heap)
│
Scheduler polls + checks GPU Service
│
If GPUs available: allocate + send Kafka event
│
Training Service (runs job, streams logs)
│
Log Ingestion (OpenHouse/ClickHouse)
│
Customer views logs/status


