加快 Weblogic 服务器启动速度
在我的工作中,我们使用 Weblogic Server 来托管企业门户。 这很好。
然而,我最近有机会使用 Tomcat 进行一些副业项目,我对速度上令人难以置信的差异感到震惊。 Tomcat启动需要3-5秒,部署一个中型项目需要10-15秒。 Webblogic 启动需要 3-5 分钟,部署最多需要 10 分钟。 这会扼杀任何迭代开发。
我是否必须接受它的缓慢和臃肿,或者我可以做些什么来加快它的速度? 有人有这方面的经验吗?
At my work, we use Weblogic Server to host an enterprise portal. 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 takes 3-5 seconds to start up, and 10-15 seconds to deploy a medium-sized projects. Wewblogic takes 3-5 minutes to start, and up to 10 minutes to deploy. 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
你将无法将青蛙变成公主。 我有点想知道 weblogic 的启动时间 - 它们看起来有点过分,你不会在 Linux 上运行吗?
如果您正在运行嵌套档案(耳内之战等)以及目录扫描技术(hibernate、spring 等),您可以在部署之前尝试将其全部解压到相应的分解结构; 众所周知,它会有所帮助。
Tomcat 包含 weblogic 功能的一小部分。 我们在 jetty 上开发,但在 weblogic 上部署以用于验收/生产环境,并且效果相当好。 您可以对 tomcat 执行相同的操作。
Tomcat 是一个相当严格的容器,而 weblogic 是宽松的,因此部署到 weblogic 通常只会遇到一些小问题,特别是只要您不断地同时执行这两个操作。
您还可以使用 javarebel 之类的工具来进行非常漂亮的热部署并避免所有这些重新启动。
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 ?
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; it has been known to help a bit.
Tomcat contains a very small subset of the features weblogic has. We develop on jetty but deploy on weblogic for acceptance/production environments and this works fairly well. You can do the same with 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.
You can also use a tool like javarebel to do really nifty hot-deployment and avoid all those restarts.
正如 krosenvold 所说,随机数生成可能会导致启动缓慢。
Oracle 的建议是使用下面的 -D 标志之一 - 仅在非生产系统上使用,因为它会降低安全性。
使用 -Djava.security.egd=file:///dev/urandom 开关或 file:/dev/./urandom 启动 weblogic 的命令。
上述信息取自 http://download.oracle.com/docs/cd/E12839_01/doc.1111/e14772/weblogic_server_issues.htm#CIHIIBGJ
如果 -D 标志没有不行,看下面的解决方案:
http://www.itonguard.com/20090313/weblogic -启动慢/
As krosenvold said, the random number generation can cause slow startup.
The recommendation from Oracle is to use one of the -D flags below - only on non-production systems since it lessen security.
Use -Djava.security.egd=file:///dev/urandom switch or file:/dev/./urandom to the command that starts weblogic.
The information above is taken from 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/
您没有提到什么级别和什么平台,但是 WebLogic Server 性能和调整指南包含许多可能对您有帮助的提示和技巧。
You haven’t mentioned what level and what platform but the WebLogic Server Performance and Tuning guide contains a number of hints and tips that may help you.
如果 WebLogic 连接到数据库并且您没有正确设置 DNS,则 WebLogic 在 Linux 上启动也可能很慢。
根据您的设置,您也许可以编辑 /etc/resolv.conf 并注释掉名称服务器行。 这可以将 WebLogic 的启动时间从 20 分钟减少到不到一分钟。
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.
Depending on your setup, you might be able to edit /etc/resolv.conf and comment out the nameserver line. This can reduce WebLogic's startup time from 20 minutes to less than a minute.
关于内存消耗问题,您可能需要尝试设置WebLogic服务器使用的JVM的内存参数。 登录到您的 WL Web 管理控制台并转到环境/服务器/[您的服务器]/配置/服务器启动,然后在“参数”上设置类似 -Xms256m -Xmx256m 的内容将设置 JVM 的初始 (Xms) 和最大值 ( Xmx) 堆大小为 256 MB。 您将需要研究这些数字并找到最适合您的环境的值。 但请注意,您的 Eclipse 实例也可能会消耗大量内存。
关于启动时间,虽然比我预期的要长一些,但看起来还不错。 这个问题很常见,我不认为你一定能解决它。 WebLogic 比 Tomcat 具有更多的功能,这反映在环境的其他特征上(例如启动时间)。
事实证明,Weblogic 在启动期间使用随机数生成器。 由于 java 中的错误,它从 /dev/random 读取“随机性”。 /dev/random 是非常好的随机数生成器,但速度非常慢。 有时需要 10 分钟或更长时间才能生成一个数字。 /dev/urandom 不是那么好,但它是即时的。
Java 以某种方式将 /dev/urandom 文件映射到 /dev/random。 这就是为什么 $JAVA_HOME/jre/lib/security/java.security 中的默认设置毫无用处。
可能的解决方案:
1) 在java参数中添加“-Djava.security.egd=file:/dev/./urandom”(/dev/urandom不起作用)。
更糟糕但可行的解决方案是:
2) mv /dev/random /dev/random.ORIG ; ln /dev/urandom /dev/random
3) 最好的解决方案是更改 $JAVA_HOME/jre/lib/security/java.security
将 securerandom.source 替换为
securerandom.source=file:/dev/./urandom
这个问题在 Windows 下不会发生,因为它使用了 /dev/random 的不同实现。
现在启动 weblogic 服务器需要几秒钟。
On the memory consumption issue, you might want to try setting the memory parameters of the JVM used by your WebLogic server. 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. 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.
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).
Turns out Weblogic uses random number generator during start up. Because of the bug in java it reads ‘randomness’ from /dev/random. /dev/random is very good random numbers generators but it is extremely slow. It takes sometimes 10 minutes or more to generate one number. /dev/urandom is not that good, but it is instant.
Java somehow maps /dev/urandom file to /dev/random. That’s why default settings in $JAVA_HOME/jre/lib/security/java.security are useless.
Possible solutions:
1) Add “-Djava.security.egd=file:/dev/./urandom” (/dev/urandom does not work) to java parameters.
Worse but working solution is:
2) mv /dev/random /dev/random.ORIG ; ln /dev/urandom /dev/random
3) Best solution is to change $JAVA_HOME/jre/lib/security/java.security
Replace securerandom.source with
securerandom.source=file:/dev/./urandom
This problem does not happen under windows because it uses different implementation of /dev/random.
It takes seconds to start weblogic server now.
如果使用Weblogic Workshop,那么迭代开发时只需要发布即可,不需要重启应用服务器。
If you use Weblogic workshop, then you just need to publish, not restart the application server while doing iterative development.
请检查启动时间过长实际上是由于WebLogic Server 启动而不是WebLogic Portal 启动时间造成的。
Please check that the lengthy startup time is actually due to WebLogic Server startup and not WebLogic Portal startup time.
正如 Tomas F 和 krosenvold 所建议的,它可能用于随机数生成器。
在 Weblogic 12.2.1 的标准启动中,我收到了以下消息:
所以我指定了它,它将启动时间减少了一半。 在干净的域上大约需要 13 秒。
有一个很棒的代码示例,您可以在普通的旧 Java 中亲自尝试一下。
运行
与
As Tomas F and krosenvold suggested it may be for the random number generator.
On the standard startup of Weblogic 12.2.1 I got this message :
So I specified it and it cut the startup time in half. About 13 seconds on a clean domain.
There is a great code example where you can try it out yourself in plain old Java.
Run
vs