问题
I've recently ran into a deployment issue with a call to Mac.getInstance("HmacSHA1")
.
It can take up to 10 minutes to execute that single call on this specific server, whilst on other machines its execution is instant.
CPU usage also spikes during the call.
Here's a bit of details on the server:
- OS: CentOS 5.6 Final (kernel 2.6.35.8-16, i686);
- JVM: Sun's JDK 1.6.0_25 (32bit);
- CPU: Intel Core2 Duo CPU (E8400@3.00GHz);
- Mem: 2GB of RAM;
- Dedicated physical server.
Any clues on what might be the problem here?
回答1:
I suspect you're low on system entropy for secure random numbers. See this page to check: Check available entropy in Linux. And this question has answers to consider: How to solve performance problem with Java SecureRandom? In particular this Java option should help you:
-Djava.security.egd=file:/dev/./urandom
It's much faster, but slightly less secure.
来源:https://stackoverflow.com/questions/6142382/mac-getinstance-for-hmacsha1-taking-ages-to-execute