Challenge - 5 Problems
Load Testing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this simple load test script?
Consider this Python script using the requests library to simulate 3 sequential API calls. What will be printed?
Rest API
import requests urls = ['https://api.example.com/data1', 'https://api.example.com/data2', 'https://api.example.com/data3'] for url in urls: response = requests.get(url) print(response.status_code)
Attempts:
2 left
💡 Hint
Assume all URLs are valid and the server is up.
✗ Incorrect
The script sends GET requests to three valid endpoints. Since the server is up and URLs are correct, each request returns HTTP status 200.
🧠 Conceptual
intermediate1:30remaining
Which factor is most important when designing a load test?
When creating a load test for a REST API, which factor should you prioritize to simulate real user behavior?
Attempts:
2 left
💡 Hint
Think about what affects server load the most.
✗ Incorrect
The number of concurrent users and how fast requests are sent directly impact server load and performance under stress.
🔧 Debug
advanced2:30remaining
Why does this load test script fail with a connection error?
This Python script uses threading to send 100 requests concurrently but raises a ConnectionError. What is the likely cause?
Rest API
import threading import requests def send_request(): requests.get('https://api.example.com/data') threads = [] for _ in range(100): t = threading.Thread(target=send_request) threads.append(t) t.start() for t in threads: t.join()
Attempts:
2 left
💡 Hint
Consider server-side limits on connections.
✗ Incorrect
Many servers limit concurrent connections from a single client. Sending 100 requests at once may exceed this limit, causing connection errors.
📝 Syntax
advanced1:30remaining
Identify the syntax error in this load test script snippet
What is wrong with this Python code snippet for sending multiple requests?
Rest API
import requests responses = [requests.get('https://api.example.com/data') for i in range(5)] print(responses.status_code)
Attempts:
2 left
💡 Hint
Think about the type of 'responses' and how to access elements.
✗ Incorrect
'responses' is a list of response objects. You cannot call 'status_code' on the list itself; you must access an individual response first.
🚀 Application
expert3:00remaining
How many requests per second does this load test generate?
This script uses asyncio to send 50 requests with a 0.1 second delay between each start. How many requests per second does it generate approximately?
Rest API
import asyncio import aiohttp async def fetch(session, url): async with session.get(url) as response: return await response.text() async def main(): async with aiohttp.ClientSession() as session: tasks = [] for _ in range(50): tasks.append(fetch(session, 'https://api.example.com/data')) await asyncio.sleep(0.1) await asyncio.gather(*tasks) asyncio.run(main())
Attempts:
2 left
💡 Hint
Calculate how many requests start each second based on the delay.
✗ Incorrect
Each request starts after 0.1 seconds, so 1/0.1 = 10 requests start per second approximately.