19 June 2019

Contention RollingFileManager.checkRollover()

Contention at: org.apache.logging.log4j.core.appender.rolling.RollingFileManager.checkRollover()

This is a problem with high concurrency, and it works as designed. The file system (I/O) doesn't have  enough performance as required.

The synchronized makes BLOCKED some Java monitor when trying to acquire the resource.
 
/**
 * Determines if a rollover should occur.
 * @param event The LogEvent.
 */
public synchronized void checkRollover(final LogEvent event) {
    if (triggeringPolicy.isTriggeringEvent(event)) {
        rollover();
    }
}

The solution as mentioned above is to move to Async logging.
https://logging.apache.org/log4j/2.x/manual/async.html

JMC Events

From the Event Types tab, look at the color of each event.

Yellow represents Java Monitor Wait events.
The yellow part is when threads are waiting for an object. This often means that the thread is idle, perhaps waiting for a task.

Red represents the Java Monitor Blocked events or synchronization events. If your Java application's important threads spend a lot of time being blocked, then that means that a critical section of the application is single threaded, which is a bottleneck.

Blue represents the Socket Reads and Socket Writes events. Again, if the Java application spends a lot of time waiting for sockets, then the main bottleneck may be in the network or with the other machines that the application communicates.


https://docs.oracle.com/javase/10/troubleshoot/troubleshoot-performance-issues-using-jfr.htm

http://java-performance.info/oracle-java-mission-control-overview/#more-921

My Blog List

Blog Archive

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.