Why webhooks push notifications in Rest API - Performance Analysis
When webhooks push notifications, they send data automatically to another system. We want to understand how the time it takes grows as more notifications are sent.
How does the work increase when the number of notifications grows?
Analyze the time complexity of the following webhook notification process.
POST /webhook/notify
for each subscriber in subscribers_list:
send HTTP POST notification
wait for response
return success
This code sends a notification to each subscriber one by one and waits for their response.
Look for repeated actions that take time.
- Primary operation: Sending HTTP POST notification to each subscriber.
- How many times: Once for every subscriber in the list.
As the number of subscribers grows, the number of notifications sent grows the same way.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 notifications sent |
| 100 | 100 notifications sent |
| 1000 | 1000 notifications sent |
Pattern observation: The work grows directly with the number of subscribers.
Time Complexity: O(n)
This means the time to send notifications grows in a straight line with the number of subscribers.
[X] Wrong: "Sending notifications happens instantly no matter how many subscribers there are."
[OK] Correct: Each notification takes time, so more subscribers mean more total time.
Understanding how notification sending scales helps you explain real-world API behavior clearly and confidently.
"What if notifications were sent in parallel instead of one by one? How would the time complexity change?"