Sql-server – the impact of MAX_DISPATCH_LATENCY while configuring EXTENDED EVENT

extended-eventsperformancesql server 2014trace

By default, MAX_DISPATCH_LATENCY is set to 30 seconds. I chose FILE as a target and write all captures there. I thought that if I write all captures into file, why would then I lower down MAX_DISPATCH_LATENCY to 1 second and by this way prevent captures from staying in the memory for the max duration of 30 seconds. What is the impact of lowering down MAX_DISPATCH_LATENCY?

Best Answer

From my research it doesn't sound like anything terrible can really happen from adjusting that property, but it also generally doesn't need to really be adjusted because 30 seconds is typically a good value for an Extended Events session.

You can read more about the property here but basically its purpose is to set a threshold for the max amount of time the captured events stay in the buffer in memory. Often times the captured events are written to their destination before hitting that threshold, so it's more of a catch all limit. Aside from that threshold, the buffer also gets flushed to the destination once the buffer is full.

Ultimately the reasoning behind having the buffer work this way rather than instantly writing to the destination every time is because I/O is less performant to write to then memory. Constant writes from the buffer to disk (e.g. a file in your case) could be bottlenecked by and/or cause bottlenecks to the disk. Doing batch writes to disk is most performant when there's a lot of data, and when there's not a lot of data then the MAX_DISPATCH_LATENCY threshold will handle writing your events to the file.