You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a few use cases when the state size is very big, and we were looking into optimizing performance. What I noticed is that by default, we're using pretty-printed JSON when storing the state, and the resulting file size is much bigger than if we use compact representation, and this make read/write of state slower, not taking into account increased storage and egress costs when using cloud backends.
For example, here is comparison of the state with ~70k objects - original state (mkdirs.tfstate) is converted into compact representation by running jq -c . on it.
84096 -rw-rw-r--@ 1 alex staff 42996911 Apr 27 10:53 mkdirs-compact.tfstate
114112 -rw-r--r--@ 1 alex staff 57680266 Apr 27 10:50 mkdirs.tfstate
Attempted Solutions
I have PR for it...
Proposal
We should be able to store the state in compact JSON format. This could be done either way:
Use compact representation by default
Make it configurable with some environment variable
References
No response
The text was updated successfully, but these errors were encountered:
This PR allows to write JSON using compact (non-indented) representation if the
`TF_USE_COMPACT_STATE_FORMAT` environment variable is defined. This significantly
improves performance when working with huge states.
For example (on ~450k objects in state):
* state size is decreased from 510.1MB to 386.6MB
* Time to write to S3 decreased from 112 seconds to 94 seconds
* Time to read from S3 decreased from 87 seconds -> 55 seconds
Fixeshashicorp#35174
Signed-off-by: Alex Ott <alexott@gmail.com>
Terraform Version
Use Cases
We have a few use cases when the state size is very big, and we were looking into optimizing performance. What I noticed is that by default, we're using pretty-printed JSON when storing the state, and the resulting file size is much bigger than if we use compact representation, and this make read/write of state slower, not taking into account increased storage and egress costs when using cloud backends.
For example, here is comparison of the state with ~70k objects - original state (
mkdirs.tfstate
) is converted into compact representation by runningjq -c .
on it.Attempted Solutions
I have PR for it...
Proposal
We should be able to store the state in compact JSON format. This could be done either way:
References
No response
The text was updated successfully, but these errors were encountered: