0
0
Hadoopdata~20 mins

Container allocation in Hadoop - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Allocation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Container Allocation in Hadoop YARN

Which statement best describes the role of container allocation in Hadoop YARN?

AContainers are the physical machines where Hadoop daemons run.
BContainers store the data blocks in HDFS for distributed storage.
CContainers are used to manage network traffic between Hadoop nodes.
DContainers are allocated by the ResourceManager to run application tasks with specific resource requirements.
Attempts:
2 left
💡 Hint

Think about how YARN manages resources for running tasks.

Predict Output
intermediate
2:00remaining
Output of Container Allocation Log Snippet

Given the following YARN container allocation log snippet, what is the total memory allocated to containers?

Hadoop
2024-06-01 10:00:00,000 INFO ResourceManager: Allocated container container_01 with 2048 MB
2024-06-01 10:00:01,000 INFO ResourceManager: Allocated container container_02 with 1024 MB
2024-06-01 10:00:02,000 INFO ResourceManager: Allocated container container_03 with 4096 MB
A7168 MB
B7164 MB
C7167 MB
D7169 MB
Attempts:
2 left
💡 Hint

Add the memory sizes of all allocated containers.

data_output
advanced
3:00remaining
Resulting Container Allocation Table

Given the following resource requests and allocations, what is the final container allocation table?

Requests: Task1 needs 2 CPUs and 2048 MB memory, Task2 needs 1 CPU and 1024 MB memory.

Allocations: Task1 got 2 CPUs and 2048 MB, Task2 got 1 CPU and 512 MB.

Hadoop
import pandas as pd

requests = {'Task': ['Task1', 'Task2'], 'CPU_requested': [2, 1], 'Memory_requested_MB': [2048, 1024]}
allocations = {'Task': ['Task1', 'Task2'], 'CPU_allocated': [2, 1], 'Memory_allocated_MB': [2048, 512]}

req_df = pd.DataFrame(requests)
alloc_df = pd.DataFrame(allocations)

result = pd.merge(req_df, alloc_df, on='Task')
result
A[{'Task': 'Task1', 'CPU_requested': 2, 'Memory_requested_MB': 2048, 'CPU_allocated': 1, 'Memory_allocated_MB': 2048}, {'Task': 'Task2', 'CPU_requested': 1, 'Memory_requested_MB': 1024, 'CPU_allocated': 1, 'Memory_allocated_MB': 512}]
B[{'Task': 'Task1', 'CPU_requested': 2, 'Memory_requested_MB': 2048, 'CPU_allocated': 2, 'Memory_allocated_MB': 2048}, {'Task': 'Task2', 'CPU_requested': 1, 'Memory_requested_MB': 1024, 'CPU_allocated': 1, 'Memory_allocated_MB': 512}]
C[{'Task': 'Task1', 'CPU_requested': 2, 'Memory_requested_MB': 2048, 'CPU_allocated': 2, 'Memory_allocated_MB': 1024}, {'Task': 'Task2', 'CPU_requested': 1, 'Memory_requested_MB': 1024, 'CPU_allocated': 1, 'Memory_allocated_MB': 512}]
D[{'Task': 'Task1', 'CPU_requested': 2, 'Memory_requested_MB': 2048, 'CPU_allocated': 2, 'Memory_allocated_MB': 512}, {'Task': 'Task2', 'CPU_requested': 1, 'Memory_requested_MB': 1024, 'CPU_allocated': 1, 'Memory_allocated_MB': 1024}]
Attempts:
2 left
💡 Hint

Look carefully at the allocated CPU and memory for each task.

visualization
advanced
2:00remaining
Interpreting Container Allocation Visualization

You see a bar chart showing container memory allocation for 3 tasks: Task1 (2048 MB), Task2 (1024 MB), Task3 (4096 MB). Which statement is true about the visualization?

ATask3 has the highest memory allocation, twice that of Task1.
BTask2 has the highest memory allocation, more than Task3.
CAll tasks have equal memory allocation.
DTask1 has the lowest memory allocation, less than Task2.
Attempts:
2 left
💡 Hint

Compare the bar heights representing memory sizes.

🔧 Debug
expert
3:00remaining
Identifying Error in Container Allocation Code

What error does the following Hadoop container allocation pseudo-code produce?

containers = []
for i in range(3):
    container = {'id': f'container_{i}', 'memory': 2048 * i}
containers.append(container)
print(containers)
AThe list 'containers' will contain three containers with memory 0, 2048, and 4096 MB.
BTypeError because 'containers' is not defined.
COnly one container will be in the list because append is outside the loop.
DSyntaxError due to missing colon after for loop.
Attempts:
2 left
💡 Hint

Check the indentation of the append statement.