Correct answer: E
Decrease the trigger interval to 5 seconds; triggering batches more frequently may
prevent records from backing up and large batches from causing spill.
Explanation
Explanation:
The adjustment that will meet the requirement of processing records in less
than 10 seconds is to decrease the trigger interval to 5 seconds. This is because triggering
batches more frequently may prevent records from backing up and large batches from
causing spill. Spill is a phenomenon where the data in memory exceeds the available
capacity and has to be written to disk, which can slow down the processing and increase
the execution time1. By reducing the trigger interval, the streaming query can process
smaller batches of data more quickly and avoid spill. This can also improve the latency and
throughput of the streaming job2.
The other options are not correct, because:
Option A is incorrect because triggering batches more frequently does not allow
idle executors to begin processing the next batch while longer running tasks from
previous batches finish. In fact, the opposite is true. Triggering batches more
frequently may cause concurrent batches to compete for the same resources and
cause contention and backpressure2. This can degrade the performance and
stability of the streaming job.
Option B is incorrect because increasing the trigger interval to 30 seconds is not a
good practice to ensure no records are dropped. Increasing the trigger interval
means that the streaming query will process larger batches of data less frequently,
which can increase the risk of spill, memory pressure, and timeouts12. This can
also increase the latency and reduce the throughput of the streaming job.
Option C is incorrect because the trigger interval can be modified without
modifying the checkpoint directory. The checkpoint directory stores the metadata
and state of the streaming query, such as the offsets, schema, and configuration3.
Changing the trigger interval does not affect the state of the streaming query, and
does not require a new checkpoint directory. However, changing the number of
shuffle partitions may affect the state of the streaming query, and may require a
new checkpoint directory4.
Option D is incorrect because using the trigger once option and configuring a
Databricks job to execute the query every 10 seconds does not ensure that all
backlogged records are processed with each batch. The trigger once option
means that the streaming query will process all the available data in the source
and then stop5. However, this does not guarantee that the query will finish
processing within 10 seconds, especially if there are a lot of records in the source.
Moreover, configuring a Databricks job to execute the query every 10 seconds
may cause overlapping or missed batches, depending on the execution time of the
query.
References:
Memory Management Overview, Structured Streaming Performance Tuning
Guide, Checkpointing, Recovery Semantics after Changes in a Streaming Query, Triggers