0
0
Rest APIprogramming~5 mins

Why webhooks push notifications in Rest API - Performance Analysis

Choose your learning style9 modes available
Time Complexity: Why webhooks push notifications
O(n)
Understanding Time Complexity

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?

Scenario Under Consideration

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.

Identify Repeating Operations

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.
How Execution Grows With Input

As the number of subscribers grows, the number of notifications sent grows the same way.

Input Size (n)Approx. Operations
1010 notifications sent
100100 notifications sent
10001000 notifications sent

Pattern observation: The work grows directly with the number of subscribers.

Final Time Complexity

Time Complexity: O(n)

This means the time to send notifications grows in a straight line with the number of subscribers.

Common Mistake

[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.

Interview Connect

Understanding how notification sending scales helps you explain real-world API behavior clearly and confidently.

Self-Check

"What if notifications were sent in parallel instead of one by one? How would the time complexity change?"