You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@bookkeeper.apache.org by Aniruddha Laud <tr...@gmail.com> on 2012/09/21 04:42:29 UTC

High latencies observed at the bookkeeper client while reading entries

I'm logging latencies in the per channel bookie client by overriding the
read completion and add completion callbacks.

When a hedwig subscriber subscribes to a topic and it hasn't consumed any
messages for a long time, it has to issue requests to bookkeeper to read
entries. We are observing very high latencies during these operations.

throttle limit for the bookkeeper client is set at 5000. We are using the
Hierarchical ledger manager.

The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
bookie server pageSize=32768, open file limit = 20000. I checked a few
bookies and the number of open ledgers was around 5000 on each. However,
the add and read latencies on the servers were less than 1 second (measured
using jconsole and the exposed jmx stats).

Also, the bookie disks are standard spin drives and were doing about 40MBps
reads and 10MBps writes when measured with dstat. Any thoughts would be
helpful.

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
Hi Aniruddha, Are you using trunk for your tests?

On Sep 21, 2012, at 4:42 AM, Aniruddha Laud wrote:

> I'm logging latencies in the per channel bookie client by overriding the
> read completion and add completion callbacks.
> 
> When a hedwig subscriber subscribes to a topic and it hasn't consumed any
> messages for a long time, it has to issue requests to bookkeeper to read
> entries. We are observing very high latencies during these operations.
> 
> throttle limit for the bookkeeper client is set at 5000. We are using the
> Hierarchical ledger manager.
> 

We throttle before PerChannelBookieClient, so if the high latency you're observing is in PCBC, then it shouldn't be related to throttling.

> The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
> bookie server pageSize=32768, open file limit = 20000. I checked a few
> bookies and the number of open ledgers was around 5000 on each. However,
> the add and read latencies on the servers were less than 1 second (measured
> using jconsole and the exposed jmx stats).
> 

Did you mean to say 1ms? 1 second for a read/write is a lot.

Can you give some more detail about your traffic, like the mix of reads and adds, size of entries, etc.?

> Also, the bookie disks are standard spin drives and were doing about 40MBps
> reads and 10MBps writes when measured with dstat. Any thoughts would be
> helpful.

Seems low to me, although I would think that they are not the culprits. 

-Flavio

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
Also, if I understand the code correctly, there is just one thread handling
reads as well as writes across all ledgers for the bookie? And this causes
add latencies to increase whenever read latencies increase. Is that
correct?

On Mon, Sep 24, 2012 at 3:18 AM, Sijie Guo <gu...@gmail.com> wrote:

> I don't think increasing the buffer capacity could work. For current bookie
> design, it works well for the writes workload. Because we just cache the
> index entries in ledger cache, for the entry data, it relies on local
> filesystem's cache. so the entries belongs to same ledger scattered on
> different positions in different entry log files, lots of disk head
> movements might be introduced when there is high read traffic to bookie
> servers.
>
> On Sat, Sep 22, 2012 at 6:47 AM, Aniruddha Laud <trojan.of.troy@gmail.com
> >wrote:
>
> > I've been looking into the bookkeeper code and from what I understand,
> > there is only one BufferedChannel per log file and each log file has
> > multiple ledgers mapped to it. The capacity of this buffered channel is
> > hard coded at 8192 bytes. So, if we are reading a number of ledgers from
> > the same log file at the same time, we might end up seeking very often?
> >
> > Is my understanding correct? If so, would it help if we made this channel
> > buffer capacity configurable for the EntryLogger and provide a higher
> > value?
> >
> > Regards,
> > Aniruddha.
> >
> > On Fri, Sep 21, 2012 at 12:06 PM, Aniruddha Laud
> > <tr...@gmail.com>wrote:
> >
> > > I ran sar while the bookies were showing high latencies. Pasting the
> > > output below
> > >
> > > disk with journal
> > > Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
> > > Average: dev8-16 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
> > > Average: dev8-17 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
> > >
> > > Following disks store ledgers.
> > >
> > > Average: dev8-32 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
> > > Average: dev8-33 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
> > >
> > > Average: dev8-48 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
> > > Average: dev8-49 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
> > >
> > > Average: dev8-64 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
> > > Average: dev8-65 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
> > >
> > > Average: dev8-80 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
> > > Average: dev8-81 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
> > >
> > > Regards,
> > > Aniruddha.
> > >
> > > On Fri, Sep 21, 2012 at 9:39 AM, Aniruddha Laud <
> > trojan.of.troy@gmail.com>wrote:
> > >
> > >> Thanks Flavio and Ivan. Please find my replies inline.
> > >>
> > >> Flavio,
> > >> Yes we are using trunk with only a few stats related modifications to
> > >> bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
> > >> checked using jconsole and I believe that is in ms. Our entries are
> > small
> > >> (Around 1KB) and we have a lot of entries in our ledgers (We see close
> > to
> > >> 20k publishes/second on our hedwig cluster)
> > >>
> > >> We have 15 bookie servers with an ensemble size of 4 and quorum of 3.
> > >>
> > >> On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:
> > >>
> > >>> What latency are you getting for the reads? Is the latency too high
> > >>> for reading individual entries, or for reading a whole ledger?
> > >>>
> > >> The latency for reading individual entries is really high. In the
> order
> > >> of seconds. This almost always occurs when a backed up subscriber is
> > >> catching up and there are simultaneous publishes. There are around
> > 15k-20k
> > >> read entry requests per second across the 15 bookies (This is the sum
> of
> > >> the PCBC requests per second) and around 10k add entry requests per
> > second.
> > >> From what I can tell, if there are only writes, the latencies are not
> > high.
> > >>
> > >>>
> > >>> Also, how many topics do you have in the system? The number of topics
> > >>> will define the amount of interleaving in the ledger storage files
> > >>> which has an affect on how long it will take to read entries from the
> > >>> ledger.
> > >>>
> > >> We have 1000 topics.
> > >>
> > >>>
> > >>> For the disk, check the number of I/O transactions which are
> > >>> occurring. I don't think you can get it with dstat, but sar -b should
> > >>> give it to you. I suspect a lot of seeks are occurring.
> > >>>
> > >> Thanks for the tip. I'll do this the next time we run into such a
> > >> problem.
> > >>
> > >>>
> > >>> There's a couple of shortcomings in how bookie's serve reads which
> > >>> I've wanted to look at for a while, so this could be a good chance.
> > >>>
> > >> Could you give some information on what those shortcomings are? Also,
> do
> > >> let me know if you need any more information from our end.
> > >>
> > >>>
> > >>> -Ivan
> > >>>
> > >>>
> > >>>
> > >>> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
> > >>> > I'm logging latencies in the per channel bookie client by
> overriding
> > >>> the
> > >>> > read completion and add completion callbacks.
> > >>> >
> > >>> > When a hedwig subscriber subscribes to a topic and it hasn't
> consumed
> > >>> any
> > >>> > messages for a long time, it has to issue requests to bookkeeper to
> > >>> read
> > >>> > entries. We are observing very high latencies during these
> > operations.
> > >>> >
> > >>> > throttle limit for the bookkeeper client is set at 5000. We are
> using
> > >>> the
> > >>> > Hierarchical ledger manager.
> > >>> >
> > >>> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On
> > the
> > >>> > bookie server pageSize=32768, open file limit = 20000. I checked a
> > few
> > >>> > bookies and the number of open ledgers was around 5000 on each.
> > >>> However,
> > >>> > the add and read latencies on the servers were less than 1 second
> > >>> (measured
> > >>> > using jconsole and the exposed jmx stats).
> > >>> >
> > >>> > Also, the bookie disks are standard spin drives and were doing
> about
> > >>> 40MBps
> > >>> > reads and 10MBps writes when measured with dstat. Any thoughts
> would
> > be
> > >>> > helpful.
> > >>>
> > >>
> > >> Regards,
> > >> Aniruddha.
> > >>
> > >
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
I don't think increasing the buffer capacity could work. For current bookie
design, it works well for the writes workload. Because we just cache the
index entries in ledger cache, for the entry data, it relies on local
filesystem's cache. so the entries belongs to same ledger scattered on
different positions in different entry log files, lots of disk head
movements might be introduced when there is high read traffic to bookie
servers.

On Sat, Sep 22, 2012 at 6:47 AM, Aniruddha Laud <tr...@gmail.com>wrote:

> I've been looking into the bookkeeper code and from what I understand,
> there is only one BufferedChannel per log file and each log file has
> multiple ledgers mapped to it. The capacity of this buffered channel is
> hard coded at 8192 bytes. So, if we are reading a number of ledgers from
> the same log file at the same time, we might end up seeking very often?
>
> Is my understanding correct? If so, would it help if we made this channel
> buffer capacity configurable for the EntryLogger and provide a higher
> value?
>
> Regards,
> Aniruddha.
>
> On Fri, Sep 21, 2012 at 12:06 PM, Aniruddha Laud
> <tr...@gmail.com>wrote:
>
> > I ran sar while the bookies were showing high latencies. Pasting the
> > output below
> >
> > disk with journal
> > Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
> > Average: dev8-16 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
> > Average: dev8-17 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
> >
> > Following disks store ledgers.
> >
> > Average: dev8-32 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
> > Average: dev8-33 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
> >
> > Average: dev8-48 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
> > Average: dev8-49 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
> >
> > Average: dev8-64 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
> > Average: dev8-65 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
> >
> > Average: dev8-80 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
> > Average: dev8-81 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
> >
> > Regards,
> > Aniruddha.
> >
> > On Fri, Sep 21, 2012 at 9:39 AM, Aniruddha Laud <
> trojan.of.troy@gmail.com>wrote:
> >
> >> Thanks Flavio and Ivan. Please find my replies inline.
> >>
> >> Flavio,
> >> Yes we are using trunk with only a few stats related modifications to
> >> bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
> >> checked using jconsole and I believe that is in ms. Our entries are
> small
> >> (Around 1KB) and we have a lot of entries in our ledgers (We see close
> to
> >> 20k publishes/second on our hedwig cluster)
> >>
> >> We have 15 bookie servers with an ensemble size of 4 and quorum of 3.
> >>
> >> On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:
> >>
> >>> What latency are you getting for the reads? Is the latency too high
> >>> for reading individual entries, or for reading a whole ledger?
> >>>
> >> The latency for reading individual entries is really high. In the order
> >> of seconds. This almost always occurs when a backed up subscriber is
> >> catching up and there are simultaneous publishes. There are around
> 15k-20k
> >> read entry requests per second across the 15 bookies (This is the sum of
> >> the PCBC requests per second) and around 10k add entry requests per
> second.
> >> From what I can tell, if there are only writes, the latencies are not
> high.
> >>
> >>>
> >>> Also, how many topics do you have in the system? The number of topics
> >>> will define the amount of interleaving in the ledger storage files
> >>> which has an affect on how long it will take to read entries from the
> >>> ledger.
> >>>
> >> We have 1000 topics.
> >>
> >>>
> >>> For the disk, check the number of I/O transactions which are
> >>> occurring. I don't think you can get it with dstat, but sar -b should
> >>> give it to you. I suspect a lot of seeks are occurring.
> >>>
> >> Thanks for the tip. I'll do this the next time we run into such a
> >> problem.
> >>
> >>>
> >>> There's a couple of shortcomings in how bookie's serve reads which
> >>> I've wanted to look at for a while, so this could be a good chance.
> >>>
> >> Could you give some information on what those shortcomings are? Also, do
> >> let me know if you need any more information from our end.
> >>
> >>>
> >>> -Ivan
> >>>
> >>>
> >>>
> >>> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
> >>> > I'm logging latencies in the per channel bookie client by overriding
> >>> the
> >>> > read completion and add completion callbacks.
> >>> >
> >>> > When a hedwig subscriber subscribes to a topic and it hasn't consumed
> >>> any
> >>> > messages for a long time, it has to issue requests to bookkeeper to
> >>> read
> >>> > entries. We are observing very high latencies during these
> operations.
> >>> >
> >>> > throttle limit for the bookkeeper client is set at 5000. We are using
> >>> the
> >>> > Hierarchical ledger manager.
> >>> >
> >>> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On
> the
> >>> > bookie server pageSize=32768, open file limit = 20000. I checked a
> few
> >>> > bookies and the number of open ledgers was around 5000 on each.
> >>> However,
> >>> > the add and read latencies on the servers were less than 1 second
> >>> (measured
> >>> > using jconsole and the exposed jmx stats).
> >>> >
> >>> > Also, the bookie disks are standard spin drives and were doing about
> >>> 40MBps
> >>> > reads and 10MBps writes when measured with dstat. Any thoughts would
> be
> >>> > helpful.
> >>>
> >>
> >> Regards,
> >> Aniruddha.
> >>
> >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
I've been looking into the bookkeeper code and from what I understand,
there is only one BufferedChannel per log file and each log file has
multiple ledgers mapped to it. The capacity of this buffered channel is
hard coded at 8192 bytes. So, if we are reading a number of ledgers from
the same log file at the same time, we might end up seeking very often?

Is my understanding correct? If so, would it help if we made this channel
buffer capacity configurable for the EntryLogger and provide a higher
value?

Regards,
Aniruddha.

On Fri, Sep 21, 2012 at 12:06 PM, Aniruddha Laud
<tr...@gmail.com>wrote:

> I ran sar while the bookies were showing high latencies. Pasting the
> output below
>
> disk with journal
> Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
> Average: dev8-16 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
> Average: dev8-17 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
>
> Following disks store ledgers.
>
> Average: dev8-32 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
> Average: dev8-33 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
>
> Average: dev8-48 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
> Average: dev8-49 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
>
> Average: dev8-64 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
> Average: dev8-65 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
>
> Average: dev8-80 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
> Average: dev8-81 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
>
> Regards,
> Aniruddha.
>
> On Fri, Sep 21, 2012 at 9:39 AM, Aniruddha Laud <tr...@gmail.com>wrote:
>
>> Thanks Flavio and Ivan. Please find my replies inline.
>>
>> Flavio,
>> Yes we are using trunk with only a few stats related modifications to
>> bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
>> checked using jconsole and I believe that is in ms. Our entries are small
>> (Around 1KB) and we have a lot of entries in our ledgers (We see close to
>> 20k publishes/second on our hedwig cluster)
>>
>> We have 15 bookie servers with an ensemble size of 4 and quorum of 3.
>>
>> On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:
>>
>>> What latency are you getting for the reads? Is the latency too high
>>> for reading individual entries, or for reading a whole ledger?
>>>
>> The latency for reading individual entries is really high. In the order
>> of seconds. This almost always occurs when a backed up subscriber is
>> catching up and there are simultaneous publishes. There are around 15k-20k
>> read entry requests per second across the 15 bookies (This is the sum of
>> the PCBC requests per second) and around 10k add entry requests per second.
>> From what I can tell, if there are only writes, the latencies are not high.
>>
>>>
>>> Also, how many topics do you have in the system? The number of topics
>>> will define the amount of interleaving in the ledger storage files
>>> which has an affect on how long it will take to read entries from the
>>> ledger.
>>>
>> We have 1000 topics.
>>
>>>
>>> For the disk, check the number of I/O transactions which are
>>> occurring. I don't think you can get it with dstat, but sar -b should
>>> give it to you. I suspect a lot of seeks are occurring.
>>>
>> Thanks for the tip. I'll do this the next time we run into such a
>> problem.
>>
>>>
>>> There's a couple of shortcomings in how bookie's serve reads which
>>> I've wanted to look at for a while, so this could be a good chance.
>>>
>> Could you give some information on what those shortcomings are? Also, do
>> let me know if you need any more information from our end.
>>
>>>
>>> -Ivan
>>>
>>>
>>>
>>> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
>>> > I'm logging latencies in the per channel bookie client by overriding
>>> the
>>> > read completion and add completion callbacks.
>>> >
>>> > When a hedwig subscriber subscribes to a topic and it hasn't consumed
>>> any
>>> > messages for a long time, it has to issue requests to bookkeeper to
>>> read
>>> > entries. We are observing very high latencies during these operations.
>>> >
>>> > throttle limit for the bookkeeper client is set at 5000. We are using
>>> the
>>> > Hierarchical ledger manager.
>>> >
>>> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
>>> > bookie server pageSize=32768, open file limit = 20000. I checked a few
>>> > bookies and the number of open ledgers was around 5000 on each.
>>> However,
>>> > the add and read latencies on the servers were less than 1 second
>>> (measured
>>> > using jconsole and the exposed jmx stats).
>>> >
>>> > Also, the bookie disks are standard spin drives and were doing about
>>> 40MBps
>>> > reads and 10MBps writes when measured with dstat. Any thoughts would be
>>> > helpful.
>>>
>>
>> Regards,
>> Aniruddha.
>>
>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
I've been looking into the bookkeeper code and from what I understand,
there is only one BufferedChannel per log file and each log file has
multiple ledgers mapped to it. The capacity of this buffered channel is
hard coded at 8192 bytes. So, if we are reading a number of ledgers from
the same log file at the same time, we might end up seeking very often?

Is my understanding correct? If so, would it help if we made this channel
buffer capacity configurable for the EntryLogger and provide a higher
value?

Regards,
Aniruddha.

On Fri, Sep 21, 2012 at 12:06 PM, Aniruddha Laud
<tr...@gmail.com>wrote:

> I ran sar while the bookies were showing high latencies. Pasting the
> output below
>
> disk with journal
> Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
> Average: dev8-16 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
> Average: dev8-17 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
>
> Following disks store ledgers.
>
> Average: dev8-32 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
> Average: dev8-33 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
>
> Average: dev8-48 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
> Average: dev8-49 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
>
> Average: dev8-64 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
> Average: dev8-65 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
>
> Average: dev8-80 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
> Average: dev8-81 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
>
> Regards,
> Aniruddha.
>
> On Fri, Sep 21, 2012 at 9:39 AM, Aniruddha Laud <tr...@gmail.com>wrote:
>
>> Thanks Flavio and Ivan. Please find my replies inline.
>>
>> Flavio,
>> Yes we are using trunk with only a few stats related modifications to
>> bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
>> checked using jconsole and I believe that is in ms. Our entries are small
>> (Around 1KB) and we have a lot of entries in our ledgers (We see close to
>> 20k publishes/second on our hedwig cluster)
>>
>> We have 15 bookie servers with an ensemble size of 4 and quorum of 3.
>>
>> On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:
>>
>>> What latency are you getting for the reads? Is the latency too high
>>> for reading individual entries, or for reading a whole ledger?
>>>
>> The latency for reading individual entries is really high. In the order
>> of seconds. This almost always occurs when a backed up subscriber is
>> catching up and there are simultaneous publishes. There are around 15k-20k
>> read entry requests per second across the 15 bookies (This is the sum of
>> the PCBC requests per second) and around 10k add entry requests per second.
>> From what I can tell, if there are only writes, the latencies are not high.
>>
>>>
>>> Also, how many topics do you have in the system? The number of topics
>>> will define the amount of interleaving in the ledger storage files
>>> which has an affect on how long it will take to read entries from the
>>> ledger.
>>>
>> We have 1000 topics.
>>
>>>
>>> For the disk, check the number of I/O transactions which are
>>> occurring. I don't think you can get it with dstat, but sar -b should
>>> give it to you. I suspect a lot of seeks are occurring.
>>>
>> Thanks for the tip. I'll do this the next time we run into such a
>> problem.
>>
>>>
>>> There's a couple of shortcomings in how bookie's serve reads which
>>> I've wanted to look at for a while, so this could be a good chance.
>>>
>> Could you give some information on what those shortcomings are? Also, do
>> let me know if you need any more information from our end.
>>
>>>
>>> -Ivan
>>>
>>>
>>>
>>> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
>>> > I'm logging latencies in the per channel bookie client by overriding
>>> the
>>> > read completion and add completion callbacks.
>>> >
>>> > When a hedwig subscriber subscribes to a topic and it hasn't consumed
>>> any
>>> > messages for a long time, it has to issue requests to bookkeeper to
>>> read
>>> > entries. We are observing very high latencies during these operations.
>>> >
>>> > throttle limit for the bookkeeper client is set at 5000. We are using
>>> the
>>> > Hierarchical ledger manager.
>>> >
>>> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
>>> > bookie server pageSize=32768, open file limit = 20000. I checked a few
>>> > bookies and the number of open ledgers was around 5000 on each.
>>> However,
>>> > the add and read latencies on the servers were less than 1 second
>>> (measured
>>> > using jconsole and the exposed jmx stats).
>>> >
>>> > Also, the bookie disks are standard spin drives and were doing about
>>> 40MBps
>>> > reads and 10MBps writes when measured with dstat. Any thoughts would be
>>> > helpful.
>>>
>>
>> Regards,
>> Aniruddha.
>>
>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
I ran sar while the bookies were showing high latencies. Pasting the output
below

disk with journal
Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
Average: dev8-16 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
Average: dev8-17 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89

Following disks store ledgers.

Average: dev8-32 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
Average: dev8-33 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59

Average: dev8-48 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
Average: dev8-49 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90

Average: dev8-64 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
Average: dev8-65 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66

Average: dev8-80 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
Average: dev8-81 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19

Regards,
Aniruddha.

On Fri, Sep 21, 2012 at 9:39 AM, Aniruddha Laud <tr...@gmail.com>wrote:

> Thanks Flavio and Ivan. Please find my replies inline.
>
> Flavio,
> Yes we are using trunk with only a few stats related modifications to
> bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
> checked using jconsole and I believe that is in ms. Our entries are small
> (Around 1KB) and we have a lot of entries in our ledgers (We see close to
> 20k publishes/second on our hedwig cluster)
>
> We have 15 bookie servers with an ensemble size of 4 and quorum of 3.
>
> On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:
>
>> What latency are you getting for the reads? Is the latency too high
>> for reading individual entries, or for reading a whole ledger?
>>
> The latency for reading individual entries is really high. In the order of
> seconds. This almost always occurs when a backed up subscriber is catching
> up and there are simultaneous publishes. There are around 15k-20k read
> entry requests per second across the 15 bookies (This is the sum of the
> PCBC requests per second) and around 10k add entry requests per second.
> From what I can tell, if there are only writes, the latencies are not high.
>
>>
>> Also, how many topics do you have in the system? The number of topics
>> will define the amount of interleaving in the ledger storage files
>> which has an affect on how long it will take to read entries from the
>> ledger.
>>
> We have 1000 topics.
>
>>
>> For the disk, check the number of I/O transactions which are
>> occurring. I don't think you can get it with dstat, but sar -b should
>> give it to you. I suspect a lot of seeks are occurring.
>>
> Thanks for the tip. I'll do this the next time we run into such a problem.
>
>
>>
>> There's a couple of shortcomings in how bookie's serve reads which
>> I've wanted to look at for a while, so this could be a good chance.
>>
> Could you give some information on what those shortcomings are? Also, do
> let me know if you need any more information from our end.
>
>>
>> -Ivan
>>
>>
>>
>> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
>> > I'm logging latencies in the per channel bookie client by overriding the
>> > read completion and add completion callbacks.
>> >
>> > When a hedwig subscriber subscribes to a topic and it hasn't consumed
>> any
>> > messages for a long time, it has to issue requests to bookkeeper to read
>> > entries. We are observing very high latencies during these operations.
>> >
>> > throttle limit for the bookkeeper client is set at 5000. We are using
>> the
>> > Hierarchical ledger manager.
>> >
>> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
>> > bookie server pageSize=32768, open file limit = 20000. I checked a few
>> > bookies and the number of open ledgers was around 5000 on each. However,
>> > the add and read latencies on the servers were less than 1 second
>> (measured
>> > using jconsole and the exposed jmx stats).
>> >
>> > Also, the bookie disks are standard spin drives and were doing about
>> 40MBps
>> > reads and 10MBps writes when measured with dstat. Any thoughts would be
>> > helpful.
>>
>
> Regards,
> Aniruddha.
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Stu Hood <st...@twitter.com>.
Additionally, in a blocking context, if a thread misses the page cache and
needs to go to the device itself, it might block other operations that
-are- in page cache... using more threads helps there, although it is not a
complete solution.

On Tue, Sep 25, 2012 at 3:33 PM, Stu Hood <st...@twitter.com> wrote:

> If with one thread we are getting pretty high latency (case Aniruddha
>> described), doesn't it mean we have a number of requests queued up?
>
> If you have 1 thread in the system and you're doing blocking IO, then the
> os/hardware can only possibly know about 1 IO operation at a time (because
> the 1 thread can't send the next operation while it is blocked waiting for
> the first operation.) If instead you have 16 threads issuing IO to one
> physical device, then there can be 16 outstanding IO operations at once.
>
> An "outstanding" IO operation might be queued a) in the kernel, via an IO
> scheduler [0], b) at a raid controller, c) in the device itself [1]. All of
> these layers implement reordering of operations: and the more queueing, the
> more chance to optimize access order.
>
> One of the simplest exposed metrics is '*avgqu-sz*', exposed by linux
> `iostat -x`: it is the average number of queued operations for a device.
>
> [0] for example, CFQ: http://en.wikipedia.org/wiki/CFQ
> [1] NCQ: http://en.wikipedia.org/wiki/Native_Command_Queuing
>
>
>
> On Tue, Sep 25, 2012 at 2:06 PM, Flavio Junqueira <fp...@yahoo-inc.com>wrote:
>
>> Hi Stu, I'm not sure I understand your point. If with one thread we are
>> getting pretty high latency (case Aniruddha described), doesn't it mean we
>> have a number of requests queued up? Adding more threads might only make
>> the problem worse by queueing up even more requests. I'm possibly missing
>> your point...
>>
>> -Flavio
>>
>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>>
>> > Separating by device would help, but will not allow the devices to be
>> fully
>> > utilized: in order to buffer enough io commands into a disk's queue for
>> the
>> > elevator algorithms to kick in, you either need to use multiple threads
>> per
>> > disk, or native async IO (not trivially available within the JVM.)
>> >
>> > On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> wrote:
>> >
>> >>
>> >> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>> >>
>> >>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> >> wrote:
>> >>>
>> >>>> Just to add a couple of comments to the discussion, separating reads
>> and
>> >>>> writes into different threads should only help with queuing latency.
>> It
>> >>>> wouldn't help with IO latency.
>> >>>>
>> >>>
>> >>> Yes, but with the current implementation, publishes latencies in
>> hedwig
>> >>> suffer because of lagging subscribers. By separating read and write
>> >> queues,
>> >>> we can at least guarantee that the write SLA is maintained (separate
>> >>> journal disk + separate thread would ensure that writes are not
>> affected
>> >> by
>> >>> read related seeks)
>> >>>
>> >>
>> >> Agreed and based on my comment below, I was wondering if it wouldn't be
>> >> best to separate traffic across threads by device instead of by
>> operation
>> >> type.
>> >>
>> >>
>> >>>>
>> >>>> Also, it sounds like a good idea to have at least one thread per
>> ledger
>> >>>> device. In the case of multiple ledger devices, if we use one single
>> >>>> thread, then the performance of the bookie will be driven by the
>> slowest
>> >>>> disk, no?
>> >>>>
>> >>> yup, makes sense.
>> >>>
>> >>>>
>> >>>> -Flavio
>> >>>>
>> >>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>> >>>>
>> >>>>>> Could you give some information on what those shortcomings are?
>> Also,
>> >> do
>> >>>>>> let me know if you need any more information from our end.
>> >>>>> Off the top of my head:
>> >>>>> - reads and writes are handled in the same thread (as you have
>> >> observed)
>> >>>>> - each entry read requires a single RPC.
>> >>>>> - entries are read in parallel
>> >>>>
>> >>> By parallel, you mean the BufferedChannel wrapper on top of
>> FileChannel,
>> >>> right?
>> >>>
>> >>>>>
>> >>>>> Not all of these could result in the high latency you see, but if
>> each
>> >>>>> entry is being read separately, a sync on the ledger disk in between
>> >>>>> will make a mess of the disk head scheduling.
>> >>>>
>> >>> Increasing the time interval between  flushing log files might
>> possibly
>> >>> help in this case then?
>> >>>
>> >>>>>
>> >>>>> -Ivan
>> >>>>
>> >>>>
>> >>> Thanks for the help :)
>> >>
>> >>
>>
>>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
This is an interesting observation overall. Most of our focus has been on the writes, which are mostly sequential. For sequential writes, I would think that introducing parallelism does not make sense. Parallelism is mostly beneficial when we have have random seeks, which we have upon reads to multiple ledgers. When read traffic increases and this traffic hits many ledgers, it sounds right that we need a good way to introduce parallelism so that we can improve the utilization of disk devices. 

