Hydration
View as MarkdownHydration is the reconstruction of an object’s in-memory state by reading from Materialize’s storage layer; hydration does not read from the upstream system.
When hydration occurs
Depending on the object, hydration (or rehydration) occurs after:
- An object is created or recreated, triggering its hydration.
- This includes recreating objects to force re-planning. For example, after dropping an index, you can drop and recreate its dependent objects to force them to re-plan and rehydrate.
- A cluster or replica restarts, such as during Materialize Cloud’s routine maintenance or after an out-of-memory event. Hydration can be memory-intensive and can itself trigger the out-of-memory event. The replica then restarts and rehydrates again, potentially creating a restart-and-rehydrate loop if the replica is undersized.
- A cluster resize, which provisions new replicas at the target size and hydrates them before retiring the old ones. The cluster keeps serving throughout.
- Adding a replica to a cluster, which hydrates the new replica only. Existing replicas are unaffected and keep serving.
For when hydration occurs for each object type, see Objects and hydration.
Objects and hydration
Hydration is per replica. When a trigger above occurs, the objects on the affected replicas hydrate as described below. A restart re-hydrates a cluster’s existing replicas. A resize or an added replica hydrates only the new replicas it provisions. On those new replicas, every object hydrates just as it would after a restart.
| Object | Hydration behavior |
|---|---|
| Materialized views |
|
| Indexes |
|
| Kafka upsert sources and associated read-only tables/subsources |
|
| Append-only Kafka sources and CDC database sources (PostgreSQL, MySQL, SQL Server), and their read-only tables/subsources |
|
| Webhook sources |
Not applicable. A webhook source is not maintained by a dataflow. It receives data pushed over HTTP and writes the data directly to storage, so it does not hydrate. |
| Sinks |
|
| Subscriptions |
|
Hydration strategies
Hydration primarily impacts memory usage, and its speed scales with cluster size. Some hydration-related strategies you may want to consider:
-
Add an
AUTO SCALING STRATEGY (ON HYDRATION)to your cluster. With this strategy, Materialize automatically provisions an extra, larger replica (a burst replica) while the cluster has un-hydrated objects, then removes it once a steady-size replica catches up. You pay for the burst replica while it is provisioned, but not at steady state. -
Split materialized views and indexes across multiple clusters. Each cluster hydrates its own objects independently, which distributes the memory required for hydration, lets objects on different clusters hydrate in parallel, and limits how much must re-hydrate when a single cluster restarts.
-
When changing a materialized view or index, or forcing dependents to re-plan (for example, after dropping an index and recreating the dependents), build the new version to the side to avoid downtime:
-
A blue/green deployment hydrates the new version alongside the old and cuts over when hydrated, with no serving gap. Note that blue/green requires sources and sinks to live on dedicated clusters that are excluded from the swap. For more information, see blue/green deployment.
-
For a single materialized view, creating and hydrating a replacement materialized view (public preview) and replacing the existing view in place may be simpler, but briefly reduces freshness.
-