Thread: Sync replication + high latency server

Sync replication + high latency server

From
Edson Richter
Date:
Hi!

I've a situation where I would like to keep sync replication, where servers have 10Mbps network connection but high latency (normally, ~20ms but sometimes, 1000ms~2000ms, even 3000ms when network is under load).

Considering that I will keep enough WAL files (let's say, 200 WAL segments on a server with low write rate):

What happens if I configure timeout in master server for, let's say, 10 seconds?
Will sync replication survive if timeout happens, and then, network "recover" it self?

Or will I be obligated to use async replication in such scenario?

I'll appreciate your expert insight.


Thanks,

Edson

Re: Sync replication + high latency server

From
"Joshua D. Drake"
Date:
On 08/12/2015 05:33 PM, Edson Richter wrote:
> Hi!
>
> I've a situation where I would like to keep sync replication, where
> servers have 10Mbps network connection but high latency (normally, ~20ms
> but sometimes, 1000ms~2000ms, even 3000ms when network is under load).
>
> Considering that I will keep enough WAL files (let's say, 200 WAL
> segments on a server with low write rate):
>
> What happens if I configure timeout in master server for, let's say, 10
> seconds?
> Will sync replication survive if timeout happens, and then, network
> "recover" it self?

I think you are misunderstanding how sync rep works.

>
> Or will I be obligated to use async replication in such scenario?
>

async is your friend here.

JD


--
Command Prompt, Inc. - http://www.commandprompt.com/  503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Announcing "I'm offended" is basically telling the world you can't
control your own emotions, so everyone else should do it for you.


Re: Sync replication + high latency server

From
Edson Richter
Date:
Em 13/08/2015 00:40, Joshua D. Drake escreveu:
>
> On 08/12/2015 05:33 PM, Edson Richter wrote:
>> Hi!
>>
>> I've a situation where I would like to keep sync replication, where
>> servers have 10Mbps network connection but high latency (normally, ~20ms
>> but sometimes, 1000ms~2000ms, even 3000ms when network is under load).
>>
>> Considering that I will keep enough WAL files (let's say, 200 WAL
>> segments on a server with low write rate):
>>
>> What happens if I configure timeout in master server for, let's say, 10
>> seconds?
>> Will sync replication survive if timeout happens, and then, network
>> "recover" it self?
>
> I think you are misunderstanding how sync rep works.

I don't think so: sync replication will force commit on both databases
before returning OK to my app server.

>
>>
>> Or will I be obligated to use async replication in such scenario?
>>
>
> async is your friend here.

And what about the timeout when using sync replication? What will happen?

Thanks,

Edson


>
> JD
>
>



Re: Sync replication + high latency server

From
Adrian Klaver
Date:
On 08/13/2015 07:41 AM, Edson Richter wrote:
>
> Em 13/08/2015 00:40, Joshua D. Drake escreveu:
>>
>> On 08/12/2015 05:33 PM, Edson Richter wrote:
>>> Hi!
>>>
>>> I've a situation where I would like to keep sync replication, where
>>> servers have 10Mbps network connection but high latency (normally, ~20ms
>>> but sometimes, 1000ms~2000ms, even 3000ms when network is under load).
>>>
>>> Considering that I will keep enough WAL files (let's say, 200 WAL
>>> segments on a server with low write rate):
>>>
>>> What happens if I configure timeout in master server for, let's say, 10
>>> seconds?
>>> Will sync replication survive if timeout happens, and then, network
>>> "recover" it self?
>>
>> I think you are misunderstanding how sync rep works.
>
> I don't think so: sync replication will force commit on both databases
> before returning OK to my app server.
>
>>
>>>
>>> Or will I be obligated to use async replication in such scenario?
>>>
>>
>> async is your friend here.
>
> And what about the timeout when using sync replication? What will happen?

If you are talking about archive_timeout, all that is going to do is
generate more WAL files. More to the point the WAL files will still the
same length(by default 16MB). So I am not sure how that is going to help
with your network issues.

If you are not talking about the above, then what timeout are referring to?

>
> Thanks,
>
> Edson
>
>
>>
>> JD
>>
>>
>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


Re: Sync replication + high latency server

From
Martín Marqués
Date:
El 13/08/15 a las 11:41, Edson Richter escribió:
>
> Em 13/08/2015 00:40, Joshua D. Drake escreveu:
>>
>> On 08/12/2015 05:33 PM, Edson Richter wrote:
>>> Hi!
>>>
>>> I've a situation where I would like to keep sync replication, where
>>> servers have 10Mbps network connection but high latency (normally, ~20ms
>>> but sometimes, 1000ms~2000ms, even 3000ms when network is under load).
>>>
>>> Considering that I will keep enough WAL files (let's say, 200 WAL
>>> segments on a server with low write rate):
>>>
>>> What happens if I configure timeout in master server for, let's say, 10
>>> seconds?
>>> Will sync replication survive if timeout happens, and then, network
>>> "recover" it self?
>>
>> I think you are misunderstanding how sync rep works.
>
> I don't think so: sync replication will force commit on both databases
> before returning OK to my app server.

So, you are ok with your app waiting more than 3s (actually 3s + the
actual commit time from both servers) to commit?

This doesn't seem acceptable.

>>
>>>
>>> Or will I be obligated to use async replication in such scenario?
>>>
>>
>> async is your friend here.
>
> And what about the timeout when using sync replication? What will happen?

There isn't any replication timeout GUC.

If your sync replica fails, your transactions will get stalled waiting
for the transaction to get committed on one of the sync replicas.

Do you get the idea (or actually the problem behind your design)?


--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services