If we are to use multiple threads to increase the degree of parallelism, I was wondering how many threads we would actually need. Any clue? Does it depend on the number of ledgers we are concurrently accessing?

-Flavio

On Sep 26, 2012, at 12:33 AM, Stu Hood wrote:

>> 
>> If with one thread we are getting pretty high latency (case Aniruddha
>> described), doesn't it mean we have a number of requests queued up?
> 
> If you have 1 thread in the system and you're doing blocking IO, then the
> os/hardware can only possibly know about 1 IO operation at a time (because
> the 1 thread can't send the next operation while it is blocked waiting for
> the first operation.) If instead you have 16 threads issuing IO to one
> physical device, then there can be 16 outstanding IO operations at once.
> 
> An "outstanding" IO operation might be queued a) in the kernel, via an IO
> scheduler [0], b) at a raid controller, c) in the device itself [1]. All of
> these layers implement reordering of operations: and the more queueing, the
> more chance to optimize access order.
> 
> One of the simplest exposed metrics is '*avgqu-sz*', exposed by linux
> `iostat -x`: it is the average number of queued operations for a device.
> 
> [0] for example, CFQ: http://en.wikipedia.org/wiki/CFQ
> [1] NCQ: http://en.wikipedia.org/wiki/Native_Command_Queuing
> 
> 
> 
> On Tue, Sep 25, 2012 at 2:06 PM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:
> 
>> Hi Stu, I'm not sure I understand your point. If with one thread we are
>> getting pretty high latency (case Aniruddha described), doesn't it mean we
>> have a number of requests queued up? Adding more threads might only make
>> the problem worse by queueing up even more requests. I'm possibly missing
>> your point...
>> 
>> -Flavio
>> 
>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>> 
>>> Separating by device would help, but will not allow the devices to be
>> fully
>>> utilized: in order to buffer enough io commands into a disk's queue for
>> the
>>> elevator algorithms to kick in, you either need to use multiple threads
>> per
>>> disk, or native async IO (not trivially available within the JVM.)
>>> 
>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> wrote:
>>> 
>>>> 
>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>>>> 
>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>>>> wrote:
>>>>> 
>>>>>> Just to add a couple of comments to the discussion, separating reads
>> and
>>>>>> writes into different threads should only help with queuing latency.
>> It
>>>>>> wouldn't help with IO latency.
>>>>>> 
>>>>> 
>>>>> Yes, but with the current implementation, publishes latencies in hedwig
>>>>> suffer because of lagging subscribers. By separating read and write
>>>> queues,
>>>>> we can at least guarantee that the write SLA is maintained (separate
>>>>> journal disk + separate thread would ensure that writes are not
>> affected
>>>> by
>>>>> read related seeks)
>>>>> 
>>>> 
>>>> Agreed and based on my comment below, I was wondering if it wouldn't be
>>>> best to separate traffic across threads by device instead of by
>> operation
>>>> type.
>>>> 
>>>> 
>>>>>> 
>>>>>> Also, it sounds like a good idea to have at least one thread per
>> ledger
>>>>>> device. In the case of multiple ledger devices, if we use one single
>>>>>> thread, then the performance of the bookie will be driven by the
>> slowest
>>>>>> disk, no?
>>>>>> 
>>>>> yup, makes sense.
>>>>> 
>>>>>> 
>>>>>> -Flavio
>>>>>> 
>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>>>>>> 
>>>>>>>> Could you give some information on what those shortcomings are?
>> Also,
>>>> do
>>>>>>>> let me know if you need any more information from our end.
>>>>>>> Off the top of my head:
>>>>>>> - reads and writes are handled in the same thread (as you have
>>>> observed)
>>>>>>> - each entry read requires a single RPC.
>>>>>>> - entries are read in parallel
>>>>>> 
>>>>> By parallel, you mean the BufferedChannel wrapper on top of
>> FileChannel,
>>>>> right?
>>>>> 
>>>>>>> 
>>>>>>> Not all of these could result in the high latency you see, but if
>> each
>>>>>>> entry is being read separately, a sync on the ledger disk in between
>>>>>>> will make a mess of the disk head scheduling.
>>>>>> 
>>>>> Increasing the time interval between  flushing log files might possibly
>>>>> help in this case then?
>>>>> 
>>>>>>> 
>>>>>>> -Ivan
>>>>>> 
>>>>>> 
>>>>> Thanks for the help :)
>>>> 
>>>> 
>> 
>> 


Re: High latencies observed at the bookkeeper client while reading entries

Posted by Stu Hood <st...@twitter.com>.
>
> If with one thread we are getting pretty high latency (case Aniruddha
> described), doesn't it mean we have a number of requests queued up?

If you have 1 thread in the system and you're doing blocking IO, then the
os/hardware can only possibly know about 1 IO operation at a time (because
the 1 thread can't send the next operation while it is blocked waiting for
the first operation.) If instead you have 16 threads issuing IO to one
physical device, then there can be 16 outstanding IO operations at once.

An "outstanding" IO operation might be queued a) in the kernel, via an IO
scheduler [0], b) at a raid controller, c) in the device itself [1]. All of
these layers implement reordering of operations: and the more queueing, the
more chance to optimize access order.

One of the simplest exposed metrics is '*avgqu-sz*', exposed by linux
`iostat -x`: it is the average number of queued operations for a device.

[0] for example, CFQ: http://en.wikipedia.org/wiki/CFQ
[1] NCQ: http://en.wikipedia.org/wiki/Native_Command_Queuing



On Tue, Sep 25, 2012 at 2:06 PM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:

> Hi Stu, I'm not sure I understand your point. If with one thread we are
> getting pretty high latency (case Aniruddha described), doesn't it mean we
> have a number of requests queued up? Adding more threads might only make
> the problem worse by queueing up even more requests. I'm possibly missing
> your point...
>
> -Flavio
>
> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>
> > Separating by device would help, but will not allow the devices to be
> fully
> > utilized: in order to buffer enough io commands into a disk's queue for
> the
> > elevator algorithms to kick in, you either need to use multiple threads
> per
> > disk, or native async IO (not trivially available within the JVM.)
> >
> > On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
> wrote:
> >
> >>
> >> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> >>
> >>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
> >> wrote:
> >>>
> >>>> Just to add a couple of comments to the discussion, separating reads
> and
> >>>> writes into different threads should only help with queuing latency.
> It
> >>>> wouldn't help with IO latency.
> >>>>
> >>>
> >>> Yes, but with the current implementation, publishes latencies in hedwig
> >>> suffer because of lagging subscribers. By separating read and write
> >> queues,
> >>> we can at least guarantee that the write SLA is maintained (separate
> >>> journal disk + separate thread would ensure that writes are not
> affected
> >> by
> >>> read related seeks)
> >>>
> >>
> >> Agreed and based on my comment below, I was wondering if it wouldn't be
> >> best to separate traffic across threads by device instead of by
> operation
> >> type.
> >>
> >>
> >>>>
> >>>> Also, it sounds like a good idea to have at least one thread per
> ledger
> >>>> device. In the case of multiple ledger devices, if we use one single
> >>>> thread, then the performance of the bookie will be driven by the
> slowest
> >>>> disk, no?
> >>>>
> >>> yup, makes sense.
> >>>
> >>>>
> >>>> -Flavio
> >>>>
> >>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> >>>>
> >>>>>> Could you give some information on what those shortcomings are?
> Also,
> >> do
> >>>>>> let me know if you need any more information from our end.
> >>>>> Off the top of my head:
> >>>>> - reads and writes are handled in the same thread (as you have
> >> observed)
> >>>>> - each entry read requires a single RPC.
> >>>>> - entries are read in parallel
> >>>>
> >>> By parallel, you mean the BufferedChannel wrapper on top of
> FileChannel,
> >>> right?
> >>>
> >>>>>
> >>>>> Not all of these could result in the high latency you see, but if
> each
> >>>>> entry is being read separately, a sync on the ledger disk in between
> >>>>> will make a mess of the disk head scheduling.
> >>>>
> >>> Increasing the time interval between  flushing log files might possibly
> >>> help in this case then?
> >>>
> >>>>>
> >>>>> -Ivan
> >>>>
> >>>>
> >>> Thanks for the help :)
> >>
> >>
>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
On Thu, Sep 27, 2012 at 3:16 AM, Ivan Kelly <iv...@apache.org> wrote:

> > I took at look at the leveldb homepage and it says - "Only a single
> process
> > (possibly multi-threaded) can access a particular database at a time."
> > This is bad because it means we can't run the console or any recovery
> > related operations while the bookies are running. I may be wrong, though.
> > What I had in mind was pretty simple. When we flush to the log file, we
> > should simply flush entries sorted by the ledger id as key. Some changes
> > might be needed to the ledger index cache, but I'm not very sure what the
> > changes would be. What do you think?
> This should be a fairly straightforward change to make, but would
> require a bit of hacking around in the EntryLogger. Currently, when we
> write to the entrylogger we write to the file handle and return, and
> then the sync thread forces this to disk when it runs. Everything is
> in OS buffers up until the sync. To do this sorting, we would need to
> keep our own buffers and then both write to the channel _and_ force to
> disk during the sync.
>
Yes, that is exactly what I had in mind.

>
> We could also cut down the amount of data we need to write to the
> index files with this, we really only need to store the first entry
> for the particular ledger in the that sync window, rather than an
> index for every single entry.
>
Agreed.

>
> -Ivan
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Ivan Kelly <iv...@apache.org>.
> I took at look at the leveldb homepage and it says - "Only a single process
> (possibly multi-threaded) can access a particular database at a time."
> This is bad because it means we can't run the console or any recovery
> related operations while the bookies are running. I may be wrong, though.
> What I had in mind was pretty simple. When we flush to the log file, we
> should simply flush entries sorted by the ledger id as key. Some changes
> might be needed to the ledger index cache, but I'm not very sure what the
> changes would be. What do you think?
This should be a fairly straightforward change to make, but would
require a bit of hacking around in the EntryLogger. Currently, when we
write to the entrylogger we write to the file handle and return, and
then the sync thread forces this to disk when it runs. Everything is
in OS buffers up until the sync. To do this sorting, we would need to
keep our own buffers and then both write to the channel _and_ force to
disk during the sync. 

We could also cut down the amount of data we need to write to the
index files with this, we really only need to store the first entry
for the particular ledger in the that sync window, rather than an
index for every single entry.

-Ivan

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Ivan Kelly <iv...@apache.org>.
On Thu, Sep 27, 2012 at 06:21:33PM +0800, Sijie Guo wrote:
> > I took at look at the leveldb homepage and it says - "Only a single
> process
> > (possibly multi-threaded) can access a particular database at a time."
> > This is bad because it means we can't run the console or any recovery
> > related operations while the bookies are running.
> 
> Yes. leveldb is single process. it prevent misuse by acquiring lock from
> filesystem. We did can't run the console to look its data while the bookie
> is running.
Is this write access or read access? Recovery should only need read
access

> 
> I am confusing about the 'recovery' operations you mentioned. what kind of
> recovery?
> 
> > When we flush to the log file, we
> > should simply flush entries sorted by the ledger id as key.
> 
> If we want to sort when flushing, we need to buffer all edits in memory,
> then flush. I am assume this approach would act same as LSM tree (what
> leveldb did).
Similar, but without the compaction.

-Ivan

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
I don't understand if it is expected that the devices are idle while we have a number of requests queued. Not being able to leverage the optimizations the disk device implement doesn't mean that devices should be idle, it simply means that that we not giving choices to the devices to select from. If we have enough requests on the bookie side, I would expect devices to be fully utilized, but perhaps not efficiently utilized.

-Flavio 

On Sep 26, 2012, at 2:06 AM, Sijie Guo wrote:

> For serving requests, either queuing the requests in bookie server per
> channel (write/read are blocking operations), or queueing in os kernel to
> let block device queuing and schedule those io requests. I think Stu's
> point is to leverage block device's schedule algorithm to issue io requests
> in multiple threads to fully utilize the disk bandwidth.
> 
> from the iostat reports provided by Aniruddha, the average queue length and
> utilized percentage are not high, which means most of time the disks are
> idle. It makes sense to use multiple threads to issue read requests. one
> write thread and several read threads might work for each device.
> 
> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:
> 
>> Hi Stu, I'm not sure I understand your point. If with one thread we are
>> getting pretty high latency (case Aniruddha described), doesn't it mean we
>> have a number of requests queued up? Adding more threads might only make
>> the problem worse by queueing up even more requests. I'm possibly missing
>> your point...
>> 
>> -Flavio
>> 
>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>> 
>>> Separating by device would help, but will not allow the devices to be
>> fully
>>> utilized: in order to buffer enough io commands into a disk's queue for
>> the
>>> elevator algorithms to kick in, you either need to use multiple threads
>> per
>>> disk, or native async IO (not trivially available within the JVM.)
>>> 
>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> wrote:
>>> 
>>>> 
>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>>>> 
>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>>>> wrote:
>>>>> 
>>>>>> Just to add a couple of comments to the discussion, separating reads
>> and
>>>>>> writes into different threads should only help with queuing latency.
>> It
>>>>>> wouldn't help with IO latency.
>>>>>> 
>>>>> 
>>>>> Yes, but with the current implementation, publishes latencies in hedwig
>>>>> suffer because of lagging subscribers. By separating read and write
>>>> queues,
>>>>> we can at least guarantee that the write SLA is maintained (separate
>>>>> journal disk + separate thread would ensure that writes are not
>> affected
>>>> by
>>>>> read related seeks)
>>>>> 
>>>> 
>>>> Agreed and based on my comment below, I was wondering if it wouldn't be
>>>> best to separate traffic across threads by device instead of by
>> operation
>>>> type.
>>>> 
>>>> 
>>>>>> 
>>>>>> Also, it sounds like a good idea to have at least one thread per
>> ledger
>>>>>> device. In the case of multiple ledger devices, if we use one single
>>>>>> thread, then the performance of the bookie will be driven by the
>> slowest
>>>>>> disk, no?
>>>>>> 
>>>>> yup, makes sense.
>>>>> 
>>>>>> 
>>>>>> -Flavio
>>>>>> 
>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>>>>>> 
>>>>>>>> Could you give some information on what those shortcomings are?
>> Also,
>>>> do
>>>>>>>> let me know if you need any more information from our end.
>>>>>>> Off the top of my head:
>>>>>>> - reads and writes are handled in the same thread (as you have
>>>> observed)
>>>>>>> - each entry read requires a single RPC.
>>>>>>> - entries are read in parallel
>>>>>> 
>>>>> By parallel, you mean the BufferedChannel wrapper on top of
>> FileChannel,
>>>>> right?
>>>>> 
>>>>>>> 
>>>>>>> Not all of these could result in the high latency you see, but if
>> each
>>>>>>> entry is being read separately, a sync on the ledger disk in between
>>>>>>> will make a mess of the disk head scheduling.
>>>>>> 
>>>>> Increasing the time interval between  flushing log files might possibly
>>>>> help in this case then?
>>>>> 
>>>>>>> 
>>>>>>> -Ivan
>>>>>> 
>>>>>> 
>>>>> Thanks for the help :)
>>>> 
>>>> 
>> 
>> 


Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
I've created https://issues.apache.org/jira/browse/BOOKKEEPER-429 for
tracking the multiple threads patch without any entry reordering. I'm going
to open another ticket that addresses entry reordering. I'll upload the
patch by EOD today.

Regards,
Aniruddha.

On Tue, Oct 9, 2012 at 12:04 AM, Sijie Guo <gu...@gmail.com> wrote:

> > I was talking about BookkeeperAdmin and how it's used from
> BookkeeperTools.
> > I believe that we currently only support replicating a bookie onto
> another
> > bookie.
>
> BookKeeperAdmin doesn't access the data files directly to replicate
> entries. It interacted with alive bookie servers to replicate entries that
> belong to dead bookie.  So at most of the time, only bookie server access
> the data files.
>
> The only exception is that when you ran a bookie shell to look into the
> details of entry log files or journals, it ran as a separated process in
> read-only mode.
>
>
> On Fri, Sep 28, 2012 at 12:54 AM, Aniruddha Laud
> <tr...@gmail.com>wrote:
>
> > On Thu, Sep 27, 2012 at 3:21 AM, Sijie Guo <gu...@gmail.com> wrote:
> >
> > > > I took at look at the leveldb homepage and it says - "Only a single
> > > process
> > > > (possibly multi-threaded) can access a particular database at a
> time."
> > > > This is bad because it means we can't run the console or any recovery
> > > > related operations while the bookies are running.
> > >
> > > Yes. leveldb is single process. it prevent misuse by acquiring lock
> from
> > > filesystem. We did can't run the console to look its data while the
> > bookie
> > > is running.
> > >
> > > I am confusing about the 'recovery' operations you mentioned. what kind
> > of
> > > recovery?
> > >
> > I was talking about BookkeeperAdmin and how it's used from
> BookkeeperTools.
> > I believe that we currently only support replicating a bookie onto
> another
> > bookie. We might want to support more operations of this nature in
> future.
> > These might need simultaneous access to the log files of a live bookie.
> >
> > >
> > > > When we flush to the log file, we
> > > > should simply flush entries sorted by the ledger id as key.
> > >
> > > If we want to sort when flushing, we need to buffer all edits in
> memory,
> > > then flush. I am assume this approach would act same as LSM tree (what
> > > leveldb did).
> > >
> > Yes. quite similar. I just glanced over LSM trees, I'll take a more
> > detailed look soon.
> >
> > >
> > > On Thu, Sep 27, 2012 at 9:39 AM, Aniruddha Laud <
> > trojan.of.troy@gmail.com
> > > >wrote:
> > >
> > > > On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com>
> wrote:
> > > >
> > > > > Sounds good to have thread pool (and make them configurable) for
> > > reading
> > > > > from entry log files.
> > > > >
> > > > > > We can have a write threadpool (and we should always keep this
> > > > > lower than the number of processors) to process the add requests.
> > > > >
> > > > > one more point, since we had only one entry log file active
> accepting
> > > > entry
> > > > > written to it. I don't think multiple write threads would help now,
> > > since
> > > > > adding entry to entry log file is synchronized method.
> > > > >
> > > > I was talking about writing to the journal file. From what I
> > understand,
> > > > log file entries
> > > > are flushed periodically by one thread and that is okay. The publish
> > > > latencies on hedwig are
> > > > dependent on the journal writes, though.
> > > >
> > > > >
> > > > > In order to utilize the disk bandwidth more efficiently, we might
> > need
> > > to
> > > > > have one active entry log file accepting entry written per ledger
> > disk.
> > > > But
> > > > > it might need to introduce some directory layout change (like
> logId,
> > > > > currently we using incrementing log id for whole bookie) and logic
> > > > > changes.  it would be a separated task if did that.
> > > > >
> > > > > > Another thing we could possibly look at is re ordering our writes
> > to
> > > > the
> > > > > log file to try and maintain locality for ledger entries.
> > > > >
> > > > > We had a prototype work internally working on using leveldb to
> store
> > 1)
> > > > > small entries data (size less than hundred of bytes), 2) ledger
> index
> > > for
> > > > > large entries (acts as ledger cache for index entries). Benefiting
> > from
> > > > > leveldb, 1) we could have more efficient cache when there are
> larger
> > > > number
> > > > > of ledgers and size skew between ledgers, 2) we could have data
> > > belonging
> > > > > to same ledger clustered when writing to disks, which achieves what
> > you
> > > > > mentioned 'reordering writes' in somehow.
> > > > >
> > > > I took at look at the leveldb homepage and it says - "Only a single
> > > process
> > > > (possibly multi-threaded) can access a particular database at a
> time."
> > > > This is bad because it means we can't run the console or any recovery
> > > > related operations while the bookies are running. I may be wrong,
> > though.
> > > > What I had in mind was pretty simple. When we flush to the log file,
> we
> > > > should simply flush entries sorted by the ledger id as key. Some
> > changes
> > > > might be needed to the ledger index cache, but I'm not very sure what
> > the
> > > > changes would be. What do you think?
> > > >
> > > > >
> > > > > -Sijie
> > > > >
> > > > > On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
> > > > > <tr...@gmail.com>wrote:
> > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > Those stats I pasted might be a little misleading as they show
> the
> > > > > average
> > > > > > over a couple of minutes. Whenever there are reads to the ledger
> > > disks,
> > > > > the
> > > > > > queue size on them is sometimes as high as 100. Also, the CPU
> > > > utilization
> > > > > > has been lower than 10% throughout and the process will continue
> to
> > > > > remain
> > > > > > I/O bound even if we introduce more threads (As the CPU remains
> > idle
> > > > > while
> > > > > > doing I/O).
> > > > > >
> > > > > > A couple of observations about the write path. We currently have
> a
> > > hard
> > > > > > coded buffer size for journal writes (I believe it's 512KB) and
> we
> > > > flush
> > > > > to
> > > > > > the disk when this fills up or if there is no entry to process
> > (which
> > > > is
> > > > > > highly unlikely in case of a high throughput application running
> on
> > > > top).
> > > > > > We should make this buffer size configurable. Now, with more
> > threads,
> > > > we
> > > > > > can process more packets in parallel and this buffer can be
> filled
> > up
> > > > > > faster. We can have a write threadpool (and we should always keep
> > > this
> > > > > > lower than the number of processors) to process the add requests.
> > > > > >
> > > > > > For read requests, a configurable number of worker threads would
> be
> > > > ideal
> > > > > > and we could let the user tune it depending on the kind of read
> > > > patterns
> > > > > > they expect. Given that ledgers are interleaved ATM, I would
> expect
> > > the
> > > > > > performance to increase linearly with the number of threads till
> a
> > > > > certain
> > > > > > point and then level out.
> > > > > >
> > > > > > Another thing we could possibly look at is re ordering our writes
> > to
> > > > the
> > > > > > log file to try and maintain locality for ledger entries. This
> > might
> > > > > reduce
> > > > > > the number of random seeks we do in case only a small number of
> > > ledgers
> > > > > are
> > > > > > lagging.
> > > > > >
> > > > > > Thoughts?
> > > > > >
> > > > > > Regards,
> > > > > > Aniruddha.
> > > > > >
> > > > > > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com>
> > > wrote:
> > > > > >
> > > > > > > >>>One question: what is multi-ledgers?
> > > > > > > multiple ledgers directories(muliple disks)
> > > > > > >
> > > > > > > >>>CPU utilization might not be largely affected if the threads
> > are
> > > > > > > sitting there waiting on IO
> > > > > > > Ok, seems I got it.
> > > > > > > If one thread spends most of its time waiting for I/O
> completion
> > > > > instead
> > > > > > > of using the CPU, but does not mean that "we've hit the system
> > I/O
> > > > > > > bandwidth limit", then IMHO having multiple threads (or
> > > asynchronous
> > > > > I/O)
> > > > > > > might improve performance (by enabling more than one concurrent
> > I/O
> > > > > > > operation).
> > > > > > >
> > > > > > > -Rakesh
> > > > > > > ________________________________________
> > > > > > > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > > > > > > Sent: Wednesday, September 26, 2012 2:17 PM
> > > > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > > > Subject: Re: High latencies observed at the bookkeeper client
> > while
> > > > > > > reading entries
> > > > > > >
> > > > > > > CPU utilization might not be largely affected if the threads
> are
> > > > > sitting
> > > > > > > there waiting on IO. In my understanding of the proposal so
> far,
> > > the
> > > > > idea
> > > > > > > is to have multiple threads only to perform IO.
> > > > > > >
> > > > > > > One question: what is multi-ledgers?
> > > > > > >
> > > > > > > -Flavio
> > > > > > >
> > > > > > >
> > > > > > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> > > > > > >
> > > > > > > > I just adding one more point:
> > > > > > > >
> > > > > > > > Increasing the number of threads, can hit the CPU utilization
> > > too.
> > > > > > Also,
> > > > > > > we would consider this and good to observe whether its more on
> > I/O
> > > > > bound
> > > > > > > than CPU bound. However, it depends in great detail on the
> disks
> > > and
> > > > > how
> > > > > > > much CPU work other threads are doing before they, too, end up
> > > > waiting
> > > > > on
> > > > > > > those disks.
> > > > > > > >
> > > > > > > > I'm also thinking inline with Flavio's suggestion to have one
> > > > thread
> > > > > > per
> > > > > > > ledger/journal device. Multithreading can help us with I/O
> bound
> > > > > problems
> > > > > > > if the I/O is perform against different disks.
> > > > > > > >
> > > > > > > > From the iostat report: waiting time of ledger directories.
> It
> > > > shows
> > > > > we
> > > > > > > have options to fully utilizing the disk bandwidth.
> > > > > > > >
> > > > > > > > multi-ledgers disk usage:
> > > > > > > > avgqu-sz
> > > > > > > > 1.10
> > > > > > > > 0.12
> > > > > > > > 0.54
> > > > > > > > 0.13
> > > > > > > >
> > > > > > > > -Rakesh
> > > > > > > > ________________________________________
> > > > > > > > From: Sijie Guo [guosijie@gmail.com]
> > > > > > > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > > > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > > > > Subject: Re: High latencies observed at the bookkeeper client
> > > while
> > > > > > > reading entries
> > > > > > > >
> > > > > > > > One more point is that each write/read request to entry log
> > files
> > > > > would
> > > > > > > be
> > > > > > > > converted to write/read a 8K blob data, since you used
> > > > > BufferedChannel.
> > > > > > > For
> > > > > > > > write requests, a larger write size is OK. For read requests,
> > > they
> > > > > are
> > > > > > > > almost randomly. Even you read a larger blob, the blob might
> be
> > > > > useless
> > > > > > > > when next read goes to other place. Even more, I don't think
> we
> > > > need
> > > > > to
> > > > > > > > maintain another fixed length readBuffer in BufferedChannel,
> it
> > > > > almost
> > > > > > > > doesn't help for random reads, we could leverage OS cache for
> > it.
> > > > > > > >
> > > > > > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <
> guosijie@gmail.com
> > >
> > > > > wrote:
> > > > > > > >
> > > > > > > >> For serving requests, either queuing the requests in bookie
> > > server
> > > > > per
> > > > > > > >> channel (write/read are blocking operations), or queueing in
> > os
> > > > > kernel
> > > > > > > to
> > > > > > > >> let block device queuing and schedule those io requests. I
> > think
> > > > > Stu's
> > > > > > > >> point is to leverage block device's schedule algorithm to
> > issue
> > > io
> > > > > > > requests
> > > > > > > >> in multiple threads to fully utilize the disk bandwidth.
> > > > > > > >>
> > > > > > > >> from the iostat reports provided by Aniruddha, the average
> > queue
> > > > > > length
> > > > > > > >> and utilized percentage are not high, which means most of
> time
> > > the
> > > > > > disks
> > > > > > > >> are idle. It makes sense to use multiple threads to issue
> read
> > > > > > requests.
> > > > > > > >> one write thread and several read threads might work for
> each
> > > > > device.
> > > > > > > >>
> > > > > > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
> > > > > fpj@yahoo-inc.com
> > > > > > > >wrote:
> > > > > > > >>
> > > > > > > >>> Hi Stu, I'm not sure I understand your point. If with one
> > > thread
> > > > we
> > > > > > are
> > > > > > > >>> getting pretty high latency (case Aniruddha described),
> > doesn't
> > > > it
> > > > > > > mean we
> > > > > > > >>> have a number of requests queued up? Adding more threads
> > might
> > > > only
> > > > > > > make
> > > > > > > >>> the problem worse by queueing up even more requests. I'm
> > > possibly
> > > > > > > missing
> > > > > > > >>> your point...
> > > > > > > >>>
> > > > > > > >>> -Flavio
> > > > > > > >>>
> > > > > > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > > > > > > >>>
> > > > > > > >>>> Separating by device would help, but will not allow the
> > > devices
> > > > to
> > > > > > be
> > > > > > > >>> fully
> > > > > > > >>>> utilized: in order to buffer enough io commands into a
> > disk's
> > > > > queue
> > > > > > > for
> > > > > > > >>> the
> > > > > > > >>>> elevator algorithms to kick in, you either need to use
> > > multiple
> > > > > > > threads
> > > > > > > >>> per
> > > > > > > >>>> disk, or native async IO (not trivially available within
> the
> > > > JVM.)
> > > > > > > >>>>
> > > > > > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> > > > > > fpj@yahoo-inc.com>
> > > > > > > >>> wrote:
> > > > > > > >>>>
> > > > > > > >>>>>
> > > > > > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > > > > > > >>>>>
> > > > > > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > > > > > > fpj@yahoo-inc.com>
> > > > > > > >>>>> wrote:
> > > > > > > >>>>>>
> > > > > > > >>>>>>> Just to add a couple of comments to the discussion,
> > > > separating
> > > > > > > reads
> > > > > > > >>> and
> > > > > > > >>>>>>> writes into different threads should only help with
> > queuing
> > > > > > > latency.
> > > > > > > >>> It
> > > > > > > >>>>>>> wouldn't help with IO latency.
> > > > > > > >>>>>>>
> > > > > > > >>>>>>
> > > > > > > >>>>>> Yes, but with the current implementation, publishes
> > > latencies
> > > > in
> > > > > > > >>> hedwig
> > > > > > > >>>>>> suffer because of lagging subscribers. By separating
> read
> > > and
> > > > > > write
> > > > > > > >>>>> queues,
> > > > > > > >>>>>> we can at least guarantee that the write SLA is
> maintained
> > > > > > (separate
> > > > > > > >>>>>> journal disk + separate thread would ensure that writes
> > are
> > > > not
> > > > > > > >>> affected
> > > > > > > >>>>> by
> > > > > > > >>>>>> read related seeks)
> > > > > > > >>>>>>
> > > > > > > >>>>>
> > > > > > > >>>>> Agreed and based on my comment below, I was wondering if
> it
> > > > > > wouldn't
> > > > > > > be
> > > > > > > >>>>> best to separate traffic across threads by device instead
> > of
> > > by
> > > > > > > >>> operation
> > > > > > > >>>>> type.
> > > > > > > >>>>>
> > > > > > > >>>>>
> > > > > > > >>>>>>>
> > > > > > > >>>>>>> Also, it sounds like a good idea to have at least one
> > > thread
> > > > > per
> > > > > > > >>> ledger
> > > > > > > >>>>>>> device. In the case of multiple ledger devices, if we
> use
> > > one
> > > > > > > single
> > > > > > > >>>>>>> thread, then the performance of the bookie will be
> driven
> > > by
> > > > > the
> > > > > > > >>> slowest
> > > > > > > >>>>>>> disk, no?
> > > > > > > >>>>>>>
> > > > > > > >>>>>> yup, makes sense.
> > > > > > > >>>>>>
> > > > > > > >>>>>>>
> > > > > > > >>>>>>> -Flavio
> > > > > > > >>>>>>>
> > > > > > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > > > > > > >>>>>>>
> > > > > > > >>>>>>>>> Could you give some information on what those
> > > shortcomings
> > > > > are?
> > > > > > > >>> Also,
> > > > > > > >>>>> do
> > > > > > > >>>>>>>>> let me know if you need any more information from our
> > > end.
> > > > > > > >>>>>>>> Off the top of my head:
> > > > > > > >>>>>>>> - reads and writes are handled in the same thread (as
> > you
> > > > have
> > > > > > > >>>>> observed)
> > > > > > > >>>>>>>> - each entry read requires a single RPC.
> > > > > > > >>>>>>>> - entries are read in parallel
> > > > > > > >>>>>>>
> > > > > > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top
> > of
> > > > > > > >>> FileChannel,
> > > > > > > >>>>>> right?
> > > > > > > >>>>>>
> > > > > > > >>>>>>>>
> > > > > > > >>>>>>>> Not all of these could result in the high latency you
> > see,
> > > > but
> > > > > > if
> > > > > > > >>> each
> > > > > > > >>>>>>>> entry is being read separately, a sync on the ledger
> > disk
> > > in
> > > > > > > between
> > > > > > > >>>>>>>> will make a mess of the disk head scheduling.
> > > > > > > >>>>>>>
> > > > > > > >>>>>> Increasing the time interval between  flushing log files
> > > might
> > > > > > > >>> possibly
> > > > > > > >>>>>> help in this case then?
> > > > > > > >>>>>>
> > > > > > > >>>>>>>>
> > > > > > > >>>>>>>> -Ivan
> > > > > > > >>>>>>>
> > > > > > > >>>>>>>
> > > > > > > >>>>>> Thanks for the help :)
> > > > > > > >>>>>
> > > > > > > >>>>>
> > > > > > > >>>
> > > > > > > >>>
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
> I was talking about BookkeeperAdmin and how it's used from
BookkeeperTools.
> I believe that we currently only support replicating a bookie onto another
> bookie.

