简体   繁体   English

加快 Weblogic Server 启动时间

[英]Speed up Weblogic Server startup times

At my work, we use Weblogic Server to host an enterprise portal.在我的工作中,我们使用 Weblogic Server 来托管企业门户。 Which is fine.这很好。

However, I've recently had the opportunity to use Tomcat for some side projects, and I am struck by the incredible difference in speed.然而,我最近有机会在一些副项目中使用 Tomcat,我对速度上令人难以置信的差异感到震惊。 Tomcat takes 3-5 seconds to start up, and 10-15 seconds to deploy a medium-sized projects. Tomcat 启动需要 3-5 秒,部署一个中型项目需要 10-15 秒。 Wewblogic takes 3-5 minutes to start, and up to 10 minutes to deploy. Webblogic 启动需要 3-5分钟,部署最多需要 10分钟 This kills any iterative development.这会扼杀任何迭代开发。

Am I going to have to resign myself to its being slow and bloated, or is there anything I can do to speed it up?我是否将不得不接受它的缓慢和臃肿,或者我能做些什么来加快它的速度? Anyone have experience with this?有人有这方面的经验吗?

You will not be able to turn the frog into a princess.您将无法将青蛙变成公主。 I would wonder slightly about those startup times for weblogic - they seem a bit excessive, you're not running on linux by any chance ?我对 weblogic 的那些启动时间有点想知道——它们似乎有点过分,你不是在 linux 上运行吗?

If you're running nested archives (wars within ears etc) and also directory-scanning technologies (hibernate, spring etc), you may try unpacking it all to the corresponding exploded structure before deploying;如果您正在运行嵌套存档(耳朵内的战争等)以及目录扫描技术(hibernate、spring 等),您可以尝试在部署之前将其全部解压缩到相应的分解结构; it has been known to help a bit.众所周知,它会有所帮助。

Tomcat contains a very small subset of the features weblogic has. Tomcat 包含 weblogic 的一小部分功能。 We develop on jetty but deploy on weblogic for acceptance/production environments and this works fairly well.我们在 jetty 上开发,但在 weblogic 上部署以用于验收/生产环境,并且效果很好。 You can do the same with tomcat.你可以用tomcat做同样的事情。

Tomcat is a fairly strict container whilst weblogic is lenient, so you'll normally have only minor troubles deploying to weblogic, especially as long as you continuously do both. Tomcat 是一个相当严格的容器,而 weblogic 是宽松的,所以通常你在部署到 weblogic 时只会遇到一些小麻烦,特别是只要你不断地做这两个。

You can also use a tool like javarebel to do really nifty hot-deployment and avoid all those restarts.您还可以使用javarebel 之类的工具来进行非常漂亮的热部署并避免所有这些重新启动。

As krosenvold said, the random number generation can cause slow startup.正如 krosenvold 所说,随机数生成会导致启动缓慢。

The recommendation from Oracle is to use one of the -D flags below - only on non-production systems since it lessen security. Oracle 的建议是使用以下 -D 标志之一 - 仅在非生产系统上使用,因为它会降低安全性。

Use -Djava.security.egd=file:///dev/urandom switch or file:/dev/./urandom to the command that starts weblogic.使用-Djava.security.egd=file:///dev/urandom开关或file:/dev/./urandom来启动 weblogic 的命令。

The information above is taken from http://download.oracle.com/docs/cd/E12839_01/doc.1111/e14772/weblogic_server_issues.htm#CIHIIBGJ以上信息取自http://download.oracle.com/docs/cd/E12839_01/doc.1111/e14772/weblogic_server_issues.htm#CIHIIBGJ

If the -D flag doesn't work, look at the following solution: http://www.itonguard.com/20090313/weblogic-starts-slow/如果 -D 标志不起作用,请查看以下解决方案: http ://www.itonguard.com/20090313/weblogic-starts-slow/

您没有提到什么级别和什么平台,但WebLogic Server 性能和调优指南包含许多可能对您有所帮助的提示和技巧。

WebLogic can also be slow to start up on Linux if it's connecting to a database and you haven't set up DNS properly.如果 WebLogic 连接到数据库并且您没有正确设置 DNS,它在 Linux 上的启动也会很慢。

Depending on your setup, you might be able to edit /etc/resolv.conf and comment out the nameserver line.根据您的设置,您可能能够编辑 /etc/resolv.conf 并注释掉 nameserver 行。 This can reduce WebLogic's startup time from 20 minutes to less than a minute.这可以将 WebLogic 的启动时间从 20 分钟减少到不到一分钟。

