0
0
MLOpsdevops~5 mins

Multi-tenancy and isolation in MLOps - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Multi-tenancy and isolation
O(n * m)
Understanding Time Complexity

When managing multiple users or teams on the same system, it's important to understand how the system's work grows as more tenants are added.

We want to know how the system handles tasks for many tenants without slowing down too much.

Scenario Under Consideration

Analyze the time complexity of the following code snippet.


for tenant in tenants:
    isolate_environment(tenant)
    for job in tenant.jobs:
        run_job(job)
        log_results(job)

This code runs jobs for each tenant separately, isolating their environments and logging results.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Running jobs inside each tenant's isolated environment.
  • How many times: For each tenant, all their jobs are processed one by one.
How Execution Grows With Input

As the number of tenants and their jobs increase, the total work grows by adding all jobs from all tenants.

Input Size (tenants * jobs)Approx. Operations
10 tenants with 5 jobs each50 operations
100 tenants with 5 jobs each500 operations
100 tenants with 50 jobs each5,000 operations

Pattern observation: The total work grows proportionally with the total number of jobs across all tenants.

Final Time Complexity

Time Complexity: O(n * m)

This means the time grows in proportion to the number of tenants (n) times the number of jobs per tenant (m).

Common Mistake

[X] Wrong: "Adding more tenants won't affect the time much because jobs run independently."

[OK] Correct: Even if jobs run separately, the system still processes all jobs for all tenants, so total time grows with total jobs.

Interview Connect

Understanding how work scales with tenants and jobs helps you design systems that stay efficient as more users join.

Self-Check

"What if jobs for all tenants could run in parallel? How would that change the time complexity?"