BookKeeperAdmin doesn't access the data files directly to replicate
entries. It interacted with alive bookie servers to replicate entries that
belong to dead bookie.  So at most of the time, only bookie server access
the data files.

The only exception is that when you ran a bookie shell to look into the
details of entry log files or journals, it ran as a separated process in
read-only mode.


On Fri, Sep 28, 2012 at 12:54 AM, Aniruddha Laud
<tr...@gmail.com>wrote:

> On Thu, Sep 27, 2012 at 3:21 AM, Sijie Guo <gu...@gmail.com> wrote:
>
> > > I took at look at the leveldb homepage and it says - "Only a single
> > process
> > > (possibly multi-threaded) can access a particular database at a time."
> > > This is bad because it means we can't run the console or any recovery
> > > related operations while the bookies are running.
> >
> > Yes. leveldb is single process. it prevent misuse by acquiring lock from
> > filesystem. We did can't run the console to look its data while the
> bookie
> > is running.
> >
> > I am confusing about the 'recovery' operations you mentioned. what kind
> of
> > recovery?
> >
> I was talking about BookkeeperAdmin and how it's used from BookkeeperTools.
> I believe that we currently only support replicating a bookie onto another
> bookie. We might want to support more operations of this nature in future.
> These might need simultaneous access to the log files of a live bookie.
>
> >
> > > When we flush to the log file, we
> > > should simply flush entries sorted by the ledger id as key.
> >
> > If we want to sort when flushing, we need to buffer all edits in memory,
> > then flush. I am assume this approach would act same as LSM tree (what
> > leveldb did).
> >
> Yes. quite similar. I just glanced over LSM trees, I'll take a more
> detailed look soon.
>
> >
> > On Thu, Sep 27, 2012 at 9:39 AM, Aniruddha Laud <
> trojan.of.troy@gmail.com
> > >wrote:
> >
> > > On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com> wrote:
> > >
> > > > Sounds good to have thread pool (and make them configurable) for
> > reading
> > > > from entry log files.
> > > >
> > > > > We can have a write threadpool (and we should always keep this
> > > > lower than the number of processors) to process the add requests.
> > > >
> > > > one more point, since we had only one entry log file active accepting
> > > entry
> > > > written to it. I don't think multiple write threads would help now,
> > since
> > > > adding entry to entry log file is synchronized method.
> > > >
> > > I was talking about writing to the journal file. From what I
> understand,
> > > log file entries
> > > are flushed periodically by one thread and that is okay. The publish
> > > latencies on hedwig are
> > > dependent on the journal writes, though.
> > >
> > > >
> > > > In order to utilize the disk bandwidth more efficiently, we might
> need
> > to
> > > > have one active entry log file accepting entry written per ledger
> disk.
> > > But
> > > > it might need to introduce some directory layout change (like logId,
> > > > currently we using incrementing log id for whole bookie) and logic
> > > > changes.  it would be a separated task if did that.
> > > >
> > > > > Another thing we could possibly look at is re ordering our writes
> to
> > > the
> > > > log file to try and maintain locality for ledger entries.
> > > >
> > > > We had a prototype work internally working on using leveldb to store
> 1)
> > > > small entries data (size less than hundred of bytes), 2) ledger index
> > for
> > > > large entries (acts as ledger cache for index entries). Benefiting
> from
> > > > leveldb, 1) we could have more efficient cache when there are larger
> > > number
> > > > of ledgers and size skew between ledgers, 2) we could have data
> > belonging
> > > > to same ledger clustered when writing to disks, which achieves what
> you
> > > > mentioned 'reordering writes' in somehow.
> > > >
> > > I took at look at the leveldb homepage and it says - "Only a single
> > process
> > > (possibly multi-threaded) can access a particular database at a time."
> > > This is bad because it means we can't run the console or any recovery
> > > related operations while the bookies are running. I may be wrong,
> though.
> > > What I had in mind was pretty simple. When we flush to the log file, we
> > > should simply flush entries sorted by the ledger id as key. Some
> changes
> > > might be needed to the ledger index cache, but I'm not very sure what
> the
> > > changes would be. What do you think?
> > >
> > > >
> > > > -Sijie
> > > >
> > > > On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
> > > > <tr...@gmail.com>wrote:
> > > >
> > > > > Hi all,
> > > > >
> > > > > Those stats I pasted might be a little misleading as they show the
> > > > average
> > > > > over a couple of minutes. Whenever there are reads to the ledger
> > disks,
> > > > the
> > > > > queue size on them is sometimes as high as 100. Also, the CPU
> > > utilization
> > > > > has been lower than 10% throughout and the process will continue to
> > > > remain
> > > > > I/O bound even if we introduce more threads (As the CPU remains
> idle
> > > > while
> > > > > doing I/O).
> > > > >
> > > > > A couple of observations about the write path. We currently have a
> > hard
> > > > > coded buffer size for journal writes (I believe it's 512KB) and we
> > > flush
> > > > to
> > > > > the disk when this fills up or if there is no entry to process
> (which
> > > is
> > > > > highly unlikely in case of a high throughput application running on
> > > top).
> > > > > We should make this buffer size configurable. Now, with more
> threads,
> > > we
> > > > > can process more packets in parallel and this buffer can be filled
> up
> > > > > faster. We can have a write threadpool (and we should always keep
> > this
> > > > > lower than the number of processors) to process the add requests.
> > > > >
> > > > > For read requests, a configurable number of worker threads would be
> > > ideal
> > > > > and we could let the user tune it depending on the kind of read
> > > patterns
> > > > > they expect. Given that ledgers are interleaved ATM, I would expect
> > the
> > > > > performance to increase linearly with the number of threads till a
> > > > certain
> > > > > point and then level out.
> > > > >
> > > > > Another thing we could possibly look at is re ordering our writes
> to
> > > the
> > > > > log file to try and maintain locality for ledger entries. This
> might
> > > > reduce
> > > > > the number of random seeks we do in case only a small number of
> > ledgers
> > > > are
> > > > > lagging.
> > > > >
> > > > > Thoughts?
> > > > >
> > > > > Regards,
> > > > > Aniruddha.
> > > > >
> > > > > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com>
> > wrote:
> > > > >
> > > > > > >>>One question: what is multi-ledgers?
> > > > > > multiple ledgers directories(muliple disks)
> > > > > >
> > > > > > >>>CPU utilization might not be largely affected if the threads
> are
> > > > > > sitting there waiting on IO
> > > > > > Ok, seems I got it.
> > > > > > If one thread spends most of its time waiting for I/O completion
> > > > instead
> > > > > > of using the CPU, but does not mean that "we've hit the system
> I/O
> > > > > > bandwidth limit", then IMHO having multiple threads (or
> > asynchronous
> > > > I/O)
> > > > > > might improve performance (by enabling more than one concurrent
> I/O
> > > > > > operation).
> > > > > >
> > > > > > -Rakesh
> > > > > > ________________________________________
> > > > > > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > > > > > Sent: Wednesday, September 26, 2012 2:17 PM
> > > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > > Subject: Re: High latencies observed at the bookkeeper client
> while
> > > > > > reading entries
> > > > > >
> > > > > > CPU utilization might not be largely affected if the threads are
> > > > sitting
> > > > > > there waiting on IO. In my understanding of the proposal so far,
> > the
> > > > idea
> > > > > > is to have multiple threads only to perform IO.
> > > > > >
> > > > > > One question: what is multi-ledgers?
> > > > > >
> > > > > > -Flavio
> > > > > >
> > > > > >
> > > > > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> > > > > >
> > > > > > > I just adding one more point:
> > > > > > >
> > > > > > > Increasing the number of threads, can hit the CPU utilization
> > too.
> > > > > Also,
> > > > > > we would consider this and good to observe whether its more on
> I/O
> > > > bound
> > > > > > than CPU bound. However, it depends in great detail on the disks
> > and
> > > > how
> > > > > > much CPU work other threads are doing before they, too, end up
> > > waiting
> > > > on
> > > > > > those disks.
> > > > > > >
> > > > > > > I'm also thinking inline with Flavio's suggestion to have one
> > > thread
> > > > > per
> > > > > > ledger/journal device. Multithreading can help us with I/O bound
> > > > problems
> > > > > > if the I/O is perform against different disks.
> > > > > > >
> > > > > > > From the iostat report: waiting time of ledger directories. It
> > > shows
> > > > we
> > > > > > have options to fully utilizing the disk bandwidth.
> > > > > > >
> > > > > > > multi-ledgers disk usage:
> > > > > > > avgqu-sz
> > > > > > > 1.10
> > > > > > > 0.12
> > > > > > > 0.54
> > > > > > > 0.13
> > > > > > >
> > > > > > > -Rakesh
> > > > > > > ________________________________________
> > > > > > > From: Sijie Guo [guosijie@gmail.com]
> > > > > > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > > > Subject: Re: High latencies observed at the bookkeeper client
> > while
> > > > > > reading entries
> > > > > > >
> > > > > > > One more point is that each write/read request to entry log
> files
> > > > would
> > > > > > be
> > > > > > > converted to write/read a 8K blob data, since you used
> > > > BufferedChannel.
> > > > > > For
> > > > > > > write requests, a larger write size is OK. For read requests,
> > they
> > > > are
> > > > > > > almost randomly. Even you read a larger blob, the blob might be
> > > > useless
> > > > > > > when next read goes to other place. Even more, I don't think we
> > > need
> > > > to
> > > > > > > maintain another fixed length readBuffer in BufferedChannel, it
> > > > almost
> > > > > > > doesn't help for random reads, we could leverage OS cache for
> it.
> > > > > > >
> > > > > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <guosijie@gmail.com
> >
> > > > wrote:
> > > > > > >
> > > > > > >> For serving requests, either queuing the requests in bookie
> > server
> > > > per
> > > > > > >> channel (write/read are blocking operations), or queueing in
> os
> > > > kernel
> > > > > > to
> > > > > > >> let block device queuing and schedule those io requests. I
> think
> > > > Stu's
> > > > > > >> point is to leverage block device's schedule algorithm to
> issue
> > io
> > > > > > requests
> > > > > > >> in multiple threads to fully utilize the disk bandwidth.
> > > > > > >>
> > > > > > >> from the iostat reports provided by Aniruddha, the average
> queue
> > > > > length
> > > > > > >> and utilized percentage are not high, which means most of time
> > the
> > > > > disks
> > > > > > >> are idle. It makes sense to use multiple threads to issue read
> > > > > requests.
> > > > > > >> one write thread and several read threads might work for each
> > > > device.
> > > > > > >>
> > > > > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
> > > > fpj@yahoo-inc.com
> > > > > > >wrote:
> > > > > > >>
> > > > > > >>> Hi Stu, I'm not sure I understand your point. If with one
> > thread
> > > we
> > > > > are
> > > > > > >>> getting pretty high latency (case Aniruddha described),
> doesn't
> > > it
> > > > > > mean we
> > > > > > >>> have a number of requests queued up? Adding more threads
> might
> > > only
> > > > > > make
> > > > > > >>> the problem worse by queueing up even more requests. I'm
> > possibly
> > > > > > missing
> > > > > > >>> your point...
> > > > > > >>>
> > > > > > >>> -Flavio
> > > > > > >>>
> > > > > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > > > > > >>>
> > > > > > >>>> Separating by device would help, but will not allow the
> > devices
> > > to
> > > > > be
> > > > > > >>> fully
> > > > > > >>>> utilized: in order to buffer enough io commands into a
> disk's
> > > > queue
> > > > > > for
> > > > > > >>> the
> > > > > > >>>> elevator algorithms to kick in, you either need to use
> > multiple
> > > > > > threads
> > > > > > >>> per
> > > > > > >>>> disk, or native async IO (not trivially available within the
> > > JVM.)
> > > > > > >>>>
> > > > > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> > > > > fpj@yahoo-inc.com>
> > > > > > >>> wrote:
> > > > > > >>>>
> > > > > > >>>>>
> > > > > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > > > > > >>>>>
> > > > > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > > > > > fpj@yahoo-inc.com>
> > > > > > >>>>> wrote:
> > > > > > >>>>>>
> > > > > > >>>>>>> Just to add a couple of comments to the discussion,
> > > separating
> > > > > > reads
> > > > > > >>> and
> > > > > > >>>>>>> writes into different threads should only help with
> queuing
> > > > > > latency.
> > > > > > >>> It
> > > > > > >>>>>>> wouldn't help with IO latency.
> > > > > > >>>>>>>
> > > > > > >>>>>>
> > > > > > >>>>>> Yes, but with the current implementation, publishes
> > latencies
> > > in
> > > > > > >>> hedwig
> > > > > > >>>>>> suffer because of lagging subscribers. By separating read
> > and
> > > > > write
> > > > > > >>>>> queues,
> > > > > > >>>>>> we can at least guarantee that the write SLA is maintained
> > > > > (separate
> > > > > > >>>>>> journal disk + separate thread would ensure that writes
> are
> > > not
> > > > > > >>> affected
> > > > > > >>>>> by
> > > > > > >>>>>> read related seeks)
> > > > > > >>>>>>
> > > > > > >>>>>
> > > > > > >>>>> Agreed and based on my comment below, I was wondering if it
> > > > > wouldn't
> > > > > > be
> > > > > > >>>>> best to separate traffic across threads by device instead
> of
> > by
> > > > > > >>> operation
> > > > > > >>>>> type.
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>>> Also, it sounds like a good idea to have at least one
> > thread
> > > > per
> > > > > > >>> ledger
> > > > > > >>>>>>> device. In the case of multiple ledger devices, if we use
> > one
> > > > > > single
> > > > > > >>>>>>> thread, then the performance of the bookie will be driven
> > by
> > > > the
> > > > > > >>> slowest
> > > > > > >>>>>>> disk, no?
> > > > > > >>>>>>>
> > > > > > >>>>>> yup, makes sense.
> > > > > > >>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>>> -Flavio
> > > > > > >>>>>>>
> > > > > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > > > > > >>>>>>>
> > > > > > >>>>>>>>> Could you give some information on what those
> > shortcomings
> > > > are?
> > > > > > >>> Also,
> > > > > > >>>>> do
> > > > > > >>>>>>>>> let me know if you need any more information from our
> > end.
> > > > > > >>>>>>>> Off the top of my head:
> > > > > > >>>>>>>> - reads and writes are handled in the same thread (as
> you
> > > have
> > > > > > >>>>> observed)
> > > > > > >>>>>>>> - each entry read requires a single RPC.
> > > > > > >>>>>>>> - entries are read in parallel
> > > > > > >>>>>>>
> > > > > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top
> of
> > > > > > >>> FileChannel,
> > > > > > >>>>>> right?
> > > > > > >>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> Not all of these could result in the high latency you
> see,
> > > but
> > > > > if
> > > > > > >>> each
> > > > > > >>>>>>>> entry is being read separately, a sync on the ledger
> disk
> > in
> > > > > > between
> > > > > > >>>>>>>> will make a mess of the disk head scheduling.
> > > > > > >>>>>>>
> > > > > > >>>>>> Increasing the time interval between  flushing log files
> > might
> > > > > > >>> possibly
> > > > > > >>>>>> help in this case then?
> > > > > > >>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> -Ivan
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>> Thanks for the help :)
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>
> > > > > > >>>
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
On Thu, Sep 27, 2012 at 3:21 AM, Sijie Guo <gu...@gmail.com> wrote:

> > I took at look at the leveldb homepage and it says - "Only a single
> process
> > (possibly multi-threaded) can access a particular database at a time."
> > This is bad because it means we can't run the console or any recovery
> > related operations while the bookies are running.
>
> Yes. leveldb is single process. it prevent misuse by acquiring lock from
> filesystem. We did can't run the console to look its data while the bookie
> is running.
>
> I am confusing about the 'recovery' operations you mentioned. what kind of
> recovery?
>
I was talking about BookkeeperAdmin and how it's used from BookkeeperTools.
I believe that we currently only support replicating a bookie onto another
bookie. We might want to support more operations of this nature in future.
These might need simultaneous access to the log files of a live bookie.

>
> > When we flush to the log file, we
> > should simply flush entries sorted by the ledger id as key.
>
> If we want to sort when flushing, we need to buffer all edits in memory,
> then flush. I am assume this approach would act same as LSM tree (what
> leveldb did).
>
Yes. quite similar. I just glanced over LSM trees, I'll take a more
detailed look soon.

