kubectl apply vs create in Kubernetes - Performance Comparison
We want to understand how the time to run kubectl apply and kubectl create changes as the number of Kubernetes resources grows.
How does the command's work grow when we manage more resources?
Analyze the time complexity of these commands managing multiple resources.
kubectl create -f resources.yaml
kubectl apply -f resources.yaml
kubectl create makes new resources, while kubectl apply creates or updates resources by checking their current state.
Look at what repeats when these commands run on many resources.
- Primary operation: For each resource,
kubectl createsends a creation request once;kubectl applyfirst fetches the current state, then sends create or update requests. - How many times: Once per resource for both commands, but
applydoes extra checks per resource.
As the number of resources grows, the work grows roughly in a straight line.
| Input Size (n) | Approx. Operations for create | Approx. Operations for apply |
|---|---|---|
| 10 | 10 create requests | 10 fetch + 10 create/update requests |
| 100 | 100 create requests | 100 fetch + 100 create/update requests |
| 1000 | 1000 create requests | 1000 fetch + 1000 create/update requests |
Pattern observation: Both commands scale linearly, but apply does about twice the work per resource.
Time Complexity: O(n)
This means the time grows directly with the number of resources you manage.
[X] Wrong: "kubectl apply is always faster than kubectl create because it updates only changed resources."
[OK] Correct: apply always checks the current state first, so it does extra work per resource, making it slower when many resources are involved.
Understanding how commands scale with resource count helps you design efficient deployment processes and shows you think about real-world system behavior.
What if we changed kubectl apply to use server-side apply? How would the time complexity change?