PlayFramework 应用程序的最佳部署策略? [英] Best deployment strategy for PlayFramework applications?

查看:18
本文介绍了PlayFramework 应用程序的最佳部署策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是面向服务器的.我有一个托管服务器(一个相当小的服务器,1,6Ghz atom,2Go,200 GO),有几个(4 或 5 个)播放应用程序,还有更多.大多数这些应用程序的使用量很小,假设每个应用程序每天有一百个请求.

This question is server oriented. I have a hosted server (a rather small one, 1,6Ghz atom, 2Go, 200 GO) with a couple (4 or 5) play apps and more coming. Most of these apps have a real small usage, let's say a hundred requests a day each.

  1. 使用 Play 的嵌入式服务器部署每个应用程序会更好吗?从而为每个应用程序使用 64mb 的内存?

  1. Is it better to deploy each of those applications using the embedded server of Play! and thus use 64mb of memory for each application?

或者部署一个Tomcat,里面的所有应用都在tomcat里面?所有应用程序共享更大的内存?

Or deploy a Tomcat with all the applications inside the tomcat? With a bigger memory shared by all the apps?

我会添加一些关于我的情况的进一步信息.服务器还托管:

I'll add a little further information about my situation. The server also hosts :

  • Apache2
  • 上约有 10,15 个 PHP 网站
  • 通过 Apache mod_dav_svn 的 SVN 服务器
  • 用于 Sonar
  • 的 tomcat
  • Jenkins 的独立安装(通过 Jetty)
  • About 10,15 PHP websites on Apache2
  • A SVN server going through Apache mod_dav_svn
  • A tomcat used for Sonar
  • A standalone installation of Jenkins (via Jetty)

我最初的计划是在 Tomcat 中部署所有这些东西.拥有应用程序,声纳 &Jenkins 在 Tomcat 和 Apache2 上运行以获取静态资源.(图片、脚本)

My original plan was to deploy all these stuff in Tomcat. Having the apps, Sonar & Jenkins running on Tomcat and Apache2 for static ressources. (Images, scripts)

评论

最后一点,我知道拥有 Sonar &Jenkins,生产环境中的持续集成系统并不是真正的最佳选择.但由于这些仅在夜间运行(自动构建),因此它们不会使系统过载.另外,我是一名学生,在经济上额外的CI/build"服务器超出了我的经济能力.

Last point, I'm aware that having Sonar & Jenkins, Continuous integration systems on a production environment isn't really optimal. But since these are only running at night (automated builds) they are not overloading the system. Plus I'm a student, financially an additional "CI/build" server is out of my financial capacities.

推荐答案

最好的方法是使用自带的 Play 服务器,将 NGinx 作为反向代理放在它的前面来处理所有的重定向/请求管理.

The best approach is to use the included Play server, putting NGinx as reverse proxy in front of it to tackle all the redirection/request managing.

为什么是这个而不是 Tomcat?您可以从比较性能的这篇文章开始.一个额外的论点是 Tomcat 加载了 Play 不需要或使用的所有 Java EE 环境,消耗了您想要为应用程序免费提供的内存和资源(特别是如果您使用内存缓存).

Why this and not Tomcat? You can start with this article that compares performance. An extra argument would be that Tomcat loads all the Java EE environment which Play doesn't require nor use, consuming memory and resources you want free for your apps (specially if you use in-memory caching).

在作为反向代理的 Nginx 上,this 应该会提示为什么要使用它而不是 Apache.

On Nginx as reverse proxy, this should give a hint on why to use it instead of Apache.

编辑(关于问题的编辑):

在您的情况下,您可以优化您的资源.

In your situation, you can optimize your resources.

首先用 Nginx 替换 Apache 2.Nginx 可以很好地为 PHP 服务(如果您使用 Ubuntu,请参阅 这个).它将非常有效地为 Play 服务,并且可以用作 Java 服务器的代理.

First replace Apache 2 by Nginx. Nginx can serve PHP, quite well (if you use Ubuntu see this). It will serve Play very efficiently, and can be used as proxy to Java servers.

然后您可以将所有 Java 应用程序移至 Jetty,并摆脱 Tomcat.Jetty 平均消耗更少的资源,即使你的应用程序只会在晚上运行,服务器仍然在线并囤积 ram.花费越少越好.

Then you can move all your Java apps to Jetty, and get rid of Tomcat. Jetty consumes less resources in average, and even if your apps will only run at night, the server is still online and hoarding ram. The less it takes the better.

SVN 呢?遗憾的是,您将需要 Apache 2 和 Nginx 作为 Apache 2 的反向代理.那为什么不保留 Apache?论点是用法.理论上,PHP 应用程序将比 SVN 服务器拥有更多的流量,这使得它们所拥有的资源消耗更加相关.使用 nginx,分配给 PHP 的 ram 和 cpu 将减少,从而使您的机器响应更快.Apache 只会在你使用 SVN 时才会行动,这种情况不会那么频繁.

What about SVN? Sadly you will need Apache 2 and Nginx as reverse proxy to Apache 2. Why not to keep Apache then? The argument would be usage. In theory the PHP apps will have more traffic than the SVN server, which makes more relevant the resource consumption they have. With nginx, ram and cpu allocated to serve PHP will be less making your machine more responsive. Apache will only act when you use SVN, which will not be so often.

如果您不想将精力转移到 Nginx(我可以理解),那么只需将 Java 应用程序移动到 Jetty 并使用 Apache 2 作为 Play 的反向代理.但是使用 Play 嵌入式服务器,不要在 Tomcat 中加载应用程序.这样会更有效率.

If you don't want to put the effort on moving stuff to Nginx (which I can understand), then just move Java apps to Jetty and use Apache 2 as reverse proxy for Play. But use Play embedded server, don't load the app in Tomcat. It will be more efficient this way.

这篇关于PlayFramework 应用程序的最佳部署策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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