How can I reduce my JAVA CPU usage?

There are two Java processes (A, B) on Linux machine (CentOS 6.5 64 bit). A sends a lot of binary data to B using sockets. B writes data to disk. Per second, data of 50-100 MB is written to disk. On a quad-core processor, the processor is almost 100% utilized. We used to run a similar application, but wrote C, only 25% of the CPU was used.

We set up a lot. We found out there were some epoll bugs and then we updated the JDK version to 1.8. We've also done some JVM tweaks. Now the overall CPU usage is lower than before, but we are not satisfied. We think we can reduce it.

There is a lot of data on the disc. We believe that the disk is not a bottleneck. Because we are using large RAID. We used to run a similar application written in C with more disk bandwidth and everything was fine.

But we also find a problem. When the kernel cleans up dirty data on disks, the CPU usage will be very high. Therefore, we increase / proc / sys / vm / dirty _background_ratio to do asynchronous flush as much as possible. After we change the value, it works, but after a while, the high CPU problem comes up again.

Can we perform additional performance tuning for Java applications with high I / O bandwidth?

+3


source to share


1 answer


Before you can perform performance tuning, you need to figure out what CPU time dominates.

This is a multifaceted topic, you need to look at what the kernel is doing, what system calls are being issued at what rate, what are your access patterns, how filesystems and other storage layers affect the characteristics of various filesystem operations, etc.



Netflix recently introduced a way to get full kernel / user space / java packages , which might be a helpful starting point, but there are many other things to watch out for.

0


source







All Articles