Serverless security considerations in Cybersecurity - Time & Space Complexity
When we look at serverless security, we want to understand how the time to check or enforce security changes as the system grows.
We ask: How does the effort to keep serverless functions safe grow when there are more functions or more events?
Analyze the time complexity of the following security check process for serverless functions.
for function in serverless_functions:
for event in function.events:
if not validate_event(event):
alert_security_team(function, event)
This code checks each event of every serverless function to ensure it meets security rules, alerting if something is wrong.
Look at what repeats in the code.
- Primary operation: Checking each event with
validate_event. - How many times: For every function, it checks all its events.
The time to finish grows as the number of functions and their events grow.
| Input Size (n functions, m events each) | Approx. Operations |
|---|---|
| 10 functions, 5 events | 50 checks |
| 100 functions, 5 events | 500 checks |
| 1000 functions, 5 events | 5000 checks |
Pattern observation: The total checks grow by multiplying the number of functions by the number of events per function.
Time Complexity: O(n * m)
This means the time to check security grows proportionally with both the number of functions and the number of events each has.
[X] Wrong: "Checking security for one function means the time stays the same no matter how many functions exist."
[OK] Correct: Each function adds more events to check, so total time grows with more functions, not stays fixed.
Understanding how security checks scale helps you design safer serverless systems and shows you can think about real-world growth challenges.
"What if we only checked a fixed number of events per function regardless of total events? How would the time complexity change?"