Bird
Raised Fist0
Agentic AIml~20 mins

Scaling agents horizontally in Agentic AI - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Horizontal Scaling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding horizontal scaling of agents

Imagine you have a team of helpers (agents) working on a task. What does it mean to scale these agents horizontally?

ACombining multiple agents into one bigger agent.
BMaking each agent work faster by improving its code.
CAdding more agents to work in parallel on the task.
DReducing the number of agents to save resources.
Attempts:
2 left
💡 Hint

Think about how adding more helpers affects the workload distribution.

Model Choice
intermediate
2:00remaining
Choosing the right approach for horizontal scaling

You want to scale your AI agents horizontally to handle more user requests simultaneously. Which approach best supports this goal?

ADeploy multiple independent agent instances behind a load balancer.
BOptimize a single agent to use GPU acceleration.
CReduce the agent's response time by simplifying its logic.
DIncrease the memory of the machine running the agent.
Attempts:
2 left
💡 Hint

Think about how to handle many requests at once by using more agents.

Predict Output
advanced
2:00remaining
Output of agent scaling simulation code

What is the output of the following Python code simulating agent task completion times when scaling horizontally?

Agentic AI
import random

def simulate_agents(num_agents, tasks_per_agent):
    times = []
    for _ in range(num_agents):
        agent_time = sum(random.uniform(0.8, 1.2) for _ in range(tasks_per_agent))
        times.append(agent_time)
    return max(times)

random.seed(0)
result = simulate_agents(3, 5)
print(round(result, 2))
A6.00
B5.00
C4.75
D5.51
Attempts:
2 left
💡 Hint

Run the code to see the maximum total time among 3 agents each doing 5 tasks with random times.

Metrics
advanced
2:00remaining
Evaluating horizontal scaling efficiency

You measure the throughput (tasks per second) of your agent system as you add more agents horizontally. Which metric best shows how efficiently the system scales?

AAccuracy of each agent's predictions
BSpeedup = Throughput with N agents / Throughput with 1 agent
CLatency of a single task processed by one agent
DMemory usage per agent
Attempts:
2 left
💡 Hint

Think about how adding agents affects total work done compared to one agent.

🔧 Debug
expert
2:00remaining
Debugging horizontal scaling bottleneck

You horizontally scaled your agents by adding more instances, but the system's throughput did not improve as expected. Which issue below most likely causes this bottleneck?

AA shared resource like a database is limiting concurrent access.
BEach agent instance has too much CPU power.
CAgents are running on separate machines with network isolation.
DThe number of agents is too high, causing perfect scaling.
Attempts:
2 left
💡 Hint

Consider what shared parts might slow down many agents working together.

Practice

(1/5)
1. What does scaling agents horizontally mean in agentic AI?
easy
A. Adding more agents to share and run tasks in parallel
B. Making one agent work faster by improving its code
C. Reducing the number of agents to save resources
D. Changing the task to fit a single agent's ability

Solution

  1. Step 1: Understand the term 'scaling horizontally'

    Scaling horizontally means increasing the number of units (agents) to handle more work simultaneously.
  2. Step 2: Apply to agentic AI context

    In agentic AI, this means adding more agents to share tasks and run them in parallel, speeding up processing.
  3. Final Answer:

    Adding more agents to share and run tasks in parallel -> Option A
  4. Quick Check:

    Scaling horizontally = Adding more agents [OK]
Hint: More agents working together means horizontal scaling [OK]
Common Mistakes:
  • Confusing horizontal scaling with making one agent faster
  • Thinking scaling means reducing agents
  • Assuming scaling changes the task itself
2. Which of the following is the correct way to start multiple agents in parallel in Python?
easy
A. for agent in agents: agent.start()
B. for agent in agents: agent.run()
C. for agent in agents: agent.execute()
D. for agent in agents: agent.parallel()

Solution

  1. Step 1: Identify the method to start agents in parallel

    In many agent frameworks, start() is used to begin an agent's process or thread asynchronously.
  2. Step 2: Compare options

    run() usually runs synchronously blocking the loop, execute() and parallel() are not standard methods.
  3. Final Answer:

    for agent in agents: agent.start() -> Option A
  4. Quick Check:

    Use start() to launch agents in parallel [OK]
Hint: Use start() to run agents asynchronously [OK]
Common Mistakes:
  • Using run() which blocks instead of start()
  • Assuming execute() or parallel() are valid methods
  • Not looping over all agents
3. Given this code snippet for scaling agents horizontally, what will be the output?
class Agent:
    def __init__(self, id):
        self.id = id
    def run(self):
        print(f"Agent {self.id} running")

agents = [Agent(i) for i in range(3)]
for agent in agents:
    agent.run()
medium
A. Agent 3 running
B. Agent running\nAgent running\nAgent running
C. No output, code has error
D. Agent 0 running\nAgent 1 running\nAgent 2 running

Solution

  1. Step 1: Understand the Agent class and its run method

    The run method prints the agent's id with the message "Agent {id} running".
  2. Step 2: Analyze the loop over agents

    There are 3 agents with ids 0, 1, 2. The loop calls run() on each, printing their messages in order.
  3. Final Answer:

    Agent 0 running Agent 1 running Agent 2 running -> Option D
  4. Quick Check:

    Each agent prints its id running [OK]
Hint: Each agent prints its id in order [OK]
Common Mistakes:
  • Thinking all agents print the same message without id
  • Assuming only one agent runs
  • Believing code has syntax error
4. This code tries to scale agents horizontally but does not run agents in parallel. What is the error?
class Agent:
    def run(self):
        print("Running")

agents = [Agent() for _ in range(3)]
for agent in agents:
    agent.run()
medium
A. The list comprehension syntax is wrong
B. Agent class is missing an __init__ method
C. Agents are run sequentially, not in parallel
D. The run method should be named start

Solution

  1. Step 1: Check how agents are executed

    The for loop calls run() on each agent one after another, so execution is sequential.
  2. Step 2: Understand parallel execution requirement

    To scale horizontally, agents must run in parallel, e.g., using threads or async calls, not sequential calls.
  3. Final Answer:

    Agents are run sequentially, not in parallel -> Option C
  4. Quick Check:

    Sequential run ≠ horizontal scaling [OK]
Hint: Sequential calls don't scale horizontally [OK]
Common Mistakes:
  • Thinking missing __init__ causes no parallelism
  • Believing list comprehension is incorrect
  • Assuming run must be renamed to start
5. You want to scale 5 agents horizontally to process independent tasks faster. Which approach best achieves this in Python?
hard
A. Run all agents sequentially in a single loop
B. Run each agent's task in a separate thread using threading.Thread
C. Use a single agent to process all tasks one by one
D. Run agents in a loop but wait for each to finish before starting next

Solution

  1. Step 1: Understand the goal of horizontal scaling

    We want to run multiple agents at the same time to speed up processing independent tasks.
  2. Step 2: Evaluate options for parallel execution

    Using threading.Thread runs agents concurrently, achieving horizontal scaling. Sequential loops or waiting block parallelism.
  3. Final Answer:

    Run each agent's task in a separate thread using threading.Thread -> Option B
  4. Quick Check:

    Threads enable parallel agent execution [OK]
Hint: Use threads to run agents in parallel [OK]
Common Mistakes:
  • Running agents sequentially thinking it's parallel
  • Using one agent for all tasks ignoring scaling
  • Starting agents but waiting for each to finish before next