On the memory consumption issue, you might want to try setting the memory parameters of the JVM used by your WebLogic server.关于内存消耗问题,您可能想尝试设置 WebLogic 服务器使用的 JVM 的内存参数。 Log in to your WL Web Admin Console and go to Environment/Servers/[your server]/Configuration/Server Start and, on the "Arguments", setting something like -Xms256m -Xmx256m will set your JVM's initial (Xms) and maximum (Xmx) heap size to 256 megabytes.登录到您的 WL Web 管理控制台并转到 Environment/Servers/[your server]/Configuration/Server Start 并在“参数”上设置 -Xms256m -Xmx256m 之类的设置将设置 JVM 的初始 (Xms) 和最大值 ( Xmx) 堆大小为 256 兆字节。 You will want to play around with these numbers and find the best values for your environment.您将希望使用这些数字并为您的环境找到最佳值。 But please be aware that your Eclipse instance might be consuming a lot of memory as well.但请注意,您的 Eclipse 实例也可能会消耗大量内存。

Regarding the startup time, although a bit larger than I would expect, they seem OK.关于启动时间,虽然比我预期的要大一些,但它们看起来还不错。 This problem is very frequent, and I don't think you will be able to definitely solve it.这个问题非常频繁,我不认为你一定能解决它。 WebLogic has much more features than Tomcat, and this reflects in other characteristics of the environment (like startup time). WebLogic 比 Tomcat 有更多的功能,这反映在环境的其他特征(如启动时间)上。

Turns out Weblogic uses random number generator during start up.原来 Weblogic 在启动期间使用随机数生成器。 Because of the bug in java it reads 'randomness' from /dev/random.由于 java 中的错误,它从 /dev/random 读取“随机性”。 /dev/random is very good random numbers generators but it is extremely slow. /dev/random 是非常好的随机数生成器,但速度极慢。 It takes sometimes 10 minutes or more to generate one number.有时需要 10 分钟或更长时间才能生成一个数字。 /dev/urandom is not that good, but it is instant. /dev/urandom 不是很好,但它是即时的。 Java somehow maps /dev/urandom file to /dev/random. Java 以某种方式将 /dev/urandom 文件映射到 /dev/random。 That's why default settings in $JAVA_HOME/jre/lib/security/java.security are useless.这就是 $JAVA_HOME/jre/lib/security/java.security 中的默认设置没有用的原因。

Possible solutions: 1) Add “-Djava.security.egd=file:/dev/./urandom” (/dev/urandom does not work) to java parameters.可能的解决方案: 1)在java参数中添加“-Djava.security.egd=file:/dev/./urandom”(/dev/urandom不起作用)。

Worse but working solution is: 2) mv /dev/random /dev/random.ORIG ;更糟糕但可行的解决方案是:2) mv /dev/random /dev/random.ORIG ; ln /dev/urandom /dev/random ln /dev/urandom /dev/random

3) Best solution is to change $JAVA_HOME/jre/lib/security/java.security Replace securerandom.source with 3)最好的解决方案是改变 $JAVA_HOME/jre/lib/security/java.security 替换securerandom.source

securerandom.source=file:/dev/./urandom securerandom.source=file:/dev/./urandom

This problem does not happen under windows because it uses different implementation of /dev/random.这个问题在 windows 下不会发生,因为它使用 /dev/random 的不同实现。

It takes seconds to start weblogic server now.现在启动 weblogic 服务器需要几秒钟。

如果您使用Weblogic Workshop,那么您只需要发布,而不是在进行迭代开发时重新启动应用程序服务器。

As Tomas F and krosenvold suggested it may be for the random number generator.正如 Tomas F 和 krosenvold 建议的那样,它可能用于随机数生成器。

On the standard startup of Weblogic 12.2.1 I got this message :在 Weblogic 12.2.1 的标准启动中,我收到了这条消息:

Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. 
To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true

So I specified it and it cut the startup time in half.所以我指定了它,它把启动时间缩短了一半。 About 13 seconds on a clean domain.在干净的域上大约需要 13 秒。

There is a great code example where you can try it out yourself in plain old Java.有一个很棒的代码示例,您可以在其中用普通的旧 Java 自己尝试一下。

public class JavaSecurityEgdTester {
    public static final double NANOSECS = 1000000000.0;

    public static void main(String[] args) {
        SecureRandom secureRandom = new SecureRandom();
        long start = System.nanoTime();
        byte[] randomBytes = new byte[256];
        secureRandom.nextBytes(randomBytes);
        double duration = (System.nanoTime() - start) / NANOSECS;

        System.out.println("java.security.egd = " + System.getProperty("java.security.egd") + " took " + duration + " seconds and used the " + secureRandom.getAlgorithm() + " algorithm");
    }
}

Run

java -Djava.security.egd=file:/dev/random -cp JavaSecurityEgdTester

vs对比

java -Djava.security.egd=file:/dev/urandom -cp . JavaSecurityEgdTester

请检查冗长的启动时间实际上是由于 WebLogic Server 启动而不是 WebLogic Portal 启动时间造成的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM