Subdomain 1.3: Understand Distribute Processing
1.A Structured Streaming job processes Kafka data with stateful aggregations and watermarks. It accumulates large state and occasionally runs out of memory. Select all actions that help reduce state size or improve stability:(Select 4)
- A.Reduce the watermark delay
- B.Increase spark.sql.shuffle.partitions
- C.Use RocksDB for state storage
- D.Decrease the trigger interval
- E.Enable state store compression
- F.Increase executor memory
Show answer & explanation
Correct answers: A, C, E, F — Reduce the watermark delay; Use RocksDB for state storage; Enable state store compression; Increase executor memory
- A. Correct. Reducing the watermark delay causes Spark to drop late data more aggressively, allowing older state to be evicted sooner. This directly reduces the amount of state maintained, lowering memory pressure. However, it must be balanced against the tolerance for late-arriving data.
- B. Incorrect. Increasing spark.sql.shuffle.partitions changes the parallelism for shuffle operations but does not directly reduce the total amount of state kept by stateful aggregations. It is not an effective measure for reducing state size or memory usage.
- C. Correct. Using RocksDB for state storage offloads state management from the JVM heap to disk-based storage, significantly reducing memory pressure. RocksDB is designed for large stateful workloads and improves stability by handling state more efficiently.
- D. Incorrect. Decreasing the trigger interval increases the frequency of micro-batches, which leads to more frequent state updates and higher overhead. It does not reduce state size and can actually increase memory usage due to more processing cycles.
- E. Correct. Enabling state store compression reduces the on-disk and in-memory footprint of state data. This directly lowers memory usage and helps manage large state, improving stability without altering the logical state structure.
- F. Correct. Increasing executor memory provides more heap and off-heap resources to the streaming query. While it does not reduce the size of state, it helps prevent out-of-memory failures and improves stability when state is legitimately large. It is a valid approach to improve stability.