Chronicle queue + log4j2 async logger

别等时光非礼了梦想. 提交于 2019-12-02 11:30:39

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!