使用嵌入式容器部署war文件与可执行jar的建议 [英] Advice deploying war files vs executable jar with embedded container

查看:109
本文介绍了使用嵌入式容器部署war文件与可执行jar的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java空间中似乎有一种趋势,即不再以war文件(或ear文件)的形式将java Web应用程序部署到java servlet容器(或应用程序服务器),而是将应用程序打包为带有嵌入式servlet / HTTP服务器的可执行jar,如jetty。我的意思是更新的框架影响新应用程序的开发和部署方式,而不是如何将应用程序交付给最终用户(因为,例如,我知道Jenkins使用嵌入式容器的原因,非常容易抓住和去)。采用可执行jar选项的框架示例:
Dropwizard Spring Boot ,并播放(它不能在servlet容器上运行,但是嵌入了HTTP服务器)。

There seems to be a current trend in java space to move away from deploying java web applications to a java servlet container (or application server) in the form of a war file (or ear file) and instead package the application as an executable jar with an embedded servlet/HTTP server like jetty. And I mean this more so in the way newer frameworks are influencing how new applications are developed and deployed rather than how applications are delivered to end users (because, for example, I get why Jenkins uses an embedded container, very easy to grab and go). Examples of frameworks adopting the executable jar option: Dropwizard, Spring Boot, and Play (well it doesn't run on a servlet container but the HTTP server is embedded).

我的问题是,来自我们部署的环境我们(到目前为止主要是Struts2)应用程序到单个tomcat应用程序服务器,如果我们计划使用嵌入式容器方法,需要做出哪些更改,最佳实践或注意事项?目前,我们在单个tomcat服务器上运行了大约10个自行开发的应用程序,对于这些小型应用程序,b b b能够共享资源并在一台服务器上进行管理。我们的应用程序无意分发给最终用户以在其环境中运行。但是,如果我们决定利用更新的Java框架,那么这种方法会改变吗?越来越多地使用云部署(例如,Heroku)刺激了可执行jar的转变?

My question is, coming from an environment where we have deployed our (up to this point mostly Struts2) applications to a single tomcat application server, what changes, best practices, or considerations need to be made if we plan on using an embedded container approach? Currently, we have about 10 homegrown applications running on a single tomcat server and for these smallish applications the ability to share resources and be managed on one server is nice. Our applications are not intended to be distributed to end users to run within their environment. However, moving forward if we decide to leverage a newer java framework, should this approach change? Is the shift to executable jars spurred on by the increasing use of cloud deployments (e.g., Heroku)?

如果您有使用Play风格管理多个应用程序的经验部署与单个应用程序服务器上的传统war文件部署,请分享您的见解。

If you've had experience managing multiple applications in the Play style of deployment versus traditional war file deployment on a single application server, please share your insight.

推荐答案

一个有趣的问题。这只是我对这个主题的看法,所以要把所有东西都拿出来。我偶尔使用servlet容器和嵌入式服务器部署和管理应用程序。我确信使用servlet容器还有很多很好的理由,但我会尽量关注它们今天不太受欢迎的原因。

An interesting question. This is just my view on the topic, so take everything with a grain of salt. I have occasionally deployed and managed applications using both servlet containers and embedded servers. I'm sure there are still many good reasons for using servlet containers but I will try to just focus on why they are less popular today.

短版本:Servlet容器是非常适合在单个主机上管理多个应用程序,但对管理一个应用程序似乎没什么用处。对于云环境,每个虚拟机的单个应用程序似乎更受欢迎且更常见。现代框架希望与云兼容,因此转向嵌入式服务器。

Short version: Servlet containers are great to manage multiple applications on a single host but don't seem very useful to manage just one single application. With cloud environments, a single application per virtual machine seems preferable and more common. Modern frameworks want to be cloud compatible, therefore the shift to embedded servers.

所以我认为云服务是放弃servlet容器的主要原因。就像servlet容器一样,您可以管理应用程序,云服务可以让您管理虚拟机,实例,数据存储等等。这听起来更复杂,但在云环境中,已经转向单个应用程序机器。这意味着您可以经常将整个机器视为 应用程序。每个应用程序都在适当大小的计算机上运行。云实例可以随时弹出并消失,这对扩展非常有用。如果应用程序需要更多资源,则可以创建更多实例。

So I think cloud services are the main reason for abandoning servlet containers. Just like servlet containers let you manage applications, cloud services let you manage virtual machines, instances, data storage and much more. This sounds more complicated, but with cloud environments, there has been a shift to single app machines. This means you can often treat the whole machine like it is the application. Each application runs on a machine with appropriate size. Cloud instances can pop up and vanish at any time which is great for scaling. If an application needs more resources, you create more instances.

另一方面,专用服务器通常功能强大但具有固定大小,因此您可以在单个服务器上运行多个应用程序机器最大限度地利用资源。管理数十个应用程序 - 每个应用程序都有自己的配置,Web服务器,路由和连接等 - 并不好玩,因此使用servlet容器可以帮助您保持一切可管理性和自己的理智。虽然规模更难。云中的Servlet容器似乎不太有用。必须为每个小实例设置它们,而不提供太多价值,因为它们只管理单个应用程序。

Dedicated servers on the other hand usually are powerful but with a fixed size, so you run multiple applications on a single machine to maximize the use of resources. Managing dozens of application - each with their own configurations, web servers, routes and connections etc. - is not fun, so using a servlet container helps you to keep everything manageable and yourself sane. It is harder to scale though. Servlet containers in the cloud don't seem very useful. They would have to be set up for each tiny instance, without providing much value since they only manage a single application.

此外,云很酷,非云的东西很无聊(如果我们仍然相信炒作)。许多框架默认都是可扩展的,因此可以轻松地将它们部署到云端。嵌入式服务器可以快速部署和运行,因此它们似乎是一种合理的解决方案Servlet容器通常仍然受支持,但需要更复杂的设置。

Also, clouds are cool and non-cloud stuff is boring (if we still believe the hype). Many frameworks try to be scalable by default, so that they can easily be deployed to the clouds. Embedded servers are fast to deploy and run so they seem like a reasonable solution. Servlet containers are usually still supported but require a more complicated set up.

其他一些要点:


  • 嵌入式服务器可以针对框架进行优化,或者更好地与框架工具集成(例如播放控制台)。

  • Not所有云环境都带有可自定义的机器映像。使用专用软件进行云应用程序部署,而不是编写初始化脚本来下载和设置servlet容器,而不是简单。

  • 我还没有找到一个不会问候你的Tomcat设置 perm gen space error 您的应用的每次重新部署。花几点时间(重新)启动嵌入式服务器是没有问题的,你可以在没有任何停机的情况下几乎立即在登台和生产实例之间切换。

  • 正如问题中已经提到的,它非常方便最终用户运行应用程序。

  • 嵌入式服务器便携,便于开发。今天一切都是快速,原型和MVP需要尽快创建和交付。没有人愿意花太多时间为每个开发人员设置一个环境。

  • The embedded server could be optimized for the framework or is better integrated with the frameworks tooling (like the play console for example).
  • Not all cloud environments come with customizable machine images. Instead of writing initialization scripts to download and set up servlet containers, using dedicated software for cloud application deployments is much simpler.
  • I have yet to find a Tomcat setup that doesn't greet you with a perm gen space error every few redeployments of your app. Taking a bit longer to (re-)start embedded servers is no problem when you can almost instantly switch between staging and production instances without any downtime.
  • As already mentioned in the question, it's very convenient for the end user to just run the application.
  • Embedded servers are portable and convenient for development. Today everything is rapid, prototypes and MVPs need to be created and delivered as fast as possible. No one wants to spend too much time setting up an environment for every developer.

这篇关于使用嵌入式容器部署war文件与可执行jar的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