Chronicle queue + log4j2 async logger

后端 未结 1 748
隐瞒了意图╮
隐瞒了意图╮ 2021-01-25 23:03

I use log4j2 2.10.0 and have the following code:

   SingleChronicleQueue q = SingleChronicleQueueBuilder.binary(args[0]).blockSize(536870912).build();
    Excerp         


        
相关标签:
1条回答
  • 2021-01-25 23:32

    Once you start to work with memory-mapped files, you leave the realm of Java and enter the world of operating systems (and hardware).

    So, question 1: what operating system (and what version) are you using?

    Question 2: how much physical memory do you have on your machine?

    Question 3: what hard disk are you using? SSD or spinning disk?

    In 2017, consumer grade spinning disks exceeding 200 MB/sec write speed are pretty fast. By comparison, the fastest SSD in this 2017 comparison writes 1900 MB/sec.

    You did just try to write about 2GB to a memory mapped file. That needs to be sync-ed with the physical disk at some point. That syncing could easily take 6 seconds...

    The “joy” with memory mapped files is that you have little control over when this syncing happens. People end up splitting into smaller files to ensure these pauses don't grow too large. There is some aspect of black magic in tuning the performance of this kind of applications. There is a lot to learn in this field. Fun times ahead! Enjoy!

    By the way, you cannot configure

    -DAsyncLogger.RingBufferSize=65536*65536 # not a number
    

    Log4j2 will try to parse 65536*65536 as a number, which will fail, and it will fall back to use the default buffer size instead. You need to specify the desired ring buffer size in bytes.

    0 讨论(0)
提交回复
热议问题