Understanding heartbeat in ASP.NET health monitori

2019-07-20 15:30发布

问题:

Who's triggering the event? What are consequences/benefits of enabling it in <healthMonitoring enabled="true" heartbeatInterval="30"> except it appears every 30 seconds in the logs? Has it anything to do with NLB heartbeat? What interval is better for production use?

回答1:

Enabling it in this way in the web.config will cause the Application Domain to raise a WebHeartbeatEvent periodically (in your case every 30 seconds), basically to check if your application is 'still alive' (like checking a human's heartbeat). You can specify additional rules like this:

<healthMonitoring enabled="true" heartbeatInterval="100">
  <rules>
    <add name="Heart Beat Events"
      eventName="Heartbeats"
      provider="EventLogProvider"
      profile="Default"
      minInterval="00:01:00" />
  </rules>
</healthMonitoring>

Specifying 'EventLogProvider' will cause the events to be logged to the EventLog, but you could also write your own Provider, see here.

It has nothing to do with the NLB heartbeat by the way, which is only used for Load Balancing purposes.