>
> On Thu, Sep 27, 2012 at 9:39 AM, Aniruddha Laud <trojan.of.troy@gmail.com
> >wrote:
>
> > On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com> wrote:
> >
> > > Sounds good to have thread pool (and make them configurable) for
> reading
> > > from entry log files.
> > >
> > > > We can have a write threadpool (and we should always keep this
> > > lower than the number of processors) to process the add requests.
> > >
> > > one more point, since we had only one entry log file active accepting
> > entry
> > > written to it. I don't think multiple write threads would help now,
> since
> > > adding entry to entry log file is synchronized method.
> > >
> > I was talking about writing to the journal file. From what I understand,
> > log file entries
> > are flushed periodically by one thread and that is okay. The publish
> > latencies on hedwig are
> > dependent on the journal writes, though.
> >
> > >
> > > In order to utilize the disk bandwidth more efficiently, we might need
> to
> > > have one active entry log file accepting entry written per ledger disk.
> > But
> > > it might need to introduce some directory layout change (like logId,
> > > currently we using incrementing log id for whole bookie) and logic
> > > changes.  it would be a separated task if did that.
> > >
> > > > Another thing we could possibly look at is re ordering our writes to
> > the
> > > log file to try and maintain locality for ledger entries.
> > >
> > > We had a prototype work internally working on using leveldb to store 1)
> > > small entries data (size less than hundred of bytes), 2) ledger index
> for
> > > large entries (acts as ledger cache for index entries). Benefiting from
> > > leveldb, 1) we could have more efficient cache when there are larger
> > number
> > > of ledgers and size skew between ledgers, 2) we could have data
> belonging
> > > to same ledger clustered when writing to disks, which achieves what you
> > > mentioned 'reordering writes' in somehow.
> > >
> > I took at look at the leveldb homepage and it says - "Only a single
> process
> > (possibly multi-threaded) can access a particular database at a time."
> > This is bad because it means we can't run the console or any recovery
> > related operations while the bookies are running. I may be wrong, though.
> > What I had in mind was pretty simple. When we flush to the log file, we
> > should simply flush entries sorted by the ledger id as key. Some changes
> > might be needed to the ledger index cache, but I'm not very sure what the
> > changes would be. What do you think?
> >
> > >
> > > -Sijie
> > >
> > > On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
> > > <tr...@gmail.com>wrote:
> > >
> > > > Hi all,
> > > >
> > > > Those stats I pasted might be a little misleading as they show the
> > > average
> > > > over a couple of minutes. Whenever there are reads to the ledger
> disks,
> > > the
> > > > queue size on them is sometimes as high as 100. Also, the CPU
> > utilization
> > > > has been lower than 10% throughout and the process will continue to
> > > remain
> > > > I/O bound even if we introduce more threads (As the CPU remains idle
> > > while
> > > > doing I/O).
> > > >
> > > > A couple of observations about the write path. We currently have a
> hard
> > > > coded buffer size for journal writes (I believe it's 512KB) and we
> > flush
> > > to
> > > > the disk when this fills up or if there is no entry to process (which
> > is
> > > > highly unlikely in case of a high throughput application running on
> > top).
> > > > We should make this buffer size configurable. Now, with more threads,
> > we
> > > > can process more packets in parallel and this buffer can be filled up
> > > > faster. We can have a write threadpool (and we should always keep
> this
> > > > lower than the number of processors) to process the add requests.
> > > >
> > > > For read requests, a configurable number of worker threads would be
> > ideal
> > > > and we could let the user tune it depending on the kind of read
> > patterns
> > > > they expect. Given that ledgers are interleaved ATM, I would expect
> the
> > > > performance to increase linearly with the number of threads till a
> > > certain
> > > > point and then level out.
> > > >
> > > > Another thing we could possibly look at is re ordering our writes to
> > the
> > > > log file to try and maintain locality for ledger entries. This might
> > > reduce
> > > > the number of random seeks we do in case only a small number of
> ledgers
> > > are
> > > > lagging.
> > > >
> > > > Thoughts?
> > > >
> > > > Regards,
> > > > Aniruddha.
> > > >
> > > > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com>
> wrote:
> > > >
> > > > > >>>One question: what is multi-ledgers?
> > > > > multiple ledgers directories(muliple disks)
> > > > >
> > > > > >>>CPU utilization might not be largely affected if the threads are
> > > > > sitting there waiting on IO
> > > > > Ok, seems I got it.
> > > > > If one thread spends most of its time waiting for I/O completion
> > > instead
> > > > > of using the CPU, but does not mean that "we've hit the system I/O
> > > > > bandwidth limit", then IMHO having multiple threads (or
> asynchronous
> > > I/O)
> > > > > might improve performance (by enabling more than one concurrent I/O
> > > > > operation).
> > > > >
> > > > > -Rakesh
> > > > > ________________________________________
> > > > > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > > > > Sent: Wednesday, September 26, 2012 2:17 PM
> > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > Subject: Re: High latencies observed at the bookkeeper client while
> > > > > reading entries
> > > > >
> > > > > CPU utilization might not be largely affected if the threads are
> > > sitting
> > > > > there waiting on IO. In my understanding of the proposal so far,
> the
> > > idea
> > > > > is to have multiple threads only to perform IO.
> > > > >
> > > > > One question: what is multi-ledgers?
> > > > >
> > > > > -Flavio
> > > > >
> > > > >
> > > > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> > > > >
> > > > > > I just adding one more point:
> > > > > >
> > > > > > Increasing the number of threads, can hit the CPU utilization
> too.
> > > > Also,
> > > > > we would consider this and good to observe whether its more on I/O
> > > bound
> > > > > than CPU bound. However, it depends in great detail on the disks
> and
> > > how
> > > > > much CPU work other threads are doing before they, too, end up
> > waiting
> > > on
> > > > > those disks.
> > > > > >
> > > > > > I'm also thinking inline with Flavio's suggestion to have one
> > thread
> > > > per
> > > > > ledger/journal device. Multithreading can help us with I/O bound
> > > problems
> > > > > if the I/O is perform against different disks.
> > > > > >
> > > > > > From the iostat report: waiting time of ledger directories. It
> > shows
> > > we
> > > > > have options to fully utilizing the disk bandwidth.
> > > > > >
> > > > > > multi-ledgers disk usage:
> > > > > > avgqu-sz
> > > > > > 1.10
> > > > > > 0.12
> > > > > > 0.54
> > > > > > 0.13
> > > > > >
> > > > > > -Rakesh
> > > > > > ________________________________________
> > > > > > From: Sijie Guo [guosijie@gmail.com]
> > > > > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > > Subject: Re: High latencies observed at the bookkeeper client
> while
> > > > > reading entries
> > > > > >
> > > > > > One more point is that each write/read request to entry log files
> > > would
> > > > > be
> > > > > > converted to write/read a 8K blob data, since you used
> > > BufferedChannel.
> > > > > For
> > > > > > write requests, a larger write size is OK. For read requests,
> they
> > > are
> > > > > > almost randomly. Even you read a larger blob, the blob might be
> > > useless
> > > > > > when next read goes to other place. Even more, I don't think we
> > need
> > > to
> > > > > > maintain another fixed length readBuffer in BufferedChannel, it
> > > almost
> > > > > > doesn't help for random reads, we could leverage OS cache for it.
> > > > > >
> > > > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com>
> > > wrote:
> > > > > >
> > > > > >> For serving requests, either queuing the requests in bookie
> server
> > > per
> > > > > >> channel (write/read are blocking operations), or queueing in os
> > > kernel
> > > > > to
> > > > > >> let block device queuing and schedule those io requests. I think
> > > Stu's
> > > > > >> point is to leverage block device's schedule algorithm to issue
> io
> > > > > requests
> > > > > >> in multiple threads to fully utilize the disk bandwidth.
> > > > > >>
> > > > > >> from the iostat reports provided by Aniruddha, the average queue
> > > > length
> > > > > >> and utilized percentage are not high, which means most of time
> the
> > > > disks
> > > > > >> are idle. It makes sense to use multiple threads to issue read
> > > > requests.
> > > > > >> one write thread and several read threads might work for each
> > > device.
> > > > > >>
> > > > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
> > > fpj@yahoo-inc.com
> > > > > >wrote:
> > > > > >>
> > > > > >>> Hi Stu, I'm not sure I understand your point. If with one
> thread
> > we
> > > > are
> > > > > >>> getting pretty high latency (case Aniruddha described), doesn't
> > it
> > > > > mean we
> > > > > >>> have a number of requests queued up? Adding more threads might
> > only
> > > > > make
> > > > > >>> the problem worse by queueing up even more requests. I'm
> possibly
> > > > > missing
> > > > > >>> your point...
> > > > > >>>
> > > > > >>> -Flavio
> > > > > >>>
> > > > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > > > > >>>
> > > > > >>>> Separating by device would help, but will not allow the
> devices
> > to
> > > > be
> > > > > >>> fully
> > > > > >>>> utilized: in order to buffer enough io commands into a disk's
> > > queue
> > > > > for
> > > > > >>> the
> > > > > >>>> elevator algorithms to kick in, you either need to use
> multiple
> > > > > threads
> > > > > >>> per
> > > > > >>>> disk, or native async IO (not trivially available within the
> > JVM.)
> > > > > >>>>
> > > > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> > > > fpj@yahoo-inc.com>
> > > > > >>> wrote:
> > > > > >>>>
> > > > > >>>>>
> > > > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > > > > >>>>>
> > > > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > > > > fpj@yahoo-inc.com>
> > > > > >>>>> wrote:
> > > > > >>>>>>
> > > > > >>>>>>> Just to add a couple of comments to the discussion,
> > separating
> > > > > reads
> > > > > >>> and
> > > > > >>>>>>> writes into different threads should only help with queuing
> > > > > latency.
> > > > > >>> It
> > > > > >>>>>>> wouldn't help with IO latency.
> > > > > >>>>>>>
> > > > > >>>>>>
> > > > > >>>>>> Yes, but with the current implementation, publishes
> latencies
> > in
> > > > > >>> hedwig
> > > > > >>>>>> suffer because of lagging subscribers. By separating read
> and
> > > > write
> > > > > >>>>> queues,
> > > > > >>>>>> we can at least guarantee that the write SLA is maintained
> > > > (separate
> > > > > >>>>>> journal disk + separate thread would ensure that writes are
> > not
> > > > > >>> affected
> > > > > >>>>> by
> > > > > >>>>>> read related seeks)
> > > > > >>>>>>
> > > > > >>>>>
> > > > > >>>>> Agreed and based on my comment below, I was wondering if it
> > > > wouldn't
> > > > > be
> > > > > >>>>> best to separate traffic across threads by device instead of
> by
> > > > > >>> operation
> > > > > >>>>> type.
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>>>
> > > > > >>>>>>> Also, it sounds like a good idea to have at least one
> thread
> > > per
> > > > > >>> ledger
> > > > > >>>>>>> device. In the case of multiple ledger devices, if we use
> one
> > > > > single
> > > > > >>>>>>> thread, then the performance of the bookie will be driven
> by
> > > the
> > > > > >>> slowest
> > > > > >>>>>>> disk, no?
> > > > > >>>>>>>
> > > > > >>>>>> yup, makes sense.
> > > > > >>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>> -Flavio
> > > > > >>>>>>>
> > > > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > > > > >>>>>>>
> > > > > >>>>>>>>> Could you give some information on what those
> shortcomings
> > > are?
> > > > > >>> Also,
> > > > > >>>>> do
> > > > > >>>>>>>>> let me know if you need any more information from our
> end.
> > > > > >>>>>>>> Off the top of my head:
> > > > > >>>>>>>> - reads and writes are handled in the same thread (as you
> > have
> > > > > >>>>> observed)
> > > > > >>>>>>>> - each entry read requires a single RPC.
> > > > > >>>>>>>> - entries are read in parallel
> > > > > >>>>>>>
> > > > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
> > > > > >>> FileChannel,
> > > > > >>>>>> right?
> > > > > >>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>>> Not all of these could result in the high latency you see,
> > but
> > > > if
> > > > > >>> each
> > > > > >>>>>>>> entry is being read separately, a sync on the ledger disk
> in
> > > > > between
> > > > > >>>>>>>> will make a mess of the disk head scheduling.
> > > > > >>>>>>>
> > > > > >>>>>> Increasing the time interval between  flushing log files
> might
> > > > > >>> possibly
> > > > > >>>>>> help in this case then?
> > > > > >>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>>> -Ivan
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> Thanks for the help :)
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>
> > > > > >>>
> > > > >
> > > >
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
> I took at look at the leveldb homepage and it says - "Only a single
process
> (possibly multi-threaded) can access a particular database at a time."
> This is bad because it means we can't run the console or any recovery
> related operations while the bookies are running.

Yes. leveldb is single process. it prevent misuse by acquiring lock from
filesystem. We did can't run the console to look its data while the bookie
is running.

I am confusing about the 'recovery' operations you mentioned. what kind of
recovery?

> When we flush to the log file, we
> should simply flush entries sorted by the ledger id as key.

If we want to sort when flushing, we need to buffer all edits in memory,
then flush. I am assume this approach would act same as LSM tree (what
leveldb did).

On Thu, Sep 27, 2012 at 9:39 AM, Aniruddha Laud <tr...@gmail.com>wrote:

> On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com> wrote:
>
> > Sounds good to have thread pool (and make them configurable) for reading
> > from entry log files.
> >
> > > We can have a write threadpool (and we should always keep this
> > lower than the number of processors) to process the add requests.
> >
> > one more point, since we had only one entry log file active accepting
> entry
> > written to it. I don't think multiple write threads would help now, since
> > adding entry to entry log file is synchronized method.
> >
> I was talking about writing to the journal file. From what I understand,
> log file entries
> are flushed periodically by one thread and that is okay. The publish
> latencies on hedwig are
> dependent on the journal writes, though.
>
> >
> > In order to utilize the disk bandwidth more efficiently, we might need to
> > have one active entry log file accepting entry written per ledger disk.
> But
> > it might need to introduce some directory layout change (like logId,
> > currently we using incrementing log id for whole bookie) and logic
> > changes.  it would be a separated task if did that.
> >
> > > Another thing we could possibly look at is re ordering our writes to
> the
> > log file to try and maintain locality for ledger entries.
> >
> > We had a prototype work internally working on using leveldb to store 1)
> > small entries data (size less than hundred of bytes), 2) ledger index for
> > large entries (acts as ledger cache for index entries). Benefiting from
> > leveldb, 1) we could have more efficient cache when there are larger
> number
> > of ledgers and size skew between ledgers, 2) we could have data belonging
> > to same ledger clustered when writing to disks, which achieves what you
> > mentioned 'reordering writes' in somehow.
> >
> I took at look at the leveldb homepage and it says - "Only a single process
> (possibly multi-threaded) can access a particular database at a time."
> This is bad because it means we can't run the console or any recovery
> related operations while the bookies are running. I may be wrong, though.
> What I had in mind was pretty simple. When we flush to the log file, we
> should simply flush entries sorted by the ledger id as key. Some changes
> might be needed to the ledger index cache, but I'm not very sure what the
> changes would be. What do you think?
>
> >
> > -Sijie
> >
> > On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
> > <tr...@gmail.com>wrote:
> >
> > > Hi all,
> > >
> > > Those stats I pasted might be a little misleading as they show the
> > average
> > > over a couple of minutes. Whenever there are reads to the ledger disks,
> > the
> > > queue size on them is sometimes as high as 100. Also, the CPU
> utilization
> > > has been lower than 10% throughout and the process will continue to
> > remain
> > > I/O bound even if we introduce more threads (As the CPU remains idle
> > while
> > > doing I/O).
> > >
> > > A couple of observations about the write path. We currently have a hard
> > > coded buffer size for journal writes (I believe it's 512KB) and we
> flush
> > to
> > > the disk when this fills up or if there is no entry to process (which
> is
> > > highly unlikely in case of a high throughput application running on
> top).
> > > We should make this buffer size configurable. Now, with more threads,
> we
> > > can process more packets in parallel and this buffer can be filled up
> > > faster. We can have a write threadpool (and we should always keep this
> > > lower than the number of processors) to process the add requests.
> > >
> > > For read requests, a configurable number of worker threads would be
> ideal
> > > and we could let the user tune it depending on the kind of read
> patterns
> > > they expect. Given that ledgers are interleaved ATM, I would expect the
> > > performance to increase linearly with the number of threads till a
> > certain
> > > point and then level out.
> > >
> > > Another thing we could possibly look at is re ordering our writes to
> the
> > > log file to try and maintain locality for ledger entries. This might
> > reduce
> > > the number of random seeks we do in case only a small number of ledgers
> > are
> > > lagging.
> > >
> > > Thoughts?
> > >
> > > Regards,
> > > Aniruddha.
> > >
> > > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com> wrote:
> > >
> > > > >>>One question: what is multi-ledgers?
> > > > multiple ledgers directories(muliple disks)
> > > >
> > > > >>>CPU utilization might not be largely affected if the threads are
> > > > sitting there waiting on IO
> > > > Ok, seems I got it.
> > > > If one thread spends most of its time waiting for I/O completion
> > instead
> > > > of using the CPU, but does not mean that "we've hit the system I/O
> > > > bandwidth limit", then IMHO having multiple threads (or asynchronous
> > I/O)
> > > > might improve performance (by enabling more than one concurrent I/O
> > > > operation).
> > > >
> > > > -Rakesh
> > > > ________________________________________
> > > > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > > > Sent: Wednesday, September 26, 2012 2:17 PM
> > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > Subject: Re: High latencies observed at the bookkeeper client while
> > > > reading entries
> > > >
> > > > CPU utilization might not be largely affected if the threads are
> > sitting
> > > > there waiting on IO. In my understanding of the proposal so far, the
> > idea
> > > > is to have multiple threads only to perform IO.
> > > >
> > > > One question: what is multi-ledgers?
> > > >
> > > > -Flavio
> > > >
> > > >
> > > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> > > >
> > > > > I just adding one more point:
> > > > >
> > > > > Increasing the number of threads, can hit the CPU utilization too.
> > > Also,
> > > > we would consider this and good to observe whether its more on I/O
> > bound
> > > > than CPU bound. However, it depends in great detail on the disks and
> > how
> > > > much CPU work other threads are doing before they, too, end up
> waiting
> > on
> > > > those disks.
> > > > >
> > > > > I'm also thinking inline with Flavio's suggestion to have one
> thread
> > > per
> > > > ledger/journal device. Multithreading can help us with I/O bound
> > problems
> > > > if the I/O is perform against different disks.
> > > > >
> > > > > From the iostat report: waiting time of ledger directories. It
> shows
> > we
> > > > have options to fully utilizing the disk bandwidth.
> > > > >
> > > > > multi-ledgers disk usage:
> > > > > avgqu-sz
> > > > > 1.10
> > > > > 0.12
> > > > > 0.54
> > > > > 0.13
> > > > >
> > > > > -Rakesh
> > > > > ________________________________________
> > > > > From: Sijie Guo [guosijie@gmail.com]
> > > > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > Subject: Re: High latencies observed at the bookkeeper client while
> > > > reading entries
> > > > >
> > > > > One more point is that each write/read request to entry log files
> > would
> > > > be
> > > > > converted to write/read a 8K blob data, since you used
> > BufferedChannel.
> > > > For
> > > > > write requests, a larger write size is OK. For read requests, they
> > are
> > > > > almost randomly. Even you read a larger blob, the blob might be
> > useless
> > > > > when next read goes to other place. Even more, I don't think we
> need
> > to
> > > > > maintain another fixed length readBuffer in BufferedChannel, it
> > almost
> > > > > doesn't help for random reads, we could leverage OS cache for it.
> > > > >
> > > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com>
> > wrote:
> > > > >
> > > > >> For serving requests, either queuing the requests in bookie server
> > per
> > > > >> channel (write/read are blocking operations), or queueing in os
> > kernel
> > > > to
> > > > >> let block device queuing and schedule those io requests. I think
> > Stu's
> > > > >> point is to leverage block device's schedule algorithm to issue io
> > > > requests
> > > > >> in multiple threads to fully utilize the disk bandwidth.
> > > > >>
> > > > >> from the iostat reports provided by Aniruddha, the average queue
> > > length
> > > > >> and utilized percentage are not high, which means most of time the
> > > disks
> > > > >> are idle. It makes sense to use multiple threads to issue read
> > > requests.
> > > > >> one write thread and several read threads might work for each
> > device.
> > > > >>
> > > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
> > fpj@yahoo-inc.com
> > > > >wrote:
> > > > >>
> > > > >>> Hi Stu, I'm not sure I understand your point. If with one thread
> we
> > > are
> > > > >>> getting pretty high latency (case Aniruddha described), doesn't
> it
> > > > mean we
> > > > >>> have a number of requests queued up? Adding more threads might
> only
> > > > make
> > > > >>> the problem worse by queueing up even more requests. I'm possibly
> > > > missing
> > > > >>> your point...
> > > > >>>
> > > > >>> -Flavio
> > > > >>>
> > > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > > > >>>
> > > > >>>> Separating by device would help, but will not allow the devices
> to
> > > be
> > > > >>> fully
> > > > >>>> utilized: in order to buffer enough io commands into a disk's
> > queue
> > > > for
> > > > >>> the
> > > > >>>> elevator algorithms to kick in, you either need to use multiple
> > > > threads
> > > > >>> per
> > > > >>>> disk, or native async IO (not trivially available within the
> JVM.)
> > > > >>>>
> > > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> > > fpj@yahoo-inc.com>
> > > > >>> wrote:
> > > > >>>>
> > > > >>>>>
> > > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > > > >>>>>
> > > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > > > fpj@yahoo-inc.com>
> > > > >>>>> wrote:
> > > > >>>>>>
> > > > >>>>>>> Just to add a couple of comments to the discussion,
> separating
> > > > reads
> > > > >>> and
> > > > >>>>>>> writes into different threads should only help with queuing
> > > > latency.
> > > > >>> It
> > > > >>>>>>> wouldn't help with IO latency.
> > > > >>>>>>>
> > > > >>>>>>
> > > > >>>>>> Yes, but with the current implementation, publishes latencies
> in
> > > > >>> hedwig
> > > > >>>>>> suffer because of lagging subscribers. By separating read and
> > > write
> > > > >>>>> queues,
> > > > >>>>>> we can at least guarantee that the write SLA is maintained
> > > (separate
> > > > >>>>>> journal disk + separate thread would ensure that writes are
> not
> > > > >>> affected
> > > > >>>>> by
> > > > >>>>>> read related seeks)
> > > > >>>>>>
> > > > >>>>>
> > > > >>>>> Agreed and based on my comment below, I was wondering if it
> > > wouldn't
> > > > be
> > > > >>>>> best to separate traffic across threads by device instead of by
> > > > >>> operation
> > > > >>>>> type.
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>>>
> > > > >>>>>>> Also, it sounds like a good idea to have at least one thread
> > per
> > > > >>> ledger
> > > > >>>>>>> device. In the case of multiple ledger devices, if we use one
> > > > single
> > > > >>>>>>> thread, then the performance of the bookie will be driven by
> > the
> > > > >>> slowest
> > > > >>>>>>> disk, no?
> > > > >>>>>>>
> > > > >>>>>> yup, makes sense.
> > > > >>>>>>
> > > > >>>>>>>
> > > > >>>>>>> -Flavio
> > > > >>>>>>>
> > > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > > > >>>>>>>
> > > > >>>>>>>>> Could you give some information on what those shortcomings
> > are?
> > > > >>> Also,
> > > > >>>>> do
> > > > >>>>>>>>> let me know if you need any more information from our end.
> > > > >>>>>>>> Off the top of my head:
> > > > >>>>>>>> - reads and writes are handled in the same thread (as you
> have
> > > > >>>>> observed)
> > > > >>>>>>>> - each entry read requires a single RPC.
> > > > >>>>>>>> - entries are read in parallel
> > > > >>>>>>>
> > > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
> > > > >>> FileChannel,
> > > > >>>>>> right?
> > > > >>>>>>
> > > > >>>>>>>>
> > > > >>>>>>>> Not all of these could result in the high latency you see,
> but
> > > if
> > > > >>> each
> > > > >>>>>>>> entry is being read separately, a sync on the ledger disk in
> > > > between
> > > > >>>>>>>> will make a mess of the disk head scheduling.
> > > > >>>>>>>
> > > > >>>>>> Increasing the time interval between  flushing log files might
> > > > >>> possibly
> > > > >>>>>> help in this case then?
> > > > >>>>>>
> > > > >>>>>>>>
> > > > >>>>>>>> -Ivan
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> Thanks for the help :)
> > > > >>>>>
> > > > >>>>>
> > > > >>>
> > > > >>>
> > > >
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
On Thu, Sep 27, 2012 at 2:53 AM, Sijie Guo <gu...@gmail.com> wrote:

> > I was talking about writing to the journal file. From what I understand,
> log file entries
> > are flushed periodically by one thread and that is okay. The publish
> > latencies on hedwig are
> > dependent on the journal writes, though.
>
> I was confused now. Journal file is flushed periodically by 'BookieJournal'
> thread not the entry log file.
>
> The write code path would be:
>
> 1) adding entry into entry log file
> 2) putting index to ledger cache
> 3) logAddEntry to journal.
>
> 1) and 2) is synchronized calls. if 1) and 2) took long time, it would
> affect other requests in PerChannelBookieClient, since
> PerChannelBookieClient process requests one by one.
>
After 1) and 2), we don't actually call flush(), right? So they're not
exactly writing to the disk the moment they're invoked. The entry to the
journal, on the other hand is flushed every 512KBs and we call the
WriteCallback on the entry when this is done. This write callback sends the
response back. We might as well cache 1) and 2) ourselves and then reorder
the writes(to maintain locality) while writing them to the log file. The
thread I was referring to is Bookie#SyncThread.

>
> 3) is asynchronous call, just putting add entry into journal queue. 3)
> would not affect other requests in PerChannelBookieClient.
>
It does, because you send a response to the bookie client only when things
are flushed to the journal.

>
> but 3) would affect the response latency for adding entry. we already took
> care about it to let journal flushing into a  separated journal disk. so 3)
> would not be the cause for high latencies.
>
Correct, journal additions are executed by the same thread as the reads and
that is what is causing this problem. According to me, because we don't
rely on the log files to be up-to-date, we can flush them in a different
thread every few minutes or so. Does that seem right? We can reorder all
writes we received in the flush-interval to maintain locality.

>
> so my understanding is that previous email discussions are talking about
> entry log file which is in the code path for read/write. so the discussion
> is that we need to separate read/write requests to different threads to
> avoid effection between them. isn't it? If I am wrong about it, please
>  correct me.

Yes, i think the idea was to not have any read requests affect write
latencies because reads might be expensive.

