简体   繁体   English

每次重新启动tomcat服务时是否都需要部署war文件

[英]Is it necessary to deploy the war files every time the tomcat service is restarted

I have a couple of war files which were deployed and the web applications were working fine but every time the tomcat service or the system gets restarted the war files were getting redeployed and to stop the redeployment I set the configuration options deployOnStartup and autoDeploy to false in the server.xml. 我已经部署了几个war文件,并且Web应用程序运行正常,但是每次重新启动tomcat服务或系统时,都会重新部署war文件并停止重新部署,因此我将配置选项deployOnStartup和autoDeploy设置为false server.xml。

But now after the machine restart or tomcat service restart, the web applications are not working, So I wonder if the war files need to be redeployed every time the machine or tomcat is restarted. 但是现在在机器重启或tomcat服务重启后,Web应用程序无法正常工作,所以我想知道是否在每次重启机器或tomcat时都需要重新部署war文件。

The original issue which I faced is that when tomcat deploys the war files on startup and restart it consumes up to 95% of CPU and the other processes are being held,so to solve it I tried to turn off auto deployment but if auto startup is turned off the web applications are not working. 我最初遇到的问题是,当tomcat在启动并重新启动时部署war文件时,它会消耗高达95%的CPU并保留其他进程,因此为了解决此问题,我尝试关闭自动部署,但是如果自动启动为关闭Web应用程序无法正常工作。 So I need to know if there is any way to restrict the CPU usage by tomcat. 因此,我需要知道是否有任何方法可以通过tomcat限制CPU使用率。

This is the way servlet containers work: you cannot have an undeployed application that is being invoked when clients make requests. 这就是servlet容器的工作方式:当客户端发出请求时,您不能拥有未部署的应用程序。 "Deploy" really means "start" in this case. 在这种情况下,“部署”实际上意味着“开始”。 There is no separate "deploy" step that only needs to happen a single time for the application to be available through the container. 没有单独的“部署”步骤,只需要执行一次就可以通过容器使用该应用程序。 Generally, deploy-on-startup is exactly what you want to happen. 通常,启动时部署正是您想要发生的事情。

If you are having a problem because your applications take all the system resources when they start-up, then I think you need to spend some time re-evaluating your capacity plan. 如果由于应用程序启动时占用了所有系统资源而遇到问题,那么我认为您需要花费一些时间来重新评估容量计划。 You are saying that "other applications are held"... presumably you mean that, while your web applications are being deployed, other applications on the same server are not responsive. 您说的是“其他应用程序被保留”……大概是指在部署Web应用程序时,同一服务器上的其他应用程序没有响应。 That' because of all the activity the web applications are performing. 那是由于Web应用程序正在执行的所有活动。

Well... if you need both the non-web-applications and the web-applications to be available at the same time, then it looks like you are going to need a second server (or a third, etc.). 好吧……如果您同时需要非Web应用程序和Web应用程序,那么您似乎需要第二台服务器(或第三台服务器等)。

You might also want to look at your web application and see what it's doing during startup. 您可能还需要查看Web应用程序,并查看其在启动过程中的运行情况。 Perhaps it's doing more work than necessary, or perhaps it's doing that work in an inefficient manner 1 . 也许它正在做比必要的更多的工作,或者它可能以一种低效的方式进行了工作1

Ultimately, this is going to come down to what services you need available and what hardware you have available. 最终,这将取决于您需要哪些可用的服务和可用的硬件。 If the services aren't meeting your needs (eg availability) then you need to change one of the parameters (eg more hardware) until the service again meets your needs. 如果服务不能满足您的需求(例如,可用性),那么您需要更改参数之一(例如,更多的硬件),直到服务再次满足您的需求。 Or, you need to adjust your expectations (sorry... some services will just have to wait while the web apps startup). 或者,您需要调整期望值(抱歉,某些服务仅在网络应用程序启动时需要等待)。

1 As a consultant, I once encountered a web application that could take up to 5 minutes to start and I got tired of waiting for it during our development efforts. 1作为一名顾问,我曾经遇到一个Web应用程序,可能需要5分钟才能启动,而我在开发过程中就厌倦了等待它。 So, I checked-out what was going on, and the application was building an in-memory representation of the entire relational database table and field structure. 因此,我检查了发生了什么,该应用程序正在构建整个关系数据库表和字段结构的内存表示。 The way they had been doing it was horribly inefficient and, after a few hours of refactoring, I had reduced the startup time from ~5min to ~30sec. 他们这样做的方式效率极低,经过几个小时的重构,我将启动时间从〜5min减少到〜30sec。 Sometimes, there's just a better way to do things. 有时候,有一种更好的做事方法。

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

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