大网数据广告活动
服务器运维问答

Java application is slow in virtual server (KVM)

· 52CE 我爱测

I have a Java web application, which runs from JAR, starts embedded Tomcat and is using Spring Boot. Problem is that it runs very slow when running in KVM virtual guest. The same application in the same JDK ( Java(TM) SE Runtime …

问题原文

原帖链接 · Xdg · CC BY-SA 3.0

I have a Java web application, which runs from JAR, starts embedded Tomcat and is using Spring Boot.

Problem is that it runs very slow when running in KVM virtual guest. The same application in the same JDK (Java(TM) SE Runtime Environment (build 1.8.0_72-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode) is starting 8 secs on bare metal, but 40 seconds when in virtualized system. Both OSes are Ubuntu 15.10 (kernel 4.2.0-27-generic). And that's not only starting issues, application responds very lazy for every HTTP request.

I've tried to change Java settings about SecureRandom, but nothing has changed.

-Djava.security.egd=file:///dev/urandom

SecureRandom and random entropy in virtual guests: https://security.stackexchange.com/questions/14386/what-do-i-need-to-configure-to-make-sure-my-software-uses-dev-urandom

https://stackoverflow.com/questions/137212/how-to-solve-performance-problem-with-java-securerandom

But it didn't help me. Do you have some other recommends, what to do? Thank you.

My virtual host is a new server with plenty of RAM, SSDs.. so I'm quite sure there is no hardware issue. I'm also running other KVM virtual guests and no problem at all. Only with slow Java application.

已采纳解答

原帖链接 · Heuriskos · CC BY-SA 3.0

If your application is using SecureRandom, you might need to install a random entropy generator, like haveged so that there is enough entropy for the initial seed.

VMs have a problem gathering entropy.

Virtual servers are running in an emulated environment, with very little access to “real” hardware. The random data that conventional computers get from their hardware doesn’t happen with emulated virtual hardware, so the prime source of entropy just isn’t present.

Source

This would at least be expected to improve performance the first time it is used.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。