>
>
> On Thu, Sep 27, 2012 at 9:39 AM, Aniruddha Laud <trojan.of.troy@gmail.com
> >wrote:
>
> > On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com> wrote:
> >
> > > Sounds good to have thread pool (and make them configurable) for
> reading
> > > from entry log files.
> > >
> > > > We can have a write threadpool (and we should always keep this
> > > lower than the number of processors) to process the add requests.
> > >
> > > one more point, since we had only one entry log file active accepting
> > entry
> > > written to it. I don't think multiple write threads would help now,
> since
> > > adding entry to entry log file is synchronized method.
> > >
> > I was talking about writing to the journal file. From what I understand,
> > log file entries
> > are flushed periodically by one thread and that is okay. The publish
> > latencies on hedwig are
> > dependent on the journal writes, though.
> >
> > >
> > > In order to utilize the disk bandwidth more efficiently, we might need
> to
> > > have one active entry log file accepting entry written per ledger disk.
> > But
> > > it might need to introduce some directory layout change (like logId,
> > > currently we using incrementing log id for whole bookie) and logic
> > > changes.  it would be a separated task if did that.
> > >
> > > > Another thing we could possibly look at is re ordering our writes to
> > the
> > > log file to try and maintain locality for ledger entries.
> > >
> > > We had a prototype work internally working on using leveldb to store 1)
> > > small entries data (size less than hundred of bytes), 2) ledger index
> for
> > > large entries (acts as ledger cache for index entries). Benefiting from
> > > leveldb, 1) we could have more efficient cache when there are larger
> > number
> > > of ledgers and size skew between ledgers, 2) we could have data
> belonging
> > > to same ledger clustered when writing to disks, which achieves what you
> > > mentioned 'reordering writes' in somehow.
> > >
> > I took at look at the leveldb homepage and it says - "Only a single
> process
> > (possibly multi-threaded) can access a particular database at a time."
> > This is bad because it means we can't run the console or any recovery
> > related operations while the bookies are running. I may be wrong, though.
> > What I had in mind was pretty simple. When we flush to the log file, we
> > should simply flush entries sorted by the ledger id as key. Some changes
> > might be needed to the ledger index cache, but I'm not very sure what the
> > changes would be. What do you think?
> >
> > >
> > > -Sijie
> > >
> > > On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
> > > <tr...@gmail.com>wrote:
> > >
> > > > Hi all,
> > > >
> > > > Those stats I pasted might be a little misleading as they show the
> > > average
> > > > over a couple of minutes. Whenever there are reads to the ledger
> disks,
> > > the
> > > > queue size on them is sometimes as high as 100. Also, the CPU
> > utilization
> > > > has been lower than 10% throughout and the process will continue to
> > > remain
> > > > I/O bound even if we introduce more threads (As the CPU remains idle
> > > while
> > > > doing I/O).
> > > >
> > > > A couple of observations about the write path. We currently have a
> hard
> > > > coded buffer size for journal writes (I believe it's 512KB) and we
> > flush
> > > to
> > > > the disk when this fills up or if there is no entry to process (which
> > is
> > > > highly unlikely in case of a high throughput application running on
> > top).
> > > > We should make this buffer size configurable. Now, with more threads,
> > we
> > > > can process more packets in parallel and this buffer can be filled up
> > > > faster. We can have a write threadpool (and we should always keep
> this
> > > > lower than the number of processors) to process the add requests.
> > > >
> > > > For read requests, a configurable number of worker threads would be
> > ideal
> > > > and we could let the user tune it depending on the kind of read
> > patterns
> > > > they expect. Given that ledgers are interleaved ATM, I would expect
> the
> > > > performance to increase linearly with the number of threads till a
> > > certain
> > > > point and then level out.
> > > >
> > > > Another thing we could possibly look at is re ordering our writes to
> > the
> > > > log file to try and maintain locality for ledger entries. This might
> > > reduce
> > > > the number of random seeks we do in case only a small number of
> ledgers
> > > are
> > > > lagging.
> > > >
> > > > Thoughts?
> > > >
> > > > Regards,
> > > > Aniruddha.
> > > >
> > > > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com>
> wrote:
> > > >
> > > > > >>>One question: what is multi-ledgers?
> > > > > multiple ledgers directories(muliple disks)
> > > > >
> > > > > >>>CPU utilization might not be largely affected if the threads are
> > > > > sitting there waiting on IO
> > > > > Ok, seems I got it.
> > > > > If one thread spends most of its time waiting for I/O completion
> > > instead
> > > > > of using the CPU, but does not mean that "we've hit the system I/O
> > > > > bandwidth limit", then IMHO having multiple threads (or
> asynchronous
> > > I/O)
> > > > > might improve performance (by enabling more than one concurrent I/O
> > > > > operation).
> > > > >
> > > > > -Rakesh
> > > > > ________________________________________
> > > > > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > > > > Sent: Wednesday, September 26, 2012 2:17 PM
> > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > Subject: Re: High latencies observed at the bookkeeper client while
> > > > > reading entries
> > > > >
> > > > > CPU utilization might not be largely affected if the threads are
> > > sitting
> > > > > there waiting on IO. In my understanding of the proposal so far,
> the
> > > idea
> > > > > is to have multiple threads only to perform IO.
> > > > >
> > > > > One question: what is multi-ledgers?
> > > > >
> > > > > -Flavio
> > > > >
> > > > >
> > > > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> > > > >
> > > > > > I just adding one more point:
> > > > > >
> > > > > > Increasing the number of threads, can hit the CPU utilization
> too.
> > > > Also,
> > > > > we would consider this and good to observe whether its more on I/O
> > > bound
> > > > > than CPU bound. However, it depends in great detail on the disks
> and
> > > how
> > > > > much CPU work other threads are doing before they, too, end up
> > waiting
> > > on
> > > > > those disks.
> > > > > >
> > > > > > I'm also thinking inline with Flavio's suggestion to have one
> > thread
> > > > per
> > > > > ledger/journal device. Multithreading can help us with I/O bound
> > > problems
> > > > > if the I/O is perform against different disks.
> > > > > >
> > > > > > From the iostat report: waiting time of ledger directories. It
> > shows
> > > we
> > > > > have options to fully utilizing the disk bandwidth.
> > > > > >
> > > > > > multi-ledgers disk usage:
> > > > > > avgqu-sz
> > > > > > 1.10
> > > > > > 0.12
> > > > > > 0.54
> > > > > > 0.13
> > > > > >
> > > > > > -Rakesh
> > > > > > ________________________________________
> > > > > > From: Sijie Guo [guosijie@gmail.com]
> > > > > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > > Subject: Re: High latencies observed at the bookkeeper client
> while
> > > > > reading entries
> > > > > >
> > > > > > One more point is that each write/read request to entry log files
> > > would
> > > > > be
> > > > > > converted to write/read a 8K blob data, since you used
> > > BufferedChannel.
> > > > > For
> > > > > > write requests, a larger write size is OK. For read requests,
> they
> > > are
> > > > > > almost randomly. Even you read a larger blob, the blob might be
> > > useless
> > > > > > when next read goes to other place. Even more, I don't think we
> > need
> > > to
> > > > > > maintain another fixed length readBuffer in BufferedChannel, it
> > > almost
> > > > > > doesn't help for random reads, we could leverage OS cache for it.
> > > > > >
> > > > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com>
> > > wrote:
> > > > > >
> > > > > >> For serving requests, either queuing the requests in bookie
> server
> > > per
> > > > > >> channel (write/read are blocking operations), or queueing in os
> > > kernel
> > > > > to
> > > > > >> let block device queuing and schedule those io requests. I think
> > > Stu's
> > > > > >> point is to leverage block device's schedule algorithm to issue
> io
> > > > > requests
> > > > > >> in multiple threads to fully utilize the disk bandwidth.
> > > > > >>
> > > > > >> from the iostat reports provided by Aniruddha, the average queue
> > > > length
> > > > > >> and utilized percentage are not high, which means most of time
> the
> > > > disks
> > > > > >> are idle. It makes sense to use multiple threads to issue read
> > > > requests.
> > > > > >> one write thread and several read threads might work for each
> > > device.
> > > > > >>
> > > > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
> > > fpj@yahoo-inc.com
> > > > > >wrote:
> > > > > >>
> > > > > >>> Hi Stu, I'm not sure I understand your point. If with one
> thread
> > we
> > > > are
> > > > > >>> getting pretty high latency (case Aniruddha described), doesn't
> > it
> > > > > mean we
> > > > > >>> have a number of requests queued up? Adding more threads might
> > only
> > > > > make
> > > > > >>> the problem worse by queueing up even more requests. I'm
> possibly
> > > > > missing
> > > > > >>> your point...
> > > > > >>>
> > > > > >>> -Flavio
> > > > > >>>
> > > > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > > > > >>>
> > > > > >>>> Separating by device would help, but will not allow the
> devices
> > to
> > > > be
> > > > > >>> fully
> > > > > >>>> utilized: in order to buffer enough io commands into a disk's
> > > queue
> > > > > for
> > > > > >>> the
> > > > > >>>> elevator algorithms to kick in, you either need to use
> multiple
> > > > > threads
> > > > > >>> per
> > > > > >>>> disk, or native async IO (not trivially available within the
> > JVM.)
> > > > > >>>>
> > > > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> > > > fpj@yahoo-inc.com>
> > > > > >>> wrote:
> > > > > >>>>
> > > > > >>>>>
> > > > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > > > > >>>>>
> > > > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > > > > fpj@yahoo-inc.com>
> > > > > >>>>> wrote:
> > > > > >>>>>>
> > > > > >>>>>>> Just to add a couple of comments to the discussion,
> > separating
> > > > > reads
> > > > > >>> and
> > > > > >>>>>>> writes into different threads should only help with queuing
> > > > > latency.
> > > > > >>> It
> > > > > >>>>>>> wouldn't help with IO latency.
> > > > > >>>>>>>
> > > > > >>>>>>
> > > > > >>>>>> Yes, but with the current implementation, publishes
> latencies
> > in
> > > > > >>> hedwig
> > > > > >>>>>> suffer because of lagging subscribers. By separating read
> and
> > > > write
> > > > > >>>>> queues,
> > > > > >>>>>> we can at least guarantee that the write SLA is maintained
> > > > (separate
> > > > > >>>>>> journal disk + separate thread would ensure that writes are
> > not
> > > > > >>> affected
> > > > > >>>>> by
> > > > > >>>>>> read related seeks)
> > > > > >>>>>>
> > > > > >>>>>
> > > > > >>>>> Agreed and based on my comment below, I was wondering if it
> > > > wouldn't
> > > > > be
> > > > > >>>>> best to separate traffic across threads by device instead of
> by
> > > > > >>> operation
> > > > > >>>>> type.
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>>>
> > > > > >>>>>>> Also, it sounds like a good idea to have at least one
> thread
> > > per
> > > > > >>> ledger
> > > > > >>>>>>> device. In the case of multiple ledger devices, if we use
> one
> > > > > single
> > > > > >>>>>>> thread, then the performance of the bookie will be driven
> by
> > > the
> > > > > >>> slowest
> > > > > >>>>>>> disk, no?
> > > > > >>>>>>>
> > > > > >>>>>> yup, makes sense.
> > > > > >>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>> -Flavio
> > > > > >>>>>>>
> > > > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > > > > >>>>>>>
> > > > > >>>>>>>>> Could you give some information on what those
> shortcomings
> > > are?
> > > > > >>> Also,
> > > > > >>>>> do
> > > > > >>>>>>>>> let me know if you need any more information from our
> end.
> > > > > >>>>>>>> Off the top of my head:
> > > > > >>>>>>>> - reads and writes are handled in the same thread (as you
> > have
> > > > > >>>>> observed)
> > > > > >>>>>>>> - each entry read requires a single RPC.
> > > > > >>>>>>>> - entries are read in parallel
> > > > > >>>>>>>
> > > > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
> > > > > >>> FileChannel,
> > > > > >>>>>> right?
> > > > > >>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>>> Not all of these could result in the high latency you see,
> > but
> > > > if
> > > > > >>> each
> > > > > >>>>>>>> entry is being read separately, a sync on the ledger disk
> in
> > > > > between
> > > > > >>>>>>>> will make a mess of the disk head scheduling.
> > > > > >>>>>>>
> > > > > >>>>>> Increasing the time interval between  flushing log files
> might
> > > > > >>> possibly
> > > > > >>>>>> help in this case then?
> > > > > >>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>>> -Ivan
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> Thanks for the help :)
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>
> > > > > >>>
> > > > >
> > > >
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
To recap my understanding about this problem is that:

1) for read requests, we would had a thread pool for each ledger device.

1.1) when a read request received, it read index entry for ledger cache. so
we know which ledger device that the entry located.
1.2) dispatch read request to a thread serving read requests to the target
ledger device. so it would not block other requests to be executed.
1.3) the read thread reads data from entry log file and send response back
to client.

(if we want to have multiple threads serving read requests from entry log
file, we don't need additional fixed length read buffer in BufferedChannel
for entry log files. local filesystem would have done a bit.)

2) for write requests, since we need to add entry to an entry log file and
there is only one entry log file active writing now even there was multiple
devices. so one write thread is OK now.

2.1) when a add request received, dispatch add request to write thread.
2.2) write thread takes the responsibility to add it into entry log file
and logAddEntry to journal file.

(if we want to improve disk bandwidth, it might make sense to have each
ledger device having an active entry log writing entries)

If my understanding is wrong, please correct me.


On Thu, Sep 27, 2012 at 5:53 PM, Sijie Guo <gu...@gmail.com> wrote:

> > I was talking about writing to the journal file. From what I understand,
> log file entries
> > are flushed periodically by one thread and that is okay. The publish
> > latencies on hedwig are
> > dependent on the journal writes, though.
>
> I was confused now. Journal file is flushed periodically by
> 'BookieJournal' thread not the entry log file.
>
> The write code path would be:
>
> 1) adding entry into entry log file
> 2) putting index to ledger cache
> 3) logAddEntry to journal.
>
> 1) and 2) is synchronized calls. if 1) and 2) took long time, it would
> affect other requests in PerChannelBookieClient, since
> PerChannelBookieClient process requests one by one.
>
> 3) is asynchronous call, just putting add entry into journal queue. 3)
> would not affect other requests in PerChannelBookieClient.
>
> but 3) would affect the response latency for adding entry. we already took
> care about it to let journal flushing into a  separated journal disk. so 3)
> would not be the cause for high latencies.
>
> so my understanding is that previous email discussions are talking about
> entry log file which is in the code path for read/write. so the discussion
> is that we need to separate read/write requests to different threads to
> avoid effection between them. isn't it? If I am wrong about it, please
> correct me.
>
>
> On Thu, Sep 27, 2012 at 9:39 AM, Aniruddha Laud <tr...@gmail.com>wrote:
>
>> On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com> wrote:
>>
>> > Sounds good to have thread pool (and make them configurable) for reading
>> > from entry log files.
>> >
>> > > We can have a write threadpool (and we should always keep this
>> > lower than the number of processors) to process the add requests.
>> >
>> > one more point, since we had only one entry log file active accepting
>> entry
>> > written to it. I don't think multiple write threads would help now,
>> since
>> > adding entry to entry log file is synchronized method.
>> >
>> I was talking about writing to the journal file. From what I understand,
>> log file entries
>> are flushed periodically by one thread and that is okay. The publish
>> latencies on hedwig are
>> dependent on the journal writes, though.
>>
>> >
>> > In order to utilize the disk bandwidth more efficiently, we might need
>> to
>> > have one active entry log file accepting entry written per ledger disk.
>> But
>> > it might need to introduce some directory layout change (like logId,
>> > currently we using incrementing log id for whole bookie) and logic
>> > changes.  it would be a separated task if did that.
>> >
>> > > Another thing we could possibly look at is re ordering our writes to
>> the
>> > log file to try and maintain locality for ledger entries.
>> >
>> > We had a prototype work internally working on using leveldb to store 1)
>> > small entries data (size less than hundred of bytes), 2) ledger index
>> for
>> > large entries (acts as ledger cache for index entries). Benefiting from
>> > leveldb, 1) we could have more efficient cache when there are larger
>> number
>> > of ledgers and size skew between ledgers, 2) we could have data
>> belonging
>> > to same ledger clustered when writing to disks, which achieves what you
>> > mentioned 'reordering writes' in somehow.
>> >
>> I took at look at the leveldb homepage and it says - "Only a single
>> process
>> (possibly multi-threaded) can access a particular database at a time."
>> This is bad because it means we can't run the console or any recovery
>> related operations while the bookies are running. I may be wrong, though.
>> What I had in mind was pretty simple. When we flush to the log file, we
>> should simply flush entries sorted by the ledger id as key. Some changes
>> might be needed to the ledger index cache, but I'm not very sure what the
>> changes would be. What do you think?
>>
>> >
>> > -Sijie
>> >
>> > On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
>> > <tr...@gmail.com>wrote:
>> >
>> > > Hi all,
>> > >
>> > > Those stats I pasted might be a little misleading as they show the
>> > average
>> > > over a couple of minutes. Whenever there are reads to the ledger
>> disks,
>> > the
>> > > queue size on them is sometimes as high as 100. Also, the CPU
>> utilization
>> > > has been lower than 10% throughout and the process will continue to
>> > remain
>> > > I/O bound even if we introduce more threads (As the CPU remains idle
>> > while
>> > > doing I/O).
>> > >
>> > > A couple of observations about the write path. We currently have a
>> hard
>> > > coded buffer size for journal writes (I believe it's 512KB) and we
>> flush
>> > to
>> > > the disk when this fills up or if there is no entry to process (which
>> is
>> > > highly unlikely in case of a high throughput application running on
>> top).
>> > > We should make this buffer size configurable. Now, with more threads,
>> we
>> > > can process more packets in parallel and this buffer can be filled up
>> > > faster. We can have a write threadpool (and we should always keep this
>> > > lower than the number of processors) to process the add requests.
>> > >
>> > > For read requests, a configurable number of worker threads would be
>> ideal
>> > > and we could let the user tune it depending on the kind of read
>> patterns
>> > > they expect. Given that ledgers are interleaved ATM, I would expect
>> the
>> > > performance to increase linearly with the number of threads till a
>> > certain
>> > > point and then level out.
>> > >
>> > > Another thing we could possibly look at is re ordering our writes to
>> the
>> > > log file to try and maintain locality for ledger entries. This might
>> > reduce
>> > > the number of random seeks we do in case only a small number of
>> ledgers
>> > are
>> > > lagging.
>> > >
>> > > Thoughts?
>> > >
>> > > Regards,
>> > > Aniruddha.
>> > >
>> > > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com> wrote:
>> > >
>> > > > >>>One question: what is multi-ledgers?
>> > > > multiple ledgers directories(muliple disks)
>> > > >
>> > > > >>>CPU utilization might not be largely affected if the threads are
>> > > > sitting there waiting on IO
>> > > > Ok, seems I got it.
>> > > > If one thread spends most of its time waiting for I/O completion
>> > instead
>> > > > of using the CPU, but does not mean that "we've hit the system I/O
>> > > > bandwidth limit", then IMHO having multiple threads (or asynchronous
>> > I/O)
>> > > > might improve performance (by enabling more than one concurrent I/O
>> > > > operation).
>> > > >
>> > > > -Rakesh
>> > > > ________________________________________
>> > > > From: Flavio Junqueira [fpj@yahoo-inc.com]
>> > > > Sent: Wednesday, September 26, 2012 2:17 PM
>> > > > To: bookkeeper-dev@zookeeper.apache.org
>> > > > Subject: Re: High latencies observed at the bookkeeper client while
>> > > > reading entries
>> > > >
>> > > > CPU utilization might not be largely affected if the threads are
>> > sitting
>> > > > there waiting on IO. In my understanding of the proposal so far, the
>> > idea
>> > > > is to have multiple threads only to perform IO.
>> > > >
>> > > > One question: what is multi-ledgers?
>> > > >
>> > > > -Flavio
>> > > >
>> > > >
>> > > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
>> > > >
>> > > > > I just adding one more point:
>> > > > >
>> > > > > Increasing the number of threads, can hit the CPU utilization too.
>> > > Also,
>> > > > we would consider this and good to observe whether its more on I/O
>> > bound
>> > > > than CPU bound. However, it depends in great detail on the disks and
>> > how
>> > > > much CPU work other threads are doing before they, too, end up
>> waiting
>> > on
>> > > > those disks.
>> > > > >
>> > > > > I'm also thinking inline with Flavio's suggestion to have one
>> thread
>> > > per
>> > > > ledger/journal device. Multithreading can help us with I/O bound
>> > problems
>> > > > if the I/O is perform against different disks.
>> > > > >
>> > > > > From the iostat report: waiting time of ledger directories. It
>> shows
>> > we
>> > > > have options to fully utilizing the disk bandwidth.
>> > > > >
>> > > > > multi-ledgers disk usage:
>> > > > > avgqu-sz
>> > > > > 1.10
>> > > > > 0.12
>> > > > > 0.54
>> > > > > 0.13
>> > > > >
>> > > > > -Rakesh
>> > > > > ________________________________________
>> > > > > From: Sijie Guo [guosijie@gmail.com]
>> > > > > Sent: Wednesday, September 26, 2012 5:58 AM
>> > > > > To: bookkeeper-dev@zookeeper.apache.org
>> > > > > Subject: Re: High latencies observed at the bookkeeper client
>> while
>> > > > reading entries
>> > > > >
>> > > > > One more point is that each write/read request to entry log files
>> > would
>> > > > be
>> > > > > converted to write/read a 8K blob data, since you used
>> > BufferedChannel.
>> > > > For
>> > > > > write requests, a larger write size is OK. For read requests, they
>> > are
>> > > > > almost randomly. Even you read a larger blob, the blob might be
>> > useless
>> > > > > when next read goes to other place. Even more, I don't think we
>> need
>> > to
>> > > > > maintain another fixed length readBuffer in BufferedChannel, it
>> > almost
>> > > > > doesn't help for random reads, we could leverage OS cache for it.
>> > > > >
>> > > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com>
>> > wrote:
>> > > > >
>> > > > >> For serving requests, either queuing the requests in bookie
>> server
>> > per
>> > > > >> channel (write/read are blocking operations), or queueing in os
>> > kernel
>> > > > to
>> > > > >> let block device queuing and schedule those io requests. I think
>> > Stu's
>> > > > >> point is to leverage block device's schedule algorithm to issue
>> io
>> > > > requests
>> > > > >> in multiple threads to fully utilize the disk bandwidth.
>> > > > >>
>> > > > >> from the iostat reports provided by Aniruddha, the average queue
>> > > length
>> > > > >> and utilized percentage are not high, which means most of time
>> the
>> > > disks
>> > > > >> are idle. It makes sense to use multiple threads to issue read
>> > > requests.
>> > > > >> one write thread and several read threads might work for each
>> > device.
>> > > > >>
>> > > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
>> > fpj@yahoo-inc.com
>> > > > >wrote:
>> > > > >>
>> > > > >>> Hi Stu, I'm not sure I understand your point. If with one
>> thread we
>> > > are
>> > > > >>> getting pretty high latency (case Aniruddha described), doesn't
>> it
>> > > > mean we
>> > > > >>> have a number of requests queued up? Adding more threads might
>> only
>> > > > make
>> > > > >>> the problem worse by queueing up even more requests. I'm
>> possibly
>> > > > missing
>> > > > >>> your point...
>> > > > >>>
>> > > > >>> -Flavio
>> > > > >>>
>> > > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>> > > > >>>
>> > > > >>>> Separating by device would help, but will not allow the
>> devices to
>> > > be
>> > > > >>> fully
>> > > > >>>> utilized: in order to buffer enough io commands into a disk's
>> > queue
>> > > > for
>> > > > >>> the
>> > > > >>>> elevator algorithms to kick in, you either need to use multiple
>> > > > threads
>> > > > >>> per
>> > > > >>>> disk, or native async IO (not trivially available within the
>> JVM.)
>> > > > >>>>
>> > > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
>> > > fpj@yahoo-inc.com>
>> > > > >>> wrote:
>> > > > >>>>
>> > > > >>>>>
>> > > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>> > > > >>>>>
>> > > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
>> > > > fpj@yahoo-inc.com>
>> > > > >>>>> wrote:
>> > > > >>>>>>
>> > > > >>>>>>> Just to add a couple of comments to the discussion,
>> separating
>> > > > reads
>> > > > >>> and
>> > > > >>>>>>> writes into different threads should only help with queuing
>> > > > latency.
>> > > > >>> It
>> > > > >>>>>>> wouldn't help with IO latency.
>> > > > >>>>>>>
>> > > > >>>>>>
>> > > > >>>>>> Yes, but with the current implementation, publishes
>> latencies in
>> > > > >>> hedwig
>> > > > >>>>>> suffer because of lagging subscribers. By separating read and
>> > > write
>> > > > >>>>> queues,
>> > > > >>>>>> we can at least guarantee that the write SLA is maintained
>> > > (separate
>> > > > >>>>>> journal disk + separate thread would ensure that writes are
>> not
>> > > > >>> affected
>> > > > >>>>> by
>> > > > >>>>>> read related seeks)
>> > > > >>>>>>
>> > > > >>>>>
>> > > > >>>>> Agreed and based on my comment below, I was wondering if it
>> > > wouldn't
>> > > > be
>> > > > >>>>> best to separate traffic across threads by device instead of
>> by
>> > > > >>> operation
>> > > > >>>>> type.
>> > > > >>>>>
>> > > > >>>>>
>> > > > >>>>>>>
>> > > > >>>>>>> Also, it sounds like a good idea to have at least one thread
>> > per
>> > > > >>> ledger
>> > > > >>>>>>> device. In the case of multiple ledger devices, if we use
>> one
>> > > > single
>> > > > >>>>>>> thread, then the performance of the bookie will be driven by
>> > the
>> > > > >>> slowest
>> > > > >>>>>>> disk, no?
>> > > > >>>>>>>
>> > > > >>>>>> yup, makes sense.
>> > > > >>>>>>
>> > > > >>>>>>>
>> > > > >>>>>>> -Flavio
>> > > > >>>>>>>
>> > > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>> > > > >>>>>>>
>> > > > >>>>>>>>> Could you give some information on what those shortcomings
>> > are?
>> > > > >>> Also,
>> > > > >>>>> do
>> > > > >>>>>>>>> let me know if you need any more information from our end.
>> > > > >>>>>>>> Off the top of my head:
>> > > > >>>>>>>> - reads and writes are handled in the same thread (as you
>> have
>> > > > >>>>> observed)
>> > > > >>>>>>>> - each entry read requires a single RPC.
>> > > > >>>>>>>> - entries are read in parallel
>> > > > >>>>>>>
>> > > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
>> > > > >>> FileChannel,
>> > > > >>>>>> right?
>> > > > >>>>>>
>> > > > >>>>>>>>
>> > > > >>>>>>>> Not all of these could result in the high latency you see,
>> but
>> > > if
>> > > > >>> each
>> > > > >>>>>>>> entry is being read separately, a sync on the ledger disk
>> in
>> > > > between
>> > > > >>>>>>>> will make a mess of the disk head scheduling.
>> > > > >>>>>>>
>> > > > >>>>>> Increasing the time interval between  flushing log files
>> might
>> > > > >>> possibly
>> > > > >>>>>> help in this case then?
>> > > > >>>>>>
>> > > > >>>>>>>>
>> > > > >>>>>>>> -Ivan
>> > > > >>>>>>>
>> > > > >>>>>>>
>> > > > >>>>>> Thanks for the help :)
>> > > > >>>>>
>> > > > >>>>>
>> > > > >>>
>> > > > >>>
>> > > >
>> > >
>> >
>>
>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
> I was talking about writing to the journal file. From what I understand,
log file entries
> are flushed periodically by one thread and that is okay. The publish
> latencies on hedwig are
> dependent on the journal writes, though.

I was confused now. Journal file is flushed periodically by 'BookieJournal'
thread not the entry log file.

The write code path would be:

1) adding entry into entry log file
2) putting index to ledger cache
3) logAddEntry to journal.

1) and 2) is synchronized calls. if 1) and 2) took long time, it would
affect other requests in PerChannelBookieClient, since
PerChannelBookieClient process requests one by one.

3) is asynchronous call, just putting add entry into journal queue. 3)
would not affect other requests in PerChannelBookieClient.

but 3) would affect the response latency for adding entry. we already took
care about it to let journal flushing into a  separated journal disk. so 3)
would not be the cause for high latencies.

so my understanding is that previous email discussions are talking about
entry log file which is in the code path for read/write. so the discussion
is that we need to separate read/write requests to different threads to
avoid effection between them. isn't it? If I am wrong about it, please
correct me.


On Thu, Sep 27, 2012 at 9:39 AM, Aniruddha Laud <tr...@gmail.com>wrote:

