Java Web project deployment on Linux system the first logon high latency issue

Source: Internet
Author: User
Tags session id system log java web
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.