Mac.getInstance() for HmacSHA1 taking ages to execute

99封情书 提交于 2019-12-11 04:54:50

问题


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

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