0
0
HLDsystem_design~10 mins

Load balancing algorithms (round robin, least connections) in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select the next server using round robin.

HLD
next_server = servers[[1] % len(servers)]
Drag options to blanks, or click blank then click option'
Acurrent_index
Bserver_count
Crandom_index
Dmax_connections
Attempts:
3 left
💡 Hint
Common Mistakes
Using random index instead of cycling
Using max connections for round robin
2fill in blank
medium

Complete the code to find the server with the least connections.

HLD
least_loaded_server = min(servers, key=lambda s: s.[1])
Drag options to blanks, or click blank then click option'
Aload
Bcapacity
Cconnections
Dlatency
Attempts:
3 left
💡 Hint
Common Mistakes
Using load or capacity instead of connections
Using latency which is unrelated
3fill in blank
hard

Fix the error in the round robin index update.

HLD
current_index = (current_index [1] 1) % len(servers)
Drag options to blanks, or click blank then click option'
A/
B-
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction which moves backward
Using multiplication or division which is incorrect
4fill in blank
hard

Fill both blanks to create a dictionary of servers with their connection counts, filtering servers with less than 10 connections.

HLD
{server.id: server.[1] for server in servers if server.[2] < 10}
Drag options to blanks, or click blank then click option'
Aconnections
Bload
Dcapacity
Attempts:
3 left
💡 Hint
Common Mistakes
Using different attributes for mapping and filtering
Using load or capacity instead of connections
5fill in blank
hard

Fill all three blanks to implement a function that selects a server using least connections algorithm.

HLD
def select_server(servers):
    return min(servers, key=lambda [1]: [2].[3])
Drag options to blanks, or click blank then click option'
Aserver
Bs
Dconnections
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names
Accessing wrong attributes