Server Fleet Uptime
Beginner Mode
Objective
Amazon Web Services (AWS) is powered by fleets of servers. Senior management has requested data-driven solutions to optimize server usage. You are given a table that logs each server's start and stop events.
Table Schema:
The server_utilization table:
| Column | Type | Description |
|---|---|---|
| server_id | integer | ID of the server |
| status_time | timestamp | Timestamp of the event |
| session_status | text | Either 'start' or 'stop' |
Task Requirements:
- Calculate the total time that the fleet of servers was running
- Each server might start and stop several times
- The total fleet running time is the sum of each server's uptime across all sessions
- Output the result in units of full days (truncate any partial day)
Output columns: total_uptime_days
Examples
Example 1:
Output:
Input:
| server_utilization | ||
|---|---|---|
| server_id | session_status | status_time |
| 1 | start | 2025-01-01 08:00:00 |
| 1 | stop | 2025-01-03 16:00:00 |
| 2 | start | 2025-01-02 10:00:00 |
| 2 | stop | 2025-01-04 10:00:00 |
| total_uptime_days |
|---|
| 4 |
Code Environment
Sign in or try as guest to run your code.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
Amazon