> On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com> wrote:
>
> > Sounds good to have thread pool (and make them configurable) for reading
> > from entry log files.
> >
> > > We can have a write threadpool (and we should always keep this
> > lower than the number of processors) to process the add requests.
> >
> > one more point, since we had only one entry log file active accepting
> entry
> > written to it. I don't think multiple write threads would help now, since
> > adding entry to entry log file is synchronized method.
> >
> I was talking about writing to the journal file. From what I understand,
> log file entries
> are flushed periodically by one thread and that is okay. The publish
> latencies on hedwig are
> dependent on the journal writes, though.
>
> >
> > In order to utilize the disk bandwidth more efficiently, we might need to
> > have one active entry log file accepting entry written per ledger disk.
> But
> > it might need to introduce some directory layout change (like logId,
> > currently we using incrementing log id for whole bookie) and logic
> > changes.  it would be a separated task if did that.
> >
> > > Another thing we could possibly look at is re ordering our writes to
> the
> > log file to try and maintain locality for ledger entries.
> >
> > We had a prototype work internally working on using leveldb to store 1)
> > small entries data (size less than hundred of bytes), 2) ledger index for
> > large entries (acts as ledger cache for index entries). Benefiting from
> > leveldb, 1) we could have more efficient cache when there are larger
> number
> > of ledgers and size skew between ledgers, 2) we could have data belonging
> > to same ledger clustered when writing to disks, which achieves what you
> > mentioned 'reordering writes' in somehow.
> >
> I took at look at the leveldb homepage and it says - "Only a single process
> (possibly multi-threaded) can access a particular database at a time."
> This is bad because it means we can't run the console or any recovery
> related operations while the bookies are running. I may be wrong, though.
> What I had in mind was pretty simple. When we flush to the log file, we
> should simply flush entries sorted by the ledger id as key. Some changes
> might be needed to the ledger index cache, but I'm not very sure what the
> changes would be. What do you think?
>
> >
> > -Sijie
> >
> > On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
> > <tr...@gmail.com>wrote:
> >
> > > Hi all,
> > >
> > > Those stats I pasted might be a little misleading as they show the
> > average
> > > over a couple of minutes. Whenever there are reads to the ledger disks,
> > the
> > > queue size on them is sometimes as high as 100. Also, the CPU
> utilization
> > > has been lower than 10% throughout and the process will continue to
> > remain
> > > I/O bound even if we introduce more threads (As the CPU remains idle
> > while
> > > doing I/O).
> > >
> > > A couple of observations about the write path. We currently have a hard
> > > coded buffer size for journal writes (I believe it's 512KB) and we
> flush
> > to
> > > the disk when this fills up or if there is no entry to process (which
> is
> > > highly unlikely in case of a high throughput application running on
> top).
> > > We should make this buffer size configurable. Now, with more threads,
> we
> > > can process more packets in parallel and this buffer can be filled up
> > > faster. We can have a write threadpool (and we should always keep this
> > > lower than the number of processors) to process the add requests.
> > >
> > > For read requests, a configurable number of worker threads would be
> ideal
> > > and we could let the user tune it depending on the kind of read
> patterns
> > > they expect. Given that ledgers are interleaved ATM, I would expect the
> > > performance to increase linearly with the number of threads till a
> > certain
> > > point and then level out.
> > >
> > > Another thing we could possibly look at is re ordering our writes to
> the
> > > log file to try and maintain locality for ledger entries. This might
> > reduce
> > > the number of random seeks we do in case only a small number of ledgers
> > are
> > > lagging.
> > >
> > > Thoughts?
> > >
> > > Regards,
> > > Aniruddha.
> > >
> > > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com> wrote:
> > >
> > > > >>>One question: what is multi-ledgers?
> > > > multiple ledgers directories(muliple disks)
> > > >
> > > > >>>CPU utilization might not be largely affected if the threads are
> > > > sitting there waiting on IO
> > > > Ok, seems I got it.
> > > > If one thread spends most of its time waiting for I/O completion
> > instead
> > > > of using the CPU, but does not mean that "we've hit the system I/O
> > > > bandwidth limit", then IMHO having multiple threads (or asynchronous
> > I/O)
> > > > might improve performance (by enabling more than one concurrent I/O
> > > > operation).
> > > >
> > > > -Rakesh
> > > > ________________________________________
> > > > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > > > Sent: Wednesday, September 26, 2012 2:17 PM
> > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > Subject: Re: High latencies observed at the bookkeeper client while
> > > > reading entries
> > > >
> > > > CPU utilization might not be largely affected if the threads are
> > sitting
> > > > there waiting on IO. In my understanding of the proposal so far, the
> > idea
> > > > is to have multiple threads only to perform IO.
> > > >
> > > > One question: what is multi-ledgers?
> > > >
> > > > -Flavio
> > > >
> > > >
> > > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> > > >
> > > > > I just adding one more point:
> > > > >
> > > > > Increasing the number of threads, can hit the CPU utilization too.
> > > Also,
> > > > we would consider this and good to observe whether its more on I/O
> > bound
> > > > than CPU bound. However, it depends in great detail on the disks and
> > how
> > > > much CPU work other threads are doing before they, too, end up
> waiting
> > on
> > > > those disks.
> > > > >
> > > > > I'm also thinking inline with Flavio's suggestion to have one
> thread
> > > per
> > > > ledger/journal device. Multithreading can help us with I/O bound
> > problems
> > > > if the I/O is perform against different disks.
> > > > >
> > > > > From the iostat report: waiting time of ledger directories. It
> shows
> > we
> > > > have options to fully utilizing the disk bandwidth.
> > > > >
> > > > > multi-ledgers disk usage:
> > > > > avgqu-sz
> > > > > 1.10
> > > > > 0.12
> > > > > 0.54
> > > > > 0.13
> > > > >
> > > > > -Rakesh
> > > > > ________________________________________
> > > > > From: Sijie Guo [guosijie@gmail.com]
> > > > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > > Subject: Re: High latencies observed at the bookkeeper client while
> > > > reading entries
> > > > >
> > > > > One more point is that each write/read request to entry log files
> > would
> > > > be
> > > > > converted to write/read a 8K blob data, since you used
> > BufferedChannel.
> > > > For
> > > > > write requests, a larger write size is OK. For read requests, they
> > are
> > > > > almost randomly. Even you read a larger blob, the blob might be
> > useless
> > > > > when next read goes to other place. Even more, I don't think we
> need
> > to
> > > > > maintain another fixed length readBuffer in BufferedChannel, it
> > almost
> > > > > doesn't help for random reads, we could leverage OS cache for it.
> > > > >
> > > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com>
> > wrote:
> > > > >
> > > > >> For serving requests, either queuing the requests in bookie server
> > per
> > > > >> channel (write/read are blocking operations), or queueing in os
> > kernel
> > > > to
> > > > >> let block device queuing and schedule those io requests. I think
> > Stu's
> > > > >> point is to leverage block device's schedule algorithm to issue io
> > > > requests
> > > > >> in multiple threads to fully utilize the disk bandwidth.
> > > > >>
> > > > >> from the iostat reports provided by Aniruddha, the average queue
> > > length
> > > > >> and utilized percentage are not high, which means most of time the
> > > disks
> > > > >> are idle. It makes sense to use multiple threads to issue read
> > > requests.
> > > > >> one write thread and several read threads might work for each
> > device.
> > > > >>
> > > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
> > fpj@yahoo-inc.com
> > > > >wrote:
> > > > >>
> > > > >>> Hi Stu, I'm not sure I understand your point. If with one thread
> we
> > > are
> > > > >>> getting pretty high latency (case Aniruddha described), doesn't
> it
> > > > mean we
> > > > >>> have a number of requests queued up? Adding more threads might
> only
> > > > make
> > > > >>> the problem worse by queueing up even more requests. I'm possibly
> > > > missing
> > > > >>> your point...
> > > > >>>
> > > > >>> -Flavio
> > > > >>>
> > > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > > > >>>
> > > > >>>> Separating by device would help, but will not allow the devices
> to
> > > be
> > > > >>> fully
> > > > >>>> utilized: in order to buffer enough io commands into a disk's
> > queue
> > > > for
> > > > >>> the
> > > > >>>> elevator algorithms to kick in, you either need to use multiple
> > > > threads
> > > > >>> per
> > > > >>>> disk, or native async IO (not trivially available within the
> JVM.)
> > > > >>>>
> > > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> > > fpj@yahoo-inc.com>
> > > > >>> wrote:
> > > > >>>>
> > > > >>>>>
> > > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > > > >>>>>
> > > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > > > fpj@yahoo-inc.com>
> > > > >>>>> wrote:
> > > > >>>>>>
> > > > >>>>>>> Just to add a couple of comments to the discussion,
> separating
> > > > reads
> > > > >>> and
> > > > >>>>>>> writes into different threads should only help with queuing
> > > > latency.
> > > > >>> It
> > > > >>>>>>> wouldn't help with IO latency.
> > > > >>>>>>>
> > > > >>>>>>
> > > > >>>>>> Yes, but with the current implementation, publishes latencies
> in
> > > > >>> hedwig
> > > > >>>>>> suffer because of lagging subscribers. By separating read and
> > > write
> > > > >>>>> queues,
> > > > >>>>>> we can at least guarantee that the write SLA is maintained
> > > (separate
> > > > >>>>>> journal disk + separate thread would ensure that writes are
> not
> > > > >>> affected
> > > > >>>>> by
> > > > >>>>>> read related seeks)
> > > > >>>>>>
> > > > >>>>>
> > > > >>>>> Agreed and based on my comment below, I was wondering if it
> > > wouldn't
> > > > be
> > > > >>>>> best to separate traffic across threads by device instead of by
> > > > >>> operation
> > > > >>>>> type.
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>>>
> > > > >>>>>>> Also, it sounds like a good idea to have at least one thread
> > per
> > > > >>> ledger
> > > > >>>>>>> device. In the case of multiple ledger devices, if we use one
> > > > single
> > > > >>>>>>> thread, then the performance of the bookie will be driven by
> > the
> > > > >>> slowest
> > > > >>>>>>> disk, no?
> > > > >>>>>>>
> > > > >>>>>> yup, makes sense.
> > > > >>>>>>
> > > > >>>>>>>
> > > > >>>>>>> -Flavio
> > > > >>>>>>>
> > > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > > > >>>>>>>
> > > > >>>>>>>>> Could you give some information on what those shortcomings
> > are?
> > > > >>> Also,
> > > > >>>>> do
> > > > >>>>>>>>> let me know if you need any more information from our end.
> > > > >>>>>>>> Off the top of my head:
> > > > >>>>>>>> - reads and writes are handled in the same thread (as you
> have
> > > > >>>>> observed)
> > > > >>>>>>>> - each entry read requires a single RPC.
> > > > >>>>>>>> - entries are read in parallel
> > > > >>>>>>>
> > > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
> > > > >>> FileChannel,
> > > > >>>>>> right?
> > > > >>>>>>
> > > > >>>>>>>>
> > > > >>>>>>>> Not all of these could result in the high latency you see,
> but
> > > if
> > > > >>> each
> > > > >>>>>>>> entry is being read separately, a sync on the ledger disk in
> > > > between
> > > > >>>>>>>> will make a mess of the disk head scheduling.
> > > > >>>>>>>
> > > > >>>>>> Increasing the time interval between  flushing log files might
> > > > >>> possibly
> > > > >>>>>> help in this case then?
> > > > >>>>>>
> > > > >>>>>>>>
> > > > >>>>>>>> -Ivan
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> Thanks for the help :)
> > > > >>>>>
> > > > >>>>>
> > > > >>>
> > > > >>>
> > > >
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
On Wed, Sep 26, 2012 at 5:06 PM, Sijie Guo <gu...@gmail.com> wrote:

> Sounds good to have thread pool (and make them configurable) for reading
> from entry log files.
>
> > We can have a write threadpool (and we should always keep this
> lower than the number of processors) to process the add requests.
>
> one more point, since we had only one entry log file active accepting entry
> written to it. I don't think multiple write threads would help now, since
> adding entry to entry log file is synchronized method.
>
I was talking about writing to the journal file. From what I understand,
log file entries
are flushed periodically by one thread and that is okay. The publish
latencies on hedwig are
dependent on the journal writes, though.

>
> In order to utilize the disk bandwidth more efficiently, we might need to
> have one active entry log file accepting entry written per ledger disk. But
> it might need to introduce some directory layout change (like logId,
> currently we using incrementing log id for whole bookie) and logic
> changes.  it would be a separated task if did that.
>
> > Another thing we could possibly look at is re ordering our writes to the
> log file to try and maintain locality for ledger entries.
>
> We had a prototype work internally working on using leveldb to store 1)
> small entries data (size less than hundred of bytes), 2) ledger index for
> large entries (acts as ledger cache for index entries). Benefiting from
> leveldb, 1) we could have more efficient cache when there are larger number
> of ledgers and size skew between ledgers, 2) we could have data belonging
> to same ledger clustered when writing to disks, which achieves what you
> mentioned 'reordering writes' in somehow.
>
I took at look at the leveldb homepage and it says - "Only a single process
(possibly multi-threaded) can access a particular database at a time."
This is bad because it means we can't run the console or any recovery
related operations while the bookies are running. I may be wrong, though.
What I had in mind was pretty simple. When we flush to the log file, we
should simply flush entries sorted by the ledger id as key. Some changes
might be needed to the ledger index cache, but I'm not very sure what the
changes would be. What do you think?

>
> -Sijie
>
> On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
> <tr...@gmail.com>wrote:
>
> > Hi all,
> >
> > Those stats I pasted might be a little misleading as they show the
> average
> > over a couple of minutes. Whenever there are reads to the ledger disks,
> the
> > queue size on them is sometimes as high as 100. Also, the CPU utilization
> > has been lower than 10% throughout and the process will continue to
> remain
> > I/O bound even if we introduce more threads (As the CPU remains idle
> while
> > doing I/O).
> >
> > A couple of observations about the write path. We currently have a hard
> > coded buffer size for journal writes (I believe it's 512KB) and we flush
> to
> > the disk when this fills up or if there is no entry to process (which is
> > highly unlikely in case of a high throughput application running on top).
> > We should make this buffer size configurable. Now, with more threads, we
> > can process more packets in parallel and this buffer can be filled up
> > faster. We can have a write threadpool (and we should always keep this
> > lower than the number of processors) to process the add requests.
> >
> > For read requests, a configurable number of worker threads would be ideal
> > and we could let the user tune it depending on the kind of read patterns
> > they expect. Given that ledgers are interleaved ATM, I would expect the
> > performance to increase linearly with the number of threads till a
> certain
> > point and then level out.
> >
> > Another thing we could possibly look at is re ordering our writes to the
> > log file to try and maintain locality for ledger entries. This might
> reduce
> > the number of random seeks we do in case only a small number of ledgers
> are
> > lagging.
> >
> > Thoughts?
> >
> > Regards,
> > Aniruddha.
> >
> > On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com> wrote:
> >
> > > >>>One question: what is multi-ledgers?
> > > multiple ledgers directories(muliple disks)
> > >
> > > >>>CPU utilization might not be largely affected if the threads are
> > > sitting there waiting on IO
> > > Ok, seems I got it.
> > > If one thread spends most of its time waiting for I/O completion
> instead
> > > of using the CPU, but does not mean that "we've hit the system I/O
> > > bandwidth limit", then IMHO having multiple threads (or asynchronous
> I/O)
> > > might improve performance (by enabling more than one concurrent I/O
> > > operation).
> > >
> > > -Rakesh
> > > ________________________________________
> > > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > > Sent: Wednesday, September 26, 2012 2:17 PM
> > > To: bookkeeper-dev@zookeeper.apache.org
> > > Subject: Re: High latencies observed at the bookkeeper client while
> > > reading entries
> > >
> > > CPU utilization might not be largely affected if the threads are
> sitting
> > > there waiting on IO. In my understanding of the proposal so far, the
> idea
> > > is to have multiple threads only to perform IO.
> > >
> > > One question: what is multi-ledgers?
> > >
> > > -Flavio
> > >
> > >
> > > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> > >
> > > > I just adding one more point:
> > > >
> > > > Increasing the number of threads, can hit the CPU utilization too.
> > Also,
> > > we would consider this and good to observe whether its more on I/O
> bound
> > > than CPU bound. However, it depends in great detail on the disks and
> how
> > > much CPU work other threads are doing before they, too, end up waiting
> on
> > > those disks.
> > > >
> > > > I'm also thinking inline with Flavio's suggestion to have one thread
> > per
> > > ledger/journal device. Multithreading can help us with I/O bound
> problems
> > > if the I/O is perform against different disks.
> > > >
> > > > From the iostat report: waiting time of ledger directories. It shows
> we
> > > have options to fully utilizing the disk bandwidth.
> > > >
> > > > multi-ledgers disk usage:
> > > > avgqu-sz
> > > > 1.10
> > > > 0.12
> > > > 0.54
> > > > 0.13
> > > >
> > > > -Rakesh
> > > > ________________________________________
> > > > From: Sijie Guo [guosijie@gmail.com]
> > > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > > To: bookkeeper-dev@zookeeper.apache.org
> > > > Subject: Re: High latencies observed at the bookkeeper client while
> > > reading entries
> > > >
> > > > One more point is that each write/read request to entry log files
> would
> > > be
> > > > converted to write/read a 8K blob data, since you used
> BufferedChannel.
> > > For
> > > > write requests, a larger write size is OK. For read requests, they
> are
> > > > almost randomly. Even you read a larger blob, the blob might be
> useless
> > > > when next read goes to other place. Even more, I don't think we need
> to
> > > > maintain another fixed length readBuffer in BufferedChannel, it
> almost
> > > > doesn't help for random reads, we could leverage OS cache for it.
> > > >
> > > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com>
> wrote:
> > > >
> > > >> For serving requests, either queuing the requests in bookie server
> per
> > > >> channel (write/read are blocking operations), or queueing in os
> kernel
> > > to
> > > >> let block device queuing and schedule those io requests. I think
> Stu's
> > > >> point is to leverage block device's schedule algorithm to issue io
> > > requests
> > > >> in multiple threads to fully utilize the disk bandwidth.
> > > >>
> > > >> from the iostat reports provided by Aniruddha, the average queue
> > length
> > > >> and utilized percentage are not high, which means most of time the
> > disks
> > > >> are idle. It makes sense to use multiple threads to issue read
> > requests.
> > > >> one write thread and several read threads might work for each
> device.
> > > >>
> > > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <
> fpj@yahoo-inc.com
> > > >wrote:
> > > >>
> > > >>> Hi Stu, I'm not sure I understand your point. If with one thread we
> > are
> > > >>> getting pretty high latency (case Aniruddha described), doesn't it
> > > mean we
> > > >>> have a number of requests queued up? Adding more threads might only
> > > make
> > > >>> the problem worse by queueing up even more requests. I'm possibly
> > > missing
> > > >>> your point...
> > > >>>
> > > >>> -Flavio
> > > >>>
> > > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > > >>>
> > > >>>> Separating by device would help, but will not allow the devices to
> > be
> > > >>> fully
> > > >>>> utilized: in order to buffer enough io commands into a disk's
> queue
> > > for
> > > >>> the
> > > >>>> elevator algorithms to kick in, you either need to use multiple
> > > threads
> > > >>> per
> > > >>>> disk, or native async IO (not trivially available within the JVM.)
> > > >>>>
> > > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> > fpj@yahoo-inc.com>
> > > >>> wrote:
> > > >>>>
> > > >>>>>
> > > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > > >>>>>
> > > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > > fpj@yahoo-inc.com>
> > > >>>>> wrote:
> > > >>>>>>
> > > >>>>>>> Just to add a couple of comments to the discussion, separating
> > > reads
> > > >>> and
> > > >>>>>>> writes into different threads should only help with queuing
> > > latency.
> > > >>> It
> > > >>>>>>> wouldn't help with IO latency.
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>> Yes, but with the current implementation, publishes latencies in
> > > >>> hedwig
> > > >>>>>> suffer because of lagging subscribers. By separating read and
> > write
> > > >>>>> queues,
> > > >>>>>> we can at least guarantee that the write SLA is maintained
> > (separate
> > > >>>>>> journal disk + separate thread would ensure that writes are not
> > > >>> affected
> > > >>>>> by
> > > >>>>>> read related seeks)
> > > >>>>>>
> > > >>>>>
> > > >>>>> Agreed and based on my comment below, I was wondering if it
> > wouldn't
> > > be
> > > >>>>> best to separate traffic across threads by device instead of by
> > > >>> operation
> > > >>>>> type.
> > > >>>>>
> > > >>>>>
> > > >>>>>>>
> > > >>>>>>> Also, it sounds like a good idea to have at least one thread
> per
> > > >>> ledger
> > > >>>>>>> device. In the case of multiple ledger devices, if we use one
> > > single
> > > >>>>>>> thread, then the performance of the bookie will be driven by
> the
> > > >>> slowest
> > > >>>>>>> disk, no?
> > > >>>>>>>
> > > >>>>>> yup, makes sense.
> > > >>>>>>
> > > >>>>>>>
> > > >>>>>>> -Flavio
> > > >>>>>>>
> > > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > > >>>>>>>
> > > >>>>>>>>> Could you give some information on what those shortcomings
> are?
> > > >>> Also,
> > > >>>>> do
> > > >>>>>>>>> let me know if you need any more information from our end.
> > > >>>>>>>> Off the top of my head:
> > > >>>>>>>> - reads and writes are handled in the same thread (as you have
> > > >>>>> observed)
> > > >>>>>>>> - each entry read requires a single RPC.
> > > >>>>>>>> - entries are read in parallel
> > > >>>>>>>
> > > >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
> > > >>> FileChannel,
> > > >>>>>> right?
> > > >>>>>>
> > > >>>>>>>>
> > > >>>>>>>> Not all of these could result in the high latency you see, but
> > if
> > > >>> each
> > > >>>>>>>> entry is being read separately, a sync on the ledger disk in
> > > between
> > > >>>>>>>> will make a mess of the disk head scheduling.
> > > >>>>>>>
> > > >>>>>> Increasing the time interval between  flushing log files might
> > > >>> possibly
> > > >>>>>> help in this case then?
> > > >>>>>>
> > > >>>>>>>>
> > > >>>>>>>> -Ivan
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>> Thanks for the help :)
> > > >>>>>
> > > >>>>>
> > > >>>
> > > >>>
> > >
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
Sounds good to have thread pool (and make them configurable) for reading
from entry log files.

> We can have a write threadpool (and we should always keep this
lower than the number of processors) to process the add requests.

one more point, since we had only one entry log file active accepting entry
written to it. I don't think multiple write threads would help now, since
adding entry to entry log file is synchronized method.

In order to utilize the disk bandwidth more efficiently, we might need to
have one active entry log file accepting entry written per ledger disk. But
it might need to introduce some directory layout change (like logId,
currently we using incrementing log id for whole bookie) and logic
changes.  it would be a separated task if did that.

> Another thing we could possibly look at is re ordering our writes to the
log file to try and maintain locality for ledger entries.

We had a prototype work internally working on using leveldb to store 1)
small entries data (size less than hundred of bytes), 2) ledger index for
large entries (acts as ledger cache for index entries). Benefiting from
leveldb, 1) we could have more efficient cache when there are larger number
of ledgers and size skew between ledgers, 2) we could have data belonging
to same ledger clustered when writing to disks, which achieves what you
mentioned 'reordering writes' in somehow.

-Sijie

On Thu, Sep 27, 2012 at 12:52 AM, Aniruddha Laud
<tr...@gmail.com>wrote:

> Hi all,
>
> Those stats I pasted might be a little misleading as they show the average
> over a couple of minutes. Whenever there are reads to the ledger disks, the
> queue size on them is sometimes as high as 100. Also, the CPU utilization
> has been lower than 10% throughout and the process will continue to remain
> I/O bound even if we introduce more threads (As the CPU remains idle while
> doing I/O).
>
> A couple of observations about the write path. We currently have a hard
> coded buffer size for journal writes (I believe it's 512KB) and we flush to
> the disk when this fills up or if there is no entry to process (which is
> highly unlikely in case of a high throughput application running on top).
> We should make this buffer size configurable. Now, with more threads, we
> can process more packets in parallel and this buffer can be filled up
> faster. We can have a write threadpool (and we should always keep this
> lower than the number of processors) to process the add requests.
>
> For read requests, a configurable number of worker threads would be ideal
> and we could let the user tune it depending on the kind of read patterns
> they expect. Given that ledgers are interleaved ATM, I would expect the
> performance to increase linearly with the number of threads till a certain
> point and then level out.
>
> Another thing we could possibly look at is re ordering our writes to the
> log file to try and maintain locality for ledger entries. This might reduce
> the number of random seeks we do in case only a small number of ledgers are
> lagging.
>
> Thoughts?
>
> Regards,
> Aniruddha.
>
> On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com> wrote:
>
> > >>>One question: what is multi-ledgers?
> > multiple ledgers directories(muliple disks)
> >
> > >>>CPU utilization might not be largely affected if the threads are
> > sitting there waiting on IO
> > Ok, seems I got it.
> > If one thread spends most of its time waiting for I/O completion instead
> > of using the CPU, but does not mean that "we've hit the system I/O
> > bandwidth limit", then IMHO having multiple threads (or asynchronous I/O)
> > might improve performance (by enabling more than one concurrent I/O
> > operation).
> >
> > -Rakesh
> > ________________________________________
> > From: Flavio Junqueira [fpj@yahoo-inc.com]
> > Sent: Wednesday, September 26, 2012 2:17 PM
> > To: bookkeeper-dev@zookeeper.apache.org
> > Subject: Re: High latencies observed at the bookkeeper client while
> > reading entries
> >
> > CPU utilization might not be largely affected if the threads are sitting
> > there waiting on IO. In my understanding of the proposal so far, the idea
> > is to have multiple threads only to perform IO.
> >
> > One question: what is multi-ledgers?
> >
> > -Flavio
> >
> >
> > On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
> >
> > > I just adding one more point:
> > >
> > > Increasing the number of threads, can hit the CPU utilization too.
> Also,
> > we would consider this and good to observe whether its more on I/O bound
> > than CPU bound. However, it depends in great detail on the disks and how
> > much CPU work other threads are doing before they, too, end up waiting on
> > those disks.
> > >
> > > I'm also thinking inline with Flavio's suggestion to have one thread
> per
> > ledger/journal device. Multithreading can help us with I/O bound problems
> > if the I/O is perform against different disks.
> > >
> > > From the iostat report: waiting time of ledger directories. It shows we
> > have options to fully utilizing the disk bandwidth.
> > >
> > > multi-ledgers disk usage:
> > > avgqu-sz
> > > 1.10
> > > 0.12
> > > 0.54
> > > 0.13
> > >
> > > -Rakesh
> > > ________________________________________
> > > From: Sijie Guo [guosijie@gmail.com]
> > > Sent: Wednesday, September 26, 2012 5:58 AM
> > > To: bookkeeper-dev@zookeeper.apache.org
> > > Subject: Re: High latencies observed at the bookkeeper client while
> > reading entries
> > >
> > > One more point is that each write/read request to entry log files would
> > be
> > > converted to write/read a 8K blob data, since you used BufferedChannel.
> > For
> > > write requests, a larger write size is OK. For read requests, they are
> > > almost randomly. Even you read a larger blob, the blob might be useless
> > > when next read goes to other place. Even more, I don't think we need to
> > > maintain another fixed length readBuffer in BufferedChannel, it almost
> > > doesn't help for random reads, we could leverage OS cache for it.
> > >
> > > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com> wrote:
> > >
> > >> For serving requests, either queuing the requests in bookie server per
> > >> channel (write/read are blocking operations), or queueing in os kernel
> > to
> > >> let block device queuing and schedule those io requests. I think Stu's
> > >> point is to leverage block device's schedule algorithm to issue io
> > requests
> > >> in multiple threads to fully utilize the disk bandwidth.
> > >>
> > >> from the iostat reports provided by Aniruddha, the average queue
> length
> > >> and utilized percentage are not high, which means most of time the
> disks
> > >> are idle. It makes sense to use multiple threads to issue read
> requests.
> > >> one write thread and several read threads might work for each device.
> > >>
> > >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fpj@yahoo-inc.com
> > >wrote:
> > >>
> > >>> Hi Stu, I'm not sure I understand your point. If with one thread we
> are
> > >>> getting pretty high latency (case Aniruddha described), doesn't it
> > mean we
> > >>> have a number of requests queued up? Adding more threads might only
> > make
> > >>> the problem worse by queueing up even more requests. I'm possibly
> > missing
> > >>> your point...
> > >>>
> > >>> -Flavio
> > >>>
> > >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> > >>>
> > >>>> Separating by device would help, but will not allow the devices to
> be
> > >>> fully
> > >>>> utilized: in order to buffer enough io commands into a disk's queue
> > for
> > >>> the
> > >>>> elevator algorithms to kick in, you either need to use multiple
> > threads
> > >>> per
> > >>>> disk, or native async IO (not trivially available within the JVM.)
> > >>>>
> > >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <
> fpj@yahoo-inc.com>
> > >>> wrote:
> > >>>>
> > >>>>>
> > >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> > >>>>>
> > >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> > fpj@yahoo-inc.com>
> > >>>>> wrote:
> > >>>>>>
> > >>>>>>> Just to add a couple of comments to the discussion, separating
> > reads
> > >>> and
> > >>>>>>> writes into different threads should only help with queuing
> > latency.
> > >>> It
> > >>>>>>> wouldn't help with IO latency.
> > >>>>>>>
> > >>>>>>
> > >>>>>> Yes, but with the current implementation, publishes latencies in
> > >>> hedwig
> > >>>>>> suffer because of lagging subscribers. By separating read and
> write
> > >>>>> queues,
> > >>>>>> we can at least guarantee that the write SLA is maintained
> (separate
> > >>>>>> journal disk + separate thread would ensure that writes are not
> > >>> affected
> > >>>>> by
> > >>>>>> read related seeks)
> > >>>>>>
> > >>>>>
> > >>>>> Agreed and based on my comment below, I was wondering if it
> wouldn't
> > be
> > >>>>> best to separate traffic across threads by device instead of by
> > >>> operation
> > >>>>> type.
> > >>>>>
> > >>>>>
> > >>>>>>>
> > >>>>>>> Also, it sounds like a good idea to have at least one thread per
> > >>> ledger
> > >>>>>>> device. In the case of multiple ledger devices, if we use one
> > single
> > >>>>>>> thread, then the performance of the bookie will be driven by the
> > >>> slowest
> > >>>>>>> disk, no?
> > >>>>>>>
> > >>>>>> yup, makes sense.
> > >>>>>>
> > >>>>>>>
> > >>>>>>> -Flavio
> > >>>>>>>
> > >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> > >>>>>>>
> > >>>>>>>>> Could you give some information on what those shortcomings are?
> > >>> Also,
> > >>>>> do
> > >>>>>>>>> let me know if you need any more information from our end.
> > >>>>>>>> Off the top of my head:
> > >>>>>>>> - reads and writes are handled in the same thread (as you have
> > >>>>> observed)
> > >>>>>>>> - each entry read requires a single RPC.
> > >>>>>>>> - entries are read in parallel
> > >>>>>>>
> > >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
> > >>> FileChannel,
> > >>>>>> right?
> > >>>>>>
> > >>>>>>>>
> > >>>>>>>> Not all of these could result in the high latency you see, but
> if
> > >>> each
> > >>>>>>>> entry is being read separately, a sync on the ledger disk in
> > between
> > >>>>>>>> will make a mess of the disk head scheduling.
> > >>>>>>>
> > >>>>>> Increasing the time interval between  flushing log files might
> > >>> possibly
> > >>>>>> help in this case then?
> > >>>>>>
> > >>>>>>>>
> > >>>>>>>> -Ivan
> > >>>>>>>
> > >>>>>>>
> > >>>>>> Thanks for the help :)
> > >>>>>
> > >>>>>
> > >>>
> > >>>
> >
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
Hi all,

Those stats I pasted might be a little misleading as they show the average
over a couple of minutes. Whenever there are reads to the ledger disks, the
queue size on them is sometimes as high as 100. Also, the CPU utilization
has been lower than 10% throughout and the process will continue to remain
I/O bound even if we introduce more threads (As the CPU remains idle while
doing I/O).

