1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Managing Heartbeats</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Getting Started with Replicated Berkeley DB Applications" />
10    <link rel="up" href="repapp.html" title="Chapter 3. The DB Replication Manager" />
11    <link rel="prev" href="fmwrkconnectretry.html" title="Managing Connection Retries" />
12    <link rel="next" href="fwrkmasterreplica.html" title="Chapter 4. Replica versus Master Processes" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Managing Heartbeats</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="fmwrkconnectretry.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 3. The DB Replication Manager</th>
23          <td width="20%" align="right"> <a accesskey="n" href="fwrkmasterreplica.html">Next</a></td>
24        </tr>
25      </table>
26      <hr />
27    </div>
28    <div class="sect1" lang="en" xml:lang="en">
29      <div class="titlepage">
30        <div>
31          <div>
32            <h2 class="title" style="clear: both"><a id="heartbeats"></a>Managing Heartbeats</h2>
33          </div>
34        </div>
35      </div>
36      <p>
37                    If your replicated application experiences few updates,
38                    it is possible for the replication group to lose a
39                    master without noticing it. This is because normally a
40                    replicated application only knows that a master has
41                    gone missing when update activity causes messages to be
42                    passed between the master and replicas.
43            </p>
44      <p>
45                    To guard against this, you can configure a heartbeat.
46                    The heartbeat must be configured for both the master
47                    and each of the replicas.
48            </p>
49      <p>
50                    On the master, you configure the application to send a
51                    heartbeat on a defined interval when it is otherwise
52                    idle. Do this by using the
53                    <span>
54                            <code class="literal">DB_REP_HEARTBEAT_SEND</code> value
55                            to the <code class="literal">which</code> parameter of the
56                            <code class="methodname">DB_ENV-&gt;rep_set_timeout()</code>
57                            
58                            method.
59                    </span>
60                
61                You must also provide the method a value representing the frequency of
62                the heartbeat in microseconds. Note that the heartbeat is sent only if the
63                system is idle.
64            </p>
65      <p>
66                    On the replica, you configure the application to listen
67                    for a heartbeat. The time that you configure here is
68                    the amount of time the replica will wait for some
69                    message from the master (either the heartbeat or some
70                    other message) before concluding that the connection is
71                    lost. You do this using the 
72                    <span>
73                            <code class="literal">DB_REP_HEARTBEAT_MONITOR</code> value
74                            to the <code class="literal">which</code> parameter of the 
75                            <code class="methodname">DB_ENV-&gt;rep_set_timeout()</code>
76                            
77                            method and a timeout value in microseconds.
78                    </span>
79                
80            </p>
81      <p>
82                For best results, configure the heartbeat monitor for a
83                longer time interval than the heartbeat send interval.
84            </p>
85    </div>
86    <div class="navfooter">
87      <hr />
88      <table width="100%" summary="Navigation footer">
89        <tr>
90          <td width="40%" align="left"><a accesskey="p" href="fmwrkconnectretry.html">Prev</a> </td>
91          <td width="20%" align="center">
92            <a accesskey="u" href="repapp.html">Up</a>
93          </td>
94          <td width="40%" align="right"> <a accesskey="n" href="fwrkmasterreplica.html">Next</a></td>
95        </tr>
96        <tr>
97          <td width="40%" align="left" valign="top">Managing Connection Retries </td>
98          <td width="20%" align="center">
99            <a accesskey="h" href="index.html">Home</a>
100          </td>
101          <td width="40%" align="right" valign="top"> Chapter 4. Replica versus Master Processes</td>
102        </tr>
103      </table>
104    </div>
105  </body>
106</html>
107