Graph scale and execution performance
Measure the whole workflow
A slow Terraform run can be caused by setup, provider startup, state retrieval, evaluation, API reads, graph execution or state persistence. First separate waiting from useful work. State is the record of managed object identities and attributes; larger state can increase serialization and backend transfer costs. Provider initialization may also involve module retrieval or dependency installation, whereas an already prepared environment avoids some setup work. A module is an organizational boundary, not automatically a separate state or independently scheduled run.
Record per run: configuration revision, CLI/provider versions, backend, resource counts, state bytes, plan mode, queue wait, initialization, plan wall time, outcome, and provider error counts.Use redacted telemetry; never attach raw state, plan JSON or sensitive logs to a public performance issue. Compare identical inputs and successful outcomes, not a failed fast run with a correct slow one.
Reason about dependency depth
Graph nodes represent operations and dependencies constrain their ordering. The critical path is the longest duration along dependent tasks. In this deliberately simplified model, A must finish before B and C, but B and C are independent of each other. D waits for both.
Synthetic task model (each task takes 2 seconds; no API or scheduling overhead)Chain: A -> B -> C -> DFork: A -> B, A -> C, B and C -> DChain critical path: 8 secondsFork critical path: 6 secondsFork with one worker: 8 secondsFork with two workers: 6 secondsThe fork has the same amount of work but a shorter critical path. A wider graph is not inherently faster: external quotas, worker availability and provider-specific operations can dominate. The graph displayed by Terraform can include implementation details beyond this four-node model.
Inspect a local dependency graph
In the included fresh local-only fixture, two built-in resources with distinct keys depend on a foundation; a summary consumes both. There are no external providers or cloud accounts. The configuration is unexecuted. In an approved compatible CLI environment inspect the directory, initialize it, validate and view terraform graph. Then inspect a full plan. The initial plan should propose four terraform_data instances; values derived from computed outputs may remain unknown until apply.
resource "terraform_data" "foundation" { input = "base"}
resource "terraform_data" "worker" { for_each = toset(["blue", "green"]) input = terraform_data.foundation.output}
resource "terraform_data" "summary" { input = { for k, v in terraform_data.worker : k => v.output }}
output "result" { value = terraform_data.summary.output}The output is expected to contain blue and green mapped to base after successful apply, which is not required for this exercise. Graph output is DOT text and may show grouped resource nodes rather than one node per instance. Do not equate the visualization with a precise timeline.
Understand concurrency and remote reads
Terraform limits concurrent graph operations using -parallelism (documented default 10). This is not a request-per-second rate limiter: a single provider operation can issue multiple API requests and several independent runs can share quotas. Lower concurrency may alleviate contention or throttling but can also lengthen a run. Profile with provider-specific evidence. Data source fan-out, repeated discovery queries and broad depends_on can increase work or delay evaluations.
Fresh approved local fixture only (not executed here):terraform plan -parallelism=1terraform plan -parallelism=2terraform plan -parallelism=10Use the same initialized directory, unchanged inputs and no apply between samples. Record a warm-up and at least five measured samples per setting; report median and range, CLI version and machine context. Do not extrapolate local built-in resource timing to cloud API behavior. The accompanying Python benchmark times only an offline graph model, not Terraform.
Preserve correctness when reducing scope
Separate roots by ownership, change frequency, failure domain and stable output contracts. For example, a shared network can change on a slower cadence than application infrastructure. Review dependency direction, state access, migration and coordinated release rules before splitting. A smaller module alone does not reduce a root state. Never routinely use -target to speed up everyday plans: it can omit unrelated changes; follow exceptional targeting with a full review. Disabling refresh may hide external changes, so do not adopt -refresh=false as a default optimization. Keep locks enabled; a slow lock is a coordination problem, not a reason to bypass it.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Graph scale and execution performance — knowledge check
Review dependency performance and bounded recovery.
Which graph has the shorter ideal critical path in the model?
What does -parallelism limit?
Which change creates an independent state boundary?
Why avoid routine -target?
Which comparison is sound?