A couple of observations about the write path. We currently have a hard
coded buffer size for journal writes (I believe it's 512KB) and we flush to
the disk when this fills up or if there is no entry to process (which is
highly unlikely in case of a high throughput application running on top).
We should make this buffer size configurable. Now, with more threads, we
can process more packets in parallel and this buffer can be filled up
faster. We can have a write threadpool (and we should always keep this
lower than the number of processors) to process the add requests.

For read requests, a configurable number of worker threads would be ideal
and we could let the user tune it depending on the kind of read patterns
they expect. Given that ledgers are interleaved ATM, I would expect the
performance to increase linearly with the number of threads till a certain
point and then level out.

Another thing we could possibly look at is re ordering our writes to the
log file to try and maintain locality for ledger entries. This might reduce
the number of random seeks we do in case only a small number of ledgers are
lagging.

Thoughts?

Regards,
Aniruddha.

On Wed, Sep 26, 2012 at 2:55 AM, Rakesh R <ra...@huawei.com> wrote:

> >>>One question: what is multi-ledgers?
> multiple ledgers directories(muliple disks)
>
> >>>CPU utilization might not be largely affected if the threads are
> sitting there waiting on IO
> Ok, seems I got it.
> If one thread spends most of its time waiting for I/O completion instead
> of using the CPU, but does not mean that "we've hit the system I/O
> bandwidth limit", then IMHO having multiple threads (or asynchronous I/O)
> might improve performance (by enabling more than one concurrent I/O
> operation).
>
> -Rakesh
> ________________________________________
> From: Flavio Junqueira [fpj@yahoo-inc.com]
> Sent: Wednesday, September 26, 2012 2:17 PM
> To: bookkeeper-dev@zookeeper.apache.org
> Subject: Re: High latencies observed at the bookkeeper client while
> reading entries
>
> CPU utilization might not be largely affected if the threads are sitting
> there waiting on IO. In my understanding of the proposal so far, the idea
> is to have multiple threads only to perform IO.
>
> One question: what is multi-ledgers?
>
> -Flavio
>
>
> On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:
>
> > I just adding one more point:
> >
> > Increasing the number of threads, can hit the CPU utilization too. Also,
> we would consider this and good to observe whether its more on I/O bound
> than CPU bound. However, it depends in great detail on the disks and how
> much CPU work other threads are doing before they, too, end up waiting on
> those disks.
> >
> > I'm also thinking inline with Flavio's suggestion to have one thread per
> ledger/journal device. Multithreading can help us with I/O bound problems
> if the I/O is perform against different disks.
> >
> > From the iostat report: waiting time of ledger directories. It shows we
> have options to fully utilizing the disk bandwidth.
> >
> > multi-ledgers disk usage:
> > avgqu-sz
> > 1.10
> > 0.12
> > 0.54
> > 0.13
> >
> > -Rakesh
> > ________________________________________
> > From: Sijie Guo [guosijie@gmail.com]
> > Sent: Wednesday, September 26, 2012 5:58 AM
> > To: bookkeeper-dev@zookeeper.apache.org
> > Subject: Re: High latencies observed at the bookkeeper client while
> reading entries
> >
> > One more point is that each write/read request to entry log files would
> be
> > converted to write/read a 8K blob data, since you used BufferedChannel.
> For
> > write requests, a larger write size is OK. For read requests, they are
> > almost randomly. Even you read a larger blob, the blob might be useless
> > when next read goes to other place. Even more, I don't think we need to
> > maintain another fixed length readBuffer in BufferedChannel, it almost
> > doesn't help for random reads, we could leverage OS cache for it.
> >
> > On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com> wrote:
> >
> >> For serving requests, either queuing the requests in bookie server per
> >> channel (write/read are blocking operations), or queueing in os kernel
> to
> >> let block device queuing and schedule those io requests. I think Stu's
> >> point is to leverage block device's schedule algorithm to issue io
> requests
> >> in multiple threads to fully utilize the disk bandwidth.
> >>
> >> from the iostat reports provided by Aniruddha, the average queue length
> >> and utilized percentage are not high, which means most of time the disks
> >> are idle. It makes sense to use multiple threads to issue read requests.
> >> one write thread and several read threads might work for each device.
> >>
> >> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fpj@yahoo-inc.com
> >wrote:
> >>
> >>> Hi Stu, I'm not sure I understand your point. If with one thread we are
> >>> getting pretty high latency (case Aniruddha described), doesn't it
> mean we
> >>> have a number of requests queued up? Adding more threads might only
> make
> >>> the problem worse by queueing up even more requests. I'm possibly
> missing
> >>> your point...
> >>>
> >>> -Flavio
> >>>
> >>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
> >>>
> >>>> Separating by device would help, but will not allow the devices to be
> >>> fully
> >>>> utilized: in order to buffer enough io commands into a disk's queue
> for
> >>> the
> >>>> elevator algorithms to kick in, you either need to use multiple
> threads
> >>> per
> >>>> disk, or native async IO (not trivially available within the JVM.)
> >>>>
> >>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
> >>> wrote:
> >>>>
> >>>>>
> >>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> >>>>>
> >>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <
> fpj@yahoo-inc.com>
> >>>>> wrote:
> >>>>>>
> >>>>>>> Just to add a couple of comments to the discussion, separating
> reads
> >>> and
> >>>>>>> writes into different threads should only help with queuing
> latency.
> >>> It
> >>>>>>> wouldn't help with IO latency.
> >>>>>>>
> >>>>>>
> >>>>>> Yes, but with the current implementation, publishes latencies in
> >>> hedwig
> >>>>>> suffer because of lagging subscribers. By separating read and write
> >>>>> queues,
> >>>>>> we can at least guarantee that the write SLA is maintained (separate
> >>>>>> journal disk + separate thread would ensure that writes are not
> >>> affected
> >>>>> by
> >>>>>> read related seeks)
> >>>>>>
> >>>>>
> >>>>> Agreed and based on my comment below, I was wondering if it wouldn't
> be
> >>>>> best to separate traffic across threads by device instead of by
> >>> operation
> >>>>> type.
> >>>>>
> >>>>>
> >>>>>>>
> >>>>>>> Also, it sounds like a good idea to have at least one thread per
> >>> ledger
> >>>>>>> device. In the case of multiple ledger devices, if we use one
> single
> >>>>>>> thread, then the performance of the bookie will be driven by the
> >>> slowest
> >>>>>>> disk, no?
> >>>>>>>
> >>>>>> yup, makes sense.
> >>>>>>
> >>>>>>>
> >>>>>>> -Flavio
> >>>>>>>
> >>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> >>>>>>>
> >>>>>>>>> Could you give some information on what those shortcomings are?
> >>> Also,
> >>>>> do
> >>>>>>>>> let me know if you need any more information from our end.
> >>>>>>>> Off the top of my head:
> >>>>>>>> - reads and writes are handled in the same thread (as you have
> >>>>> observed)
> >>>>>>>> - each entry read requires a single RPC.
> >>>>>>>> - entries are read in parallel
> >>>>>>>
> >>>>>> By parallel, you mean the BufferedChannel wrapper on top of
> >>> FileChannel,
> >>>>>> right?
> >>>>>>
> >>>>>>>>
> >>>>>>>> Not all of these could result in the high latency you see, but if
> >>> each
> >>>>>>>> entry is being read separately, a sync on the ledger disk in
> between
> >>>>>>>> will make a mess of the disk head scheduling.
> >>>>>>>
> >>>>>> Increasing the time interval between  flushing log files might
> >>> possibly
> >>>>>> help in this case then?
> >>>>>>
> >>>>>>>>
> >>>>>>>> -Ivan
> >>>>>>>
> >>>>>>>
> >>>>>> Thanks for the help :)
> >>>>>
> >>>>>
> >>>
> >>>
>

RE: High latencies observed at the bookkeeper client while reading entries

Posted by Rakesh R <ra...@huawei.com>.
>>>One question: what is multi-ledgers?
multiple ledgers directories(muliple disks)

>>>CPU utilization might not be largely affected if the threads are sitting there waiting on IO
Ok, seems I got it.
If one thread spends most of its time waiting for I/O completion instead of using the CPU, but does not mean that "we've hit the system I/O bandwidth limit", then IMHO having multiple threads (or asynchronous I/O) might improve performance (by enabling more than one concurrent I/O operation).

-Rakesh
________________________________________
From: Flavio Junqueira [fpj@yahoo-inc.com]
Sent: Wednesday, September 26, 2012 2:17 PM
To: bookkeeper-dev@zookeeper.apache.org
Subject: Re: High latencies observed at the bookkeeper client while reading entries

CPU utilization might not be largely affected if the threads are sitting there waiting on IO. In my understanding of the proposal so far, the idea is to have multiple threads only to perform IO.

One question: what is multi-ledgers?

-Flavio


On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:

> I just adding one more point:
>
> Increasing the number of threads, can hit the CPU utilization too. Also, we would consider this and good to observe whether its more on I/O bound than CPU bound. However, it depends in great detail on the disks and how much CPU work other threads are doing before they, too, end up waiting on those disks.
>
> I'm also thinking inline with Flavio's suggestion to have one thread per ledger/journal device. Multithreading can help us with I/O bound problems if the I/O is perform against different disks.
>
> From the iostat report: waiting time of ledger directories. It shows we have options to fully utilizing the disk bandwidth.
>
> multi-ledgers disk usage:
> avgqu-sz
> 1.10
> 0.12
> 0.54
> 0.13
>
> -Rakesh
> ________________________________________
> From: Sijie Guo [guosijie@gmail.com]
> Sent: Wednesday, September 26, 2012 5:58 AM
> To: bookkeeper-dev@zookeeper.apache.org
> Subject: Re: High latencies observed at the bookkeeper client while reading entries
>
> One more point is that each write/read request to entry log files would be
> converted to write/read a 8K blob data, since you used BufferedChannel. For
> write requests, a larger write size is OK. For read requests, they are
> almost randomly. Even you read a larger blob, the blob might be useless
> when next read goes to other place. Even more, I don't think we need to
> maintain another fixed length readBuffer in BufferedChannel, it almost
> doesn't help for random reads, we could leverage OS cache for it.
>
> On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com> wrote:
>
>> For serving requests, either queuing the requests in bookie server per
>> channel (write/read are blocking operations), or queueing in os kernel to
>> let block device queuing and schedule those io requests. I think Stu's
>> point is to leverage block device's schedule algorithm to issue io requests
>> in multiple threads to fully utilize the disk bandwidth.
>>
>> from the iostat reports provided by Aniruddha, the average queue length
>> and utilized percentage are not high, which means most of time the disks
>> are idle. It makes sense to use multiple threads to issue read requests.
>> one write thread and several read threads might work for each device.
>>
>> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fp...@yahoo-inc.com>wrote:
>>
>>> Hi Stu, I'm not sure I understand your point. If with one thread we are
>>> getting pretty high latency (case Aniruddha described), doesn't it mean we
>>> have a number of requests queued up? Adding more threads might only make
>>> the problem worse by queueing up even more requests. I'm possibly missing
>>> your point...
>>>
>>> -Flavio
>>>
>>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>>>
>>>> Separating by device would help, but will not allow the devices to be
>>> fully
>>>> utilized: in order to buffer enough io commands into a disk's queue for
>>> the
>>>> elevator algorithms to kick in, you either need to use multiple threads
>>> per
>>>> disk, or native async IO (not trivially available within the JVM.)
>>>>
>>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>>> wrote:
>>>>
>>>>>
>>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>>>>>
>>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>>>>> wrote:
>>>>>>
>>>>>>> Just to add a couple of comments to the discussion, separating reads
>>> and
>>>>>>> writes into different threads should only help with queuing latency.
>>> It
>>>>>>> wouldn't help with IO latency.
>>>>>>>
>>>>>>
>>>>>> Yes, but with the current implementation, publishes latencies in
>>> hedwig
>>>>>> suffer because of lagging subscribers. By separating read and write
>>>>> queues,
>>>>>> we can at least guarantee that the write SLA is maintained (separate
>>>>>> journal disk + separate thread would ensure that writes are not
>>> affected
>>>>> by
>>>>>> read related seeks)
>>>>>>
>>>>>
>>>>> Agreed and based on my comment below, I was wondering if it wouldn't be
>>>>> best to separate traffic across threads by device instead of by
>>> operation
>>>>> type.
>>>>>
>>>>>
>>>>>>>
>>>>>>> Also, it sounds like a good idea to have at least one thread per
>>> ledger
>>>>>>> device. In the case of multiple ledger devices, if we use one single
>>>>>>> thread, then the performance of the bookie will be driven by the
>>> slowest
>>>>>>> disk, no?
>>>>>>>
>>>>>> yup, makes sense.
>>>>>>
>>>>>>>
>>>>>>> -Flavio
>>>>>>>
>>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>>>>>>>
>>>>>>>>> Could you give some information on what those shortcomings are?
>>> Also,
>>>>> do
>>>>>>>>> let me know if you need any more information from our end.
>>>>>>>> Off the top of my head:
>>>>>>>> - reads and writes are handled in the same thread (as you have
>>>>> observed)
>>>>>>>> - each entry read requires a single RPC.
>>>>>>>> - entries are read in parallel
>>>>>>>
>>>>>> By parallel, you mean the BufferedChannel wrapper on top of
>>> FileChannel,
>>>>>> right?
>>>>>>
>>>>>>>>
>>>>>>>> Not all of these could result in the high latency you see, but if
>>> each
>>>>>>>> entry is being read separately, a sync on the ledger disk in between
>>>>>>>> will make a mess of the disk head scheduling.
>>>>>>>
>>>>>> Increasing the time interval between  flushing log files might
>>> possibly
>>>>>> help in this case then?
>>>>>>
>>>>>>>>
>>>>>>>> -Ivan
>>>>>>>
>>>>>>>
>>>>>> Thanks for the help :)
>>>>>
>>>>>
>>>
>>>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
CPU utilization might not be largely affected if the threads are sitting there waiting on IO. In my understanding of the proposal so far, the idea is to have multiple threads only to perform IO. 

One question: what is multi-ledgers?

-Flavio


On Sep 26, 2012, at 7:52 AM, Rakesh R wrote:

> I just adding one more point:
> 
> Increasing the number of threads, can hit the CPU utilization too. Also, we would consider this and good to observe whether its more on I/O bound than CPU bound. However, it depends in great detail on the disks and how much CPU work other threads are doing before they, too, end up waiting on those disks.
> 
> I'm also thinking inline with Flavio's suggestion to have one thread per ledger/journal device. Multithreading can help us with I/O bound problems if the I/O is perform against different disks. 
> 
> From the iostat report: waiting time of ledger directories. It shows we have options to fully utilizing the disk bandwidth. 
> 
> multi-ledgers disk usage:
> avgqu-sz 
> 1.10 
> 0.12 
> 0.54
> 0.13
> 
> -Rakesh
> ________________________________________
> From: Sijie Guo [guosijie@gmail.com]
> Sent: Wednesday, September 26, 2012 5:58 AM
> To: bookkeeper-dev@zookeeper.apache.org
> Subject: Re: High latencies observed at the bookkeeper client while reading entries
> 
> One more point is that each write/read request to entry log files would be
> converted to write/read a 8K blob data, since you used BufferedChannel. For
> write requests, a larger write size is OK. For read requests, they are
> almost randomly. Even you read a larger blob, the blob might be useless
> when next read goes to other place. Even more, I don't think we need to
> maintain another fixed length readBuffer in BufferedChannel, it almost
> doesn't help for random reads, we could leverage OS cache for it.
> 
> On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com> wrote:
> 
>> For serving requests, either queuing the requests in bookie server per
>> channel (write/read are blocking operations), or queueing in os kernel to
>> let block device queuing and schedule those io requests. I think Stu's
>> point is to leverage block device's schedule algorithm to issue io requests
>> in multiple threads to fully utilize the disk bandwidth.
>> 
>> from the iostat reports provided by Aniruddha, the average queue length
>> and utilized percentage are not high, which means most of time the disks
>> are idle. It makes sense to use multiple threads to issue read requests.
>> one write thread and several read threads might work for each device.
>> 
>> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fp...@yahoo-inc.com>wrote:
>> 
>>> Hi Stu, I'm not sure I understand your point. If with one thread we are
>>> getting pretty high latency (case Aniruddha described), doesn't it mean we
>>> have a number of requests queued up? Adding more threads might only make
>>> the problem worse by queueing up even more requests. I'm possibly missing
>>> your point...
>>> 
>>> -Flavio
>>> 
>>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>>> 
>>>> Separating by device would help, but will not allow the devices to be
>>> fully
>>>> utilized: in order to buffer enough io commands into a disk's queue for
>>> the
>>>> elevator algorithms to kick in, you either need to use multiple threads
>>> per
>>>> disk, or native async IO (not trivially available within the JVM.)
>>>> 
>>>> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>>> wrote:
>>>> 
>>>>> 
>>>>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>>>>> 
>>>>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>>>>> wrote:
>>>>>> 
>>>>>>> Just to add a couple of comments to the discussion, separating reads
>>> and
>>>>>>> writes into different threads should only help with queuing latency.
>>> It
>>>>>>> wouldn't help with IO latency.
>>>>>>> 
>>>>>> 
>>>>>> Yes, but with the current implementation, publishes latencies in
>>> hedwig
>>>>>> suffer because of lagging subscribers. By separating read and write
>>>>> queues,
>>>>>> we can at least guarantee that the write SLA is maintained (separate
>>>>>> journal disk + separate thread would ensure that writes are not
>>> affected
>>>>> by
>>>>>> read related seeks)
>>>>>> 
>>>>> 
>>>>> Agreed and based on my comment below, I was wondering if it wouldn't be
>>>>> best to separate traffic across threads by device instead of by
>>> operation
>>>>> type.
>>>>> 
>>>>> 
>>>>>>> 
>>>>>>> Also, it sounds like a good idea to have at least one thread per
>>> ledger
>>>>>>> device. In the case of multiple ledger devices, if we use one single
>>>>>>> thread, then the performance of the bookie will be driven by the
>>> slowest
>>>>>>> disk, no?
>>>>>>> 
>>>>>> yup, makes sense.
>>>>>> 
>>>>>>> 
>>>>>>> -Flavio
>>>>>>> 
>>>>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>>>>>>> 
>>>>>>>>> Could you give some information on what those shortcomings are?
>>> Also,
>>>>> do
>>>>>>>>> let me know if you need any more information from our end.
>>>>>>>> Off the top of my head:
>>>>>>>> - reads and writes are handled in the same thread (as you have
>>>>> observed)
>>>>>>>> - each entry read requires a single RPC.
>>>>>>>> - entries are read in parallel
>>>>>>> 
>>>>>> By parallel, you mean the BufferedChannel wrapper on top of
>>> FileChannel,
>>>>>> right?
>>>>>> 
>>>>>>>> 
>>>>>>>> Not all of these could result in the high latency you see, but if
>>> each
>>>>>>>> entry is being read separately, a sync on the ledger disk in between
>>>>>>>> will make a mess of the disk head scheduling.
>>>>>>> 
>>>>>> Increasing the time interval between  flushing log files might
>>> possibly
>>>>>> help in this case then?
>>>>>> 
>>>>>>>> 
>>>>>>>> -Ivan
>>>>>>> 
>>>>>>> 
>>>>>> Thanks for the help :)
>>>>> 
>>>>> 
>>> 
>>> 


RE: High latencies observed at the bookkeeper client while reading entries

Posted by Rakesh R <ra...@huawei.com>.
I just adding one more point:

Increasing the number of threads, can hit the CPU utilization too. Also, we would consider this and good to observe whether its more on I/O bound than CPU bound. However, it depends in great detail on the disks and how much CPU work other threads are doing before they, too, end up waiting on those disks.

I'm also thinking inline with Flavio's suggestion to have one thread per ledger/journal device. Multithreading can help us with I/O bound problems if the I/O is perform against different disks. 

>From the iostat report: waiting time of ledger directories. It shows we have options to fully utilizing the disk bandwidth. 

multi-ledgers disk usage:
avgqu-sz 
1.10 
0.12 
0.54
0.13

-Rakesh
________________________________________
From: Sijie Guo [guosijie@gmail.com]
Sent: Wednesday, September 26, 2012 5:58 AM
To: bookkeeper-dev@zookeeper.apache.org
Subject: Re: High latencies observed at the bookkeeper client while reading entries

One more point is that each write/read request to entry log files would be
converted to write/read a 8K blob data, since you used BufferedChannel. For
write requests, a larger write size is OK. For read requests, they are
almost randomly. Even you read a larger blob, the blob might be useless
when next read goes to other place. Even more, I don't think we need to
maintain another fixed length readBuffer in BufferedChannel, it almost
doesn't help for random reads, we could leverage OS cache for it.

On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com> wrote:

> For serving requests, either queuing the requests in bookie server per
> channel (write/read are blocking operations), or queueing in os kernel to
> let block device queuing and schedule those io requests. I think Stu's
> point is to leverage block device's schedule algorithm to issue io requests
> in multiple threads to fully utilize the disk bandwidth.
>
> from the iostat reports provided by Aniruddha, the average queue length
> and utilized percentage are not high, which means most of time the disks
> are idle. It makes sense to use multiple threads to issue read requests.
> one write thread and several read threads might work for each device.
>
> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fp...@yahoo-inc.com>wrote:
>
>> Hi Stu, I'm not sure I understand your point. If with one thread we are
>> getting pretty high latency (case Aniruddha described), doesn't it mean we
>> have a number of requests queued up? Adding more threads might only make
>> the problem worse by queueing up even more requests. I'm possibly missing
>> your point...
>>
>> -Flavio
>>
>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>>
>> > Separating by device would help, but will not allow the devices to be
>> fully
>> > utilized: in order to buffer enough io commands into a disk's queue for
>> the
>> > elevator algorithms to kick in, you either need to use multiple threads
>> per
>> > disk, or native async IO (not trivially available within the JVM.)
>> >
>> > On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> wrote:
>> >
>> >>
>> >> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>> >>
>> >>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> >> wrote:
>> >>>
>> >>>> Just to add a couple of comments to the discussion, separating reads
>> and
>> >>>> writes into different threads should only help with queuing latency.
>> It
>> >>>> wouldn't help with IO latency.
>> >>>>
>> >>>
>> >>> Yes, but with the current implementation, publishes latencies in
>> hedwig
>> >>> suffer because of lagging subscribers. By separating read and write
>> >> queues,
>> >>> we can at least guarantee that the write SLA is maintained (separate
>> >>> journal disk + separate thread would ensure that writes are not
>> affected
>> >> by
>> >>> read related seeks)
>> >>>
>> >>
>> >> Agreed and based on my comment below, I was wondering if it wouldn't be
>> >> best to separate traffic across threads by device instead of by
>> operation
>> >> type.
>> >>
>> >>
>> >>>>
>> >>>> Also, it sounds like a good idea to have at least one thread per
>> ledger
>> >>>> device. In the case of multiple ledger devices, if we use one single
>> >>>> thread, then the performance of the bookie will be driven by the
>> slowest
>> >>>> disk, no?
>> >>>>
>> >>> yup, makes sense.
>> >>>
>> >>>>
>> >>>> -Flavio
>> >>>>
>> >>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>> >>>>
>> >>>>>> Could you give some information on what those shortcomings are?
>> Also,
>> >> do
>> >>>>>> let me know if you need any more information from our end.
>> >>>>> Off the top of my head:
>> >>>>> - reads and writes are handled in the same thread (as you have
>> >> observed)
>> >>>>> - each entry read requires a single RPC.
>> >>>>> - entries are read in parallel
>> >>>>
>> >>> By parallel, you mean the BufferedChannel wrapper on top of
>> FileChannel,
>> >>> right?
>> >>>
>> >>>>>
>> >>>>> Not all of these could result in the high latency you see, but if
>> each
>> >>>>> entry is being read separately, a sync on the ledger disk in between
>> >>>>> will make a mess of the disk head scheduling.
>> >>>>
>> >>> Increasing the time interval between  flushing log files might
>> possibly
>> >>> help in this case then?
>> >>>
>> >>>>>
>> >>>>> -Ivan
>> >>>>
>> >>>>
>> >>> Thanks for the help :)
>> >>
>> >>
>>
>>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
One more point is that each write/read request to entry log files would be
converted to write/read a 8K blob data, since you used BufferedChannel. For
write requests, a larger write size is OK. For read requests, they are
almost randomly. Even you read a larger blob, the blob might be useless
when next read goes to other place. Even more, I don't think we need to
maintain another fixed length readBuffer in BufferedChannel, it almost
doesn't help for random reads, we could leverage OS cache for it.

On Wed, Sep 26, 2012 at 8:06 AM, Sijie Guo <gu...@gmail.com> wrote:

> For serving requests, either queuing the requests in bookie server per
> channel (write/read are blocking operations), or queueing in os kernel to
> let block device queuing and schedule those io requests. I think Stu's
> point is to leverage block device's schedule algorithm to issue io requests
> in multiple threads to fully utilize the disk bandwidth.
>
> from the iostat reports provided by Aniruddha, the average queue length
> and utilized percentage are not high, which means most of time the disks
> are idle. It makes sense to use multiple threads to issue read requests.
> one write thread and several read threads might work for each device.
>
> On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fp...@yahoo-inc.com>wrote:
>
>> Hi Stu, I'm not sure I understand your point. If with one thread we are
>> getting pretty high latency (case Aniruddha described), doesn't it mean we
>> have a number of requests queued up? Adding more threads might only make
>> the problem worse by queueing up even more requests. I'm possibly missing
>> your point...
>>
>> -Flavio
>>
>> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>>
>> > Separating by device would help, but will not allow the devices to be
>> fully
>> > utilized: in order to buffer enough io commands into a disk's queue for
>> the
>> > elevator algorithms to kick in, you either need to use multiple threads
>> per
>> > disk, or native async IO (not trivially available within the JVM.)
>> >
>> > On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> wrote:
>> >
>> >>
>> >> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>> >>
>> >>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> >> wrote:
>> >>>
>> >>>> Just to add a couple of comments to the discussion, separating reads
>> and
>> >>>> writes into different threads should only help with queuing latency.
>> It
>> >>>> wouldn't help with IO latency.
>> >>>>
>> >>>
>> >>> Yes, but with the current implementation, publishes latencies in
>> hedwig
>> >>> suffer because of lagging subscribers. By separating read and write
>> >> queues,
>> >>> we can at least guarantee that the write SLA is maintained (separate
>> >>> journal disk + separate thread would ensure that writes are not
>> affected
>> >> by
>> >>> read related seeks)
>> >>>
>> >>
>> >> Agreed and based on my comment below, I was wondering if it wouldn't be
>> >> best to separate traffic across threads by device instead of by
>> operation
>> >> type.
>> >>
>> >>
>> >>>>
>> >>>> Also, it sounds like a good idea to have at least one thread per
>> ledger
>> >>>> device. In the case of multiple ledger devices, if we use one single
>> >>>> thread, then the performance of the bookie will be driven by the
>> slowest
>> >>>> disk, no?
>> >>>>
>> >>> yup, makes sense.
>> >>>
>> >>>>
>> >>>> -Flavio
>> >>>>
>> >>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>> >>>>
>> >>>>>> Could you give some information on what those shortcomings are?
>> Also,
>> >> do
>> >>>>>> let me know if you need any more information from our end.
>> >>>>> Off the top of my head:
>> >>>>> - reads and writes are handled in the same thread (as you have
>> >> observed)
>> >>>>> - each entry read requires a single RPC.
>> >>>>> - entries are read in parallel
>> >>>>
>> >>> By parallel, you mean the BufferedChannel wrapper on top of
>> FileChannel,
>> >>> right?
>> >>>
>> >>>>>
>> >>>>> Not all of these could result in the high latency you see, but if
>> each
>> >>>>> entry is being read separately, a sync on the ledger disk in between
>> >>>>> will make a mess of the disk head scheduling.
>> >>>>
>> >>> Increasing the time interval between  flushing log files might
>> possibly
>> >>> help in this case then?
>> >>>
>> >>>>>
>> >>>>> -Ivan
>> >>>>
>> >>>>
>> >>> Thanks for the help :)
>> >>
>> >>
>>
>>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Sijie Guo <gu...@gmail.com>.
For serving requests, either queuing the requests in bookie server per
channel (write/read are blocking operations), or queueing in os kernel to
let block device queuing and schedule those io requests. I think Stu's
point is to leverage block device's schedule algorithm to issue io requests
in multiple threads to fully utilize the disk bandwidth.

