Today, record the problems you encountered before: Project deployment in window login can be completed quickly, after deployment to Linux, the first logon process becomes very slow.
By looking at the system log, the discovery time is mainly consumed in the creation session, and is located to the SecureRandom initialization problem, continue to view, found that the session ID is created as a UUID, here, the person familiar with Linux will understand the problem.
Java's UUID relies on the Securerandom.nextbytes method, and SecureRandom relies on the random number source provided by the operating system. Under the Linux system, its default dependency is/dev/random, and the source is blocked. Most frightening of all, this nextbytes method is still a synchronized method, that is, if the multi-threaded call UUID, the generation rate does not rise and fall.
Here, you just need to modify the default random generation rules for Java. Here's how to modify it:
Go to $java_path/jre/lib/security/java.security This file and find the following:
Securerandom.source=/dev/random
Replaced by
Securerandom.source=/dev/urandom
OK, the problem has been solved!!
In fact, this is also a distributed system, do not use UUID as an important reason for the ID.
Java Web project deployment on Linux system the first logon high latency issue