Measuring replication lag time

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Measuring replication lag time

Stuart Bishop
Hi.

I need to measure how far in the past a hot standby is, async
streaming replication.

On the Hot Standby, "select
age(current_timestamp,pg_last_xact_replay_timestamp())" gets me this
(or close enough for my purposes - I understand that if there are no
updates, there are no logs to replay and the lag time will increase).

Is there some way to get this same information on the master?
pg_stat_replication contains the log information, but I can't see how
to map this to a timestamp.

Is there a better way of measuring this?

--
Stuart Bishop <[hidden email]>
http://www.stuartbishop.net/

--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Measuring replication lag time

Venkat Balaji
On Wed, Feb 22, 2012 at 5:40 PM, Stuart Bishop <[hidden email]> wrote:

Hi.

I need to measure how far in the past a hot standby is, async
streaming replication.

On the Hot Standby, "select
age(current_timestamp,pg_last_xact_replay_timestamp())" gets me this
(or close enough for my purposes - I understand that if there are no
updates, there are no logs to replay and the lag time will increase).

Is there some way to get this same information on the master?
pg_stat_replication contains the log information, but I can't see how
to map this to a timestamp.

Is there a better way of measuring this?

Comparing "pg_controldata" output on prod and standby might help you with this. 

Thanks,
VB
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Measuring replication lag time

Greg Williamson-3
In reply to this post by Stuart Bishop
Stuart Bishop shaped the aether to ask:

> Hi.
>
> I need to measure how far in the past a hot standby is, async
> streaming replication.
>


Not sure if this will help, but we are using repmgr <https://github.com/greg2ndQuadrant/repmgr>; it sets up a monitoring schema which we poll )see the "Monitoring and Testing" section ... study their source code some and see how they come up with lag times.

HTH,

Greg WiIliamson
DBA
Powerreviews dot com


--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Measuring replication lag time

Stuart Bishop
On Thu, Feb 23, 2012 at 2:58 AM, Greg Williamson
<[hidden email]> wrote:
> Stuart Bishop shaped the aether to ask:
>
>> Hi.
>>
>> I need to measure how far in the past a hot standby is, async
>> streaming replication.
>
> Not sure if this will help, but we are using repmgr <https://github.com/greg2ndQuadrant/repmgr>; it sets up a monitoring schema which we poll )see the "Monitoring and Testing" section ... study their source code some and see how they come up with lag times.

Might help indeed. My existing solution already has a small daemon (I
can't always query the Slony-I sl_status view fast enough for load
balancing web requests, so I maintain a cache). But repmgr seems to
cover other work I need to do to keep ops happy so something for me to
look closer at.


--
Stuart Bishop <[hidden email]>
http://www.stuartbishop.net/

--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Measuring replication lag time

Samba

Comparing "pg_controldata" output on prod and standby might help you with this.

We do use this approach and it is pretty reliable and gives time lag up to the granularity of checkpoint_timeout.



On Thu, Feb 23, 2012 at 11:51 AM, Stuart Bishop <[hidden email]> wrote:
On Thu, Feb 23, 2012 at 2:58 AM, Greg Williamson
<[hidden email]> wrote:
> Stuart Bishop shaped the aether to ask:
>
>> Hi.
>>
>> I need to measure how far in the past a hot standby is, async
>> streaming replication.
>
> Not sure if this will help, but we are using repmgr <https://github.com/greg2ndQuadrant/repmgr>; it sets up a monitoring schema which we poll )see the "Monitoring and Testing" section ... study their source code some and see how they come up with lag times.

Might help indeed. My existing solution already has a small daemon (I
can't always query the Slony-I sl_status view fast enough for load
balancing web requests, so I maintain a cache). But repmgr seems to
cover other work I need to do to keep ops happy so something for me to
look closer at.
--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Loading...