from the iostat reports provided by Aniruddha, the average queue length and
utilized percentage are not high, which means most of time the disks are
idle. It makes sense to use multiple threads to issue read requests. one
write thread and several read threads might work for each device.

On Wed, Sep 26, 2012 at 5:06 AM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:

> Hi Stu, I'm not sure I understand your point. If with one thread we are
> getting pretty high latency (case Aniruddha described), doesn't it mean we
> have a number of requests queued up? Adding more threads might only make
> the problem worse by queueing up even more requests. I'm possibly missing
> your point...
>
> -Flavio
>
> On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:
>
> > Separating by device would help, but will not allow the devices to be
> fully
> > utilized: in order to buffer enough io commands into a disk's queue for
> the
> > elevator algorithms to kick in, you either need to use multiple threads
> per
> > disk, or native async IO (not trivially available within the JVM.)
> >
> > On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com>
> wrote:
> >
> >>
> >> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
> >>
> >>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
> >> wrote:
> >>>
> >>>> Just to add a couple of comments to the discussion, separating reads
> and
> >>>> writes into different threads should only help with queuing latency.
> It
> >>>> wouldn't help with IO latency.
> >>>>
> >>>
> >>> Yes, but with the current implementation, publishes latencies in hedwig
> >>> suffer because of lagging subscribers. By separating read and write
> >> queues,
> >>> we can at least guarantee that the write SLA is maintained (separate
> >>> journal disk + separate thread would ensure that writes are not
> affected
> >> by
> >>> read related seeks)
> >>>
> >>
> >> Agreed and based on my comment below, I was wondering if it wouldn't be
> >> best to separate traffic across threads by device instead of by
> operation
> >> type.
> >>
> >>
> >>>>
> >>>> Also, it sounds like a good idea to have at least one thread per
> ledger
> >>>> device. In the case of multiple ledger devices, if we use one single
> >>>> thread, then the performance of the bookie will be driven by the
> slowest
> >>>> disk, no?
> >>>>
> >>> yup, makes sense.
> >>>
> >>>>
> >>>> -Flavio
> >>>>
> >>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> >>>>
> >>>>>> Could you give some information on what those shortcomings are?
> Also,
> >> do
> >>>>>> let me know if you need any more information from our end.
> >>>>> Off the top of my head:
> >>>>> - reads and writes are handled in the same thread (as you have
> >> observed)
> >>>>> - each entry read requires a single RPC.
> >>>>> - entries are read in parallel
> >>>>
> >>> By parallel, you mean the BufferedChannel wrapper on top of
> FileChannel,
> >>> right?
> >>>
> >>>>>
> >>>>> Not all of these could result in the high latency you see, but if
> each
> >>>>> entry is being read separately, a sync on the ledger disk in between
> >>>>> will make a mess of the disk head scheduling.
> >>>>
> >>> Increasing the time interval between  flushing log files might possibly
> >>> help in this case then?
> >>>
> >>>>>
> >>>>> -Ivan
> >>>>
> >>>>
> >>> Thanks for the help :)
> >>
> >>
>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
Hi Stu, I'm not sure I understand your point. If with one thread we are getting pretty high latency (case Aniruddha described), doesn't it mean we have a number of requests queued up? Adding more threads might only make the problem worse by queueing up even more requests. I'm possibly missing your point...

-Flavio

On Sep 25, 2012, at 9:37 PM, Stu Hood wrote:

> Separating by device would help, but will not allow the devices to be fully
> utilized: in order to buffer enough io commands into a disk's queue for the
> elevator algorithms to kick in, you either need to use multiple threads per
> disk, or native async IO (not trivially available within the JVM.)
> 
> On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:
> 
>> 
>> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>> 
>>> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
>> wrote:
>>> 
>>>> Just to add a couple of comments to the discussion, separating reads and
>>>> writes into different threads should only help with queuing latency. It
>>>> wouldn't help with IO latency.
>>>> 
>>> 
>>> Yes, but with the current implementation, publishes latencies in hedwig
>>> suffer because of lagging subscribers. By separating read and write
>> queues,
>>> we can at least guarantee that the write SLA is maintained (separate
>>> journal disk + separate thread would ensure that writes are not affected
>> by
>>> read related seeks)
>>> 
>> 
>> Agreed and based on my comment below, I was wondering if it wouldn't be
>> best to separate traffic across threads by device instead of by operation
>> type.
>> 
>> 
>>>> 
>>>> Also, it sounds like a good idea to have at least one thread per ledger
>>>> device. In the case of multiple ledger devices, if we use one single
>>>> thread, then the performance of the bookie will be driven by the slowest
>>>> disk, no?
>>>> 
>>> yup, makes sense.
>>> 
>>>> 
>>>> -Flavio
>>>> 
>>>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>>>> 
>>>>>> Could you give some information on what those shortcomings are? Also,
>> do
>>>>>> let me know if you need any more information from our end.
>>>>> Off the top of my head:
>>>>> - reads and writes are handled in the same thread (as you have
>> observed)
>>>>> - each entry read requires a single RPC.
>>>>> - entries are read in parallel
>>>> 
>>> By parallel, you mean the BufferedChannel wrapper on top of FileChannel,
>>> right?
>>> 
>>>>> 
>>>>> Not all of these could result in the high latency you see, but if each
>>>>> entry is being read separately, a sync on the ledger disk in between
>>>>> will make a mess of the disk head scheduling.
>>>> 
>>> Increasing the time interval between  flushing log files might possibly
>>> help in this case then?
>>> 
>>>>> 
>>>>> -Ivan
>>>> 
>>>> 
>>> Thanks for the help :)
>> 
>> 


Re: High latencies observed at the bookkeeper client while reading entries

Posted by Stu Hood <st...@twitter.com>.
Separating by device would help, but will not allow the devices to be fully
utilized: in order to buffer enough io commands into a disk's queue for the
elevator algorithms to kick in, you either need to use multiple threads per
disk, or native async IO (not trivially available within the JVM.)

On Tue, Sep 25, 2012 at 2:23 AM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:

>
> On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:
>
> > On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com>
> wrote:
> >
> >> Just to add a couple of comments to the discussion, separating reads and
> >> writes into different threads should only help with queuing latency. It
> >> wouldn't help with IO latency.
> >>
> >
> > Yes, but with the current implementation, publishes latencies in hedwig
> > suffer because of lagging subscribers. By separating read and write
> queues,
> > we can at least guarantee that the write SLA is maintained (separate
> > journal disk + separate thread would ensure that writes are not affected
> by
> > read related seeks)
> >
>
> Agreed and based on my comment below, I was wondering if it wouldn't be
> best to separate traffic across threads by device instead of by operation
> type.
>
>
> >>
> >> Also, it sounds like a good idea to have at least one thread per ledger
> >> device. In the case of multiple ledger devices, if we use one single
> >> thread, then the performance of the bookie will be driven by the slowest
> >> disk, no?
> >>
> > yup, makes sense.
> >
> >>
> >> -Flavio
> >>
> >> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
> >>
> >>>> Could you give some information on what those shortcomings are? Also,
> do
> >>>> let me know if you need any more information from our end.
> >>> Off the top of my head:
> >>> - reads and writes are handled in the same thread (as you have
> observed)
> >>> - each entry read requires a single RPC.
> >>> - entries are read in parallel
> >>
> > By parallel, you mean the BufferedChannel wrapper on top of FileChannel,
> > right?
> >
> >>>
> >>> Not all of these could result in the high latency you see, but if each
> >>> entry is being read separately, a sync on the ledger disk in between
> >>> will make a mess of the disk head scheduling.
> >>
> > Increasing the time interval between  flushing log files might possibly
> > help in this case then?
> >
> >>>
> >>> -Ivan
> >>
> >>
> > Thanks for the help :)
>
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
On Sep 25, 2012, at 10:55 AM, Aniruddha Laud wrote:

> On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:
> 
>> Just to add a couple of comments to the discussion, separating reads and
>> writes into different threads should only help with queuing latency. It
>> wouldn't help with IO latency.
>> 
> 
> Yes, but with the current implementation, publishes latencies in hedwig
> suffer because of lagging subscribers. By separating read and write queues,
> we can at least guarantee that the write SLA is maintained (separate
> journal disk + separate thread would ensure that writes are not affected by
> read related seeks)
> 

Agreed and based on my comment below, I was wondering if it wouldn't be best to separate traffic across threads by device instead of by operation type.


>> 
>> Also, it sounds like a good idea to have at least one thread per ledger
>> device. In the case of multiple ledger devices, if we use one single
>> thread, then the performance of the bookie will be driven by the slowest
>> disk, no?
>> 
> yup, makes sense.
> 
>> 
>> -Flavio
>> 
>> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>> 
>>>> Could you give some information on what those shortcomings are? Also, do
>>>> let me know if you need any more information from our end.
>>> Off the top of my head:
>>> - reads and writes are handled in the same thread (as you have observed)
>>> - each entry read requires a single RPC.
>>> - entries are read in parallel
>> 
> By parallel, you mean the BufferedChannel wrapper on top of FileChannel,
> right?
> 
>>> 
>>> Not all of these could result in the high latency you see, but if each
>>> entry is being read separately, a sync on the ledger disk in between
>>> will make a mess of the disk head scheduling.
>> 
> Increasing the time interval between  flushing log files might possibly
> help in this case then?
> 
>>> 
>>> -Ivan
>> 
>> 
> Thanks for the help :)


Re: High latencies observed at the bookkeeper client while reading entries

Posted by Ivan Kelly <iv...@apache.org>.
> > >> Could you give some information on what those shortcomings are? Also, do
> > >> let me know if you need any more information from our end.
> > > Off the top of my head:
> > > - reads and writes are handled in the same thread (as you have observed)
> > > - each entry read requires a single RPC.
> > > - entries are read in parallel
> >
> By parallel, you mean the BufferedChannel wrapper on top of FileChannel,
> right?
No, i mean the RPCs from the client are all sent in parallel. This
isn't a problem in this case, and is really related to the second
point.

> 
> >  >
> > > Not all of these could result in the high latency you see, but if each
> > > entry is being read separately, a sync on the ledger disk in between
> > > will make a mess of the disk head scheduling.
> >
> Increasing the time interval between  flushing log files might possibly
> help in this case then?
Possibly, but really the biggest problem, I think, is that each entry
is being read individually. So if we want to read all of ledger L1 and
write traffic is occurring, we can get the scenario.

- read L1, entry 1 (disk seek for index, disk seek for entry)
- Sync (many disk seeks)
- read L2, entry 2 (disk seek for entry)
- Sync (many disk seeks)
- read L2, entry 3 (disk seek for entry)
- Sync (many disk seeks)
- read L2, entry 4 (disk seek for entry)
...

Also, if the sync is causing the index to be flushed out of the index
cache, there will be an extra seek for the read. 

I think the solution would be to have reads hold off syncs while all
entries in one ledger are read. This should be safe, as the journal is
ensuring the data is persisted. 

How big is the disk readahead on your disks? Also, what is the average
entry size?

-Ivan

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
On Tue, Sep 25, 2012 at 1:35 AM, Flavio Junqueira <fp...@yahoo-inc.com> wrote:

> Just to add a couple of comments to the discussion, separating reads and
> writes into different threads should only help with queuing latency. It
> wouldn't help with IO latency.
>

Yes, but with the current implementation, publishes latencies in hedwig
suffer because of lagging subscribers. By separating read and write queues,
we can at least guarantee that the write SLA is maintained (separate
journal disk + separate thread would ensure that writes are not affected by
read related seeks)

>
> Also, it sounds like a good idea to have at least one thread per ledger
> device. In the case of multiple ledger devices, if we use one single
> thread, then the performance of the bookie will be driven by the slowest
> disk, no?
>
yup, makes sense.

>
> -Flavio
>
> On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:
>
> >> Could you give some information on what those shortcomings are? Also, do
> >> let me know if you need any more information from our end.
> > Off the top of my head:
> > - reads and writes are handled in the same thread (as you have observed)
> > - each entry read requires a single RPC.
> > - entries are read in parallel
>
By parallel, you mean the BufferedChannel wrapper on top of FileChannel,
right?

>  >
> > Not all of these could result in the high latency you see, but if each
> > entry is being read separately, a sync on the ledger disk in between
> > will make a mess of the disk head scheduling.
>
Increasing the time interval between  flushing log files might possibly
help in this case then?

>  >
> > -Ivan
>
>
Thanks for the help :)

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
Just to add a couple of comments to the discussion, separating reads and writes into different threads should only help with queuing latency. It wouldn't help with IO latency. 

Also, it sounds like a good idea to have at least one thread per ledger device. In the case of multiple ledger devices, if we use one single thread, then the performance of the bookie will be driven by the slowest disk, no?

-Flavio 

On Sep 25, 2012, at 10:24 AM, Ivan Kelly wrote:

>> Could you give some information on what those shortcomings are? Also, do
>> let me know if you need any more information from our end.
> Off the top of my head:
> - reads and writes are handled in the same thread (as you have observed)
> - each entry read requires a single RPC.
> - entries are read in parallel
> 
> Not all of these could result in the high latency you see, but if each
> entry is being read separately, a sync on the ledger disk in between
> will make a mess of the disk head scheduling. 
> 
> -Ivan


Re: High latencies observed at the bookkeeper client while reading entries

Posted by Ivan Kelly <iv...@apache.org>.
> Could you give some information on what those shortcomings are? Also, do
> let me know if you need any more information from our end.
Off the top of my head:
- reads and writes are handled in the same thread (as you have observed)
- each entry read requires a single RPC.
- entries are read in parallel

Not all of these could result in the high latency you see, but if each
entry is being read separately, a sync on the ledger disk in between
will make a mess of the disk head scheduling. 

-Ivan

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
I ran sar while the bookies were showing high latencies. Pasting the output
below

disk with journal
Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
Average: dev8-16 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89
Average: dev8-17 2467.77 0.05 27118.78 10.99 0.14 0.06 0.06 13.89

Following disks store ledgers.

Average: dev8-32 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59
Average: dev8-33 319.61 10524.33 462.75 34.38 1.10 3.43 1.14 36.59

Average: dev8-48 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90
Average: dev8-49 63.25 1613.32 2022.78 57.49 0.12 1.96 1.25 7.90

Average: dev8-64 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66
Average: dev8-65 142.51 2934.78 480.65 23.97 0.54 3.80 1.31 18.66

Average: dev8-80 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19
Average: dev8-81 17.14 4.53 501.03 29.50 0.00 0.13 0.11 0.19

Regards,
Aniruddha.

On Fri, Sep 21, 2012 at 9:39 AM, Aniruddha Laud <tr...@gmail.com>wrote:

> Thanks Flavio and Ivan. Please find my replies inline.
>
> Flavio,
> Yes we are using trunk with only a few stats related modifications to
> bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
> checked using jconsole and I believe that is in ms. Our entries are small
> (Around 1KB) and we have a lot of entries in our ledgers (We see close to
> 20k publishes/second on our hedwig cluster)
>
> We have 15 bookie servers with an ensemble size of 4 and quorum of 3.
>
> On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:
>
>> What latency are you getting for the reads? Is the latency too high
>> for reading individual entries, or for reading a whole ledger?
>>
> The latency for reading individual entries is really high. In the order of
> seconds. This almost always occurs when a backed up subscriber is catching
> up and there are simultaneous publishes. There are around 15k-20k read
> entry requests per second across the 15 bookies (This is the sum of the
> PCBC requests per second) and around 10k add entry requests per second.
> From what I can tell, if there are only writes, the latencies are not high.
>
>>
>> Also, how many topics do you have in the system? The number of topics
>> will define the amount of interleaving in the ledger storage files
>> which has an affect on how long it will take to read entries from the
>> ledger.
>>
> We have 1000 topics.
>
>>
>> For the disk, check the number of I/O transactions which are
>> occurring. I don't think you can get it with dstat, but sar -b should
>> give it to you. I suspect a lot of seeks are occurring.
>>
> Thanks for the tip. I'll do this the next time we run into such a problem.
>
>
>>
>> There's a couple of shortcomings in how bookie's serve reads which
>> I've wanted to look at for a while, so this could be a good chance.
>>
> Could you give some information on what those shortcomings are? Also, do
> let me know if you need any more information from our end.
>
>>
>> -Ivan
>>
>>
>>
>> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
>> > I'm logging latencies in the per channel bookie client by overriding the
>> > read completion and add completion callbacks.
>> >
>> > When a hedwig subscriber subscribes to a topic and it hasn't consumed
>> any
>> > messages for a long time, it has to issue requests to bookkeeper to read
>> > entries. We are observing very high latencies during these operations.
>> >
>> > throttle limit for the bookkeeper client is set at 5000. We are using
>> the
>> > Hierarchical ledger manager.
>> >
>> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
>> > bookie server pageSize=32768, open file limit = 20000. I checked a few
>> > bookies and the number of open ledgers was around 5000 on each. However,
>> > the add and read latencies on the servers were less than 1 second
>> (measured
>> > using jconsole and the exposed jmx stats).
>> >
>> > Also, the bookie disks are standard spin drives and were doing about
>> 40MBps
>> > reads and 10MBps writes when measured with dstat. Any thoughts would be
>> > helpful.
>>
>
> Regards,
> Aniruddha.
>

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Ivan Kelly <iv...@apache.org>.
> Could you give some information on what those shortcomings are? Also, do
> let me know if you need any more information from our end.
Off the top of my head:
- reads and writes are handled in the same thread (as you have observed)
- each entry read requires a single RPC.
- entries are read in parallel

Not all of these could result in the high latency you see, but if each
entry is being read separately, a sync on the ledger disk in between
will make a mess of the disk head scheduling. 

-Ivan

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
Thanks Flavio and Ivan. Please find my replies inline.

Flavio,
Yes we are using trunk with only a few stats related modifications to
bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
checked using jconsole and I believe that is in ms. Our entries are small
(Around 1KB) and we have a lot of entries in our ledgers (We see close to
20k publishes/second on our hedwig cluster)

We have 15 bookie servers with an ensemble size of 4 and quorum of 3.

On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:

> What latency are you getting for the reads? Is the latency too high
> for reading individual entries, or for reading a whole ledger?
>
The latency for reading individual entries is really high. In the order of
seconds. This almost always occurs when a backed up subscriber is catching
up and there are simultaneous publishes. There are around 15k-20k read
entry requests per second across the 15 bookies (This is the sum of the
PCBC requests per second) and around 10k add entry requests per second.
>From what I can tell, if there are only writes, the latencies are not high.

>
> Also, how many topics do you have in the system? The number of topics
> will define the amount of interleaving in the ledger storage files
> which has an affect on how long it will take to read entries from the
> ledger.
>
We have 1000 topics.

>
> For the disk, check the number of I/O transactions which are
> occurring. I don't think you can get it with dstat, but sar -b should
> give it to you. I suspect a lot of seeks are occurring.
>
Thanks for the tip. I'll do this the next time we run into such a problem.

>
> There's a couple of shortcomings in how bookie's serve reads which
> I've wanted to look at for a while, so this could be a good chance.
>
Could you give some information on what those shortcomings are? Also, do
let me know if you need any more information from our end.

>
> -Ivan
>
>
>
> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
> > I'm logging latencies in the per channel bookie client by overriding the
> > read completion and add completion callbacks.
> >
> > When a hedwig subscriber subscribes to a topic and it hasn't consumed any
> > messages for a long time, it has to issue requests to bookkeeper to read
> > entries. We are observing very high latencies during these operations.
> >
> > throttle limit for the bookkeeper client is set at 5000. We are using the
> > Hierarchical ledger manager.
> >
> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
> > bookie server pageSize=32768, open file limit = 20000. I checked a few
> > bookies and the number of open ledgers was around 5000 on each. However,
> > the add and read latencies on the servers were less than 1 second
> (measured
> > using jconsole and the exposed jmx stats).
> >
> > Also, the bookie disks are standard spin drives and were doing about
> 40MBps
> > reads and 10MBps writes when measured with dstat. Any thoughts would be
> > helpful.
>

Regards,
Aniruddha.

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Aniruddha Laud <tr...@gmail.com>.
Thanks Flavio and Ivan. Please find my replies inline.

Flavio,
Yes we are using trunk with only a few stats related modifications to
bookkeeper. Also, I meant < 1ms and not 1 second. It's jmx stat value
checked using jconsole and I believe that is in ms. Our entries are small
(Around 1KB) and we have a lot of entries in our ledgers (We see close to
20k publishes/second on our hedwig cluster)

We have 15 bookie servers with an ensemble size of 4 and quorum of 3.

On Fri, Sep 21, 2012 at 2:59 AM, Ivan Kelly <iv...@apache.org> wrote:

> What latency are you getting for the reads? Is the latency too high
> for reading individual entries, or for reading a whole ledger?
>
The latency for reading individual entries is really high. In the order of
seconds. This almost always occurs when a backed up subscriber is catching
up and there are simultaneous publishes. There are around 15k-20k read
entry requests per second across the 15 bookies (This is the sum of the
PCBC requests per second) and around 10k add entry requests per second.
>From what I can tell, if there are only writes, the latencies are not high.

>
> Also, how many topics do you have in the system? The number of topics
> will define the amount of interleaving in the ledger storage files
> which has an affect on how long it will take to read entries from the
> ledger.
>
We have 1000 topics.

>
> For the disk, check the number of I/O transactions which are
> occurring. I don't think you can get it with dstat, but sar -b should
> give it to you. I suspect a lot of seeks are occurring.
>
Thanks for the tip. I'll do this the next time we run into such a problem.

>
> There's a couple of shortcomings in how bookie's serve reads which
> I've wanted to look at for a while, so this could be a good chance.
>
Could you give some information on what those shortcomings are? Also, do
let me know if you need any more information from our end.

>
> -Ivan
>
>
>
> On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
> > I'm logging latencies in the per channel bookie client by overriding the
> > read completion and add completion callbacks.
> >
> > When a hedwig subscriber subscribes to a topic and it hasn't consumed any
> > messages for a long time, it has to issue requests to bookkeeper to read
> > entries. We are observing very high latencies during these operations.
> >
> > throttle limit for the bookkeeper client is set at 5000. We are using the
> > Hierarchical ledger manager.
> >
> > The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
> > bookie server pageSize=32768, open file limit = 20000. I checked a few
> > bookies and the number of open ledgers was around 5000 on each. However,
> > the add and read latencies on the servers were less than 1 second
> (measured
> > using jconsole and the exposed jmx stats).
> >
> > Also, the bookie disks are standard spin drives and were doing about
> 40MBps
> > reads and 10MBps writes when measured with dstat. Any thoughts would be
> > helpful.
>

Regards,
Aniruddha.

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Ivan Kelly <iv...@apache.org>.
What latency are you getting for the reads? Is the latency too high
for reading individual entries, or for reading a whole ledger?

Also, how many topics do you have in the system? The number of topics
will define the amount of interleaving in the ledger storage files
which has an affect on how long it will take to read entries from the
ledger.

For the disk, check the number of I/O transactions which are
occurring. I don't think you can get it with dstat, but sar -b should
give it to you. I suspect a lot of seeks are occurring. 

There's a couple of shortcomings in how bookie's serve reads which
I've wanted to look at for a while, so this could be a good chance. 

-Ivan



On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
> I'm logging latencies in the per channel bookie client by overriding the
> read completion and add completion callbacks.
> 
> When a hedwig subscriber subscribes to a topic and it hasn't consumed any
> messages for a long time, it has to issue requests to bookkeeper to read
> entries. We are observing very high latencies during these operations.
> 
> throttle limit for the bookkeeper client is set at 5000. We are using the
> Hierarchical ledger manager.
> 
> The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
> bookie server pageSize=32768, open file limit = 20000. I checked a few
> bookies and the number of open ledgers was around 5000 on each. However,
> the add and read latencies on the servers were less than 1 second (measured
> using jconsole and the exposed jmx stats).
> 
> Also, the bookie disks are standard spin drives and were doing about 40MBps
> reads and 10MBps writes when measured with dstat. Any thoughts would be
> helpful.

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Flavio Junqueira <fp...@yahoo-inc.com>.
Hi Aniruddha, Are you using trunk for your tests?

On Sep 21, 2012, at 4:42 AM, Aniruddha Laud wrote:

> I'm logging latencies in the per channel bookie client by overriding the
> read completion and add completion callbacks.
> 
> When a hedwig subscriber subscribes to a topic and it hasn't consumed any
> messages for a long time, it has to issue requests to bookkeeper to read
> entries. We are observing very high latencies during these operations.
> 
> throttle limit for the bookkeeper client is set at 5000. We are using the
> Hierarchical ledger manager.
> 

We throttle before PerChannelBookieClient, so if the high latency you're observing is in PCBC, then it shouldn't be related to throttling.

> The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
> bookie server pageSize=32768, open file limit = 20000. I checked a few
> bookies and the number of open ledgers was around 5000 on each. However,
> the add and read latencies on the servers were less than 1 second (measured
> using jconsole and the exposed jmx stats).
> 

Did you mean to say 1ms? 1 second for a read/write is a lot.

Can you give some more detail about your traffic, like the mix of reads and adds, size of entries, etc.?

> Also, the bookie disks are standard spin drives and were doing about 40MBps
> reads and 10MBps writes when measured with dstat. Any thoughts would be
> helpful.

Seems low to me, although I would think that they are not the culprits. 

-Flavio

Re: High latencies observed at the bookkeeper client while reading entries

Posted by Ivan Kelly <iv...@apache.org>.
What latency are you getting for the reads? Is the latency too high
for reading individual entries, or for reading a whole ledger?

Also, how many topics do you have in the system? The number of topics
will define the amount of interleaving in the ledger storage files
which has an affect on how long it will take to read entries from the
ledger.

For the disk, check the number of I/O transactions which are
occurring. I don't think you can get it with dstat, but sar -b should
give it to you. I suspect a lot of seeks are occurring. 

There's a couple of shortcomings in how bookie's serve reads which
I've wanted to look at for a while, so this could be a good chance. 

-Ivan



On Thu, Sep 20, 2012 at 07:42:29PM -0700, Aniruddha Laud wrote:
> I'm logging latencies in the per channel bookie client by overriding the
> read completion and add completion callbacks.
> 
> When a hedwig subscriber subscribes to a topic and it hasn't consumed any
> messages for a long time, it has to issue requests to bookkeeper to read
> entries. We are observing very high latencies during these operations.
> 
> throttle limit for the bookkeeper client is set at 5000. We are using the
> Hierarchical ledger manager.
> 
> The bookies have 5 disks. 1 for the journal, 4 for the ledgers. On the
> bookie server pageSize=32768, open file limit = 20000. I checked a few
> bookies and the number of open ledgers was around 5000 on each. However,
> the add and read latencies on the servers were less than 1 second (measured
> using jconsole and the exposed jmx stats).
> 
> Also, the bookie disks are standard spin drives and were doing about 40MBps
> reads and 10MBps writes when measured with dstat. Any thoughts would be
> helpful.