为 Web 应用程序在 Django-Apache 和 Java-Tomcat 之间进行选择

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5320457/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 10:37:47  来源:igfitidea点击:

Choosing between Django-Apache and Java-Tomcat for a web application

javapythondjangotomcat

提问by viksit

In order to develop a web application that can easily scale, provide production stability, is easily deploy-able, and allows for fast development cycles, what points would you recommend I look at before choosing one or the other framework - using Java and Tomcat, or Django and Apache/Mod_WSGI?

为了开发一个可以轻松扩展、提供生产稳定性、易于部署并允许快速开发周期的 Web 应用程序,在选择一个或另一个框架之前,您会推荐哪些要点 - 使用 Java 和 Tomcat,或 Django 和 Apache/Mod_WSGI?

Some pros and cons I could see immediately,

我可以立即看到一些优点和缺点,

  • Tomcat apps are simple to deploy - drop a WAR file and you're done. Django apps seem to need more wrangling (Not sure if creating .egg files and dropping them in would work as well?)
  • Django's ORM seems much nicer than Hibernate - generates models directly compared to Hibernate's manual configuration files
  • Python as a language is faster to develop in, and much more concise than Java can be. (Of course, this is a relatively higher level discussion).
  • Tomcat 应用程序易于部署 - 删除 WAR 文件即可完成。Django 应用程序似乎需要更多的争论(不确定创建 .egg 文件并将它们放入是否也能工作?)
  • Django 的 ORM 似乎比 Hibernate 好得多 - 与 Hibernate 的手动配置文件相比,直接生成模型
  • Python 作为一种语言开发速度更快,而且比 Java 简洁得多。(当然,这是一个比较高层次的讨论)。

I've looked at Disqus's slides about scaling Django and am under no doubts it can be done. But would scaling a Django app be any harder than scaling a Java/Tomcat one?

我看过 Disqus 关于扩展 Django 的幻灯片,毫无疑问它可以做到。但是,扩展 Django 应用程序是否比扩展 Java/Tomcat 应用程序更难?

I'm familiar with both Java and Python and the frameworks mentioned above, and it boils down to getting feedback those who've worked with either (or both) on scale.

我熟悉 Java 和 Python 以及上面提到的框架,归根结底是获得那些大规模使用其中一个(或两者)的人的反馈。

Thanks!

谢谢!

回答by Eser Aygün

Here are my experiences:

以下是我的经验:

  • Django-Apache fits in 16MBs of memory, whereas Java-Tomcat requires much more than that.
  • Coding in Python is much faster, that is true. In Java, on the other hand, you have compile-time checks, profilers and debuggers that help you increase the stability of your application.
  • If you are planning to do heavy computations or need complex data structures, Java's compilation technologies will provide the speed you need.
  • It is easier to maintain a large project in a strictly object-oriented environment with advanced refactoring tools, such as Java.
  • Then again, coding in Python is much faster.
  • Django-Apache 适合 16MB 的内存,而 Java-Tomcat 需要的内存远不止这些。
  • 用 Python 编码要快得多,这是真的。另一方面,在 Java 中,您可以使用编译时检查、分析器和调试器来帮助您提高应用程序的稳定性。
  • 如果您计划进行大量计算或需要复杂的数据结构,Java 的编译技术将提供您需要的速度。
  • 使用高级重构工具(例如 Java)在严格面向对象的环境中维护大型项目更容易。
  • 再说一次,用 Python 编码要快得多。

回答by Razvan Cojocaru

It's worth noting that Python code can be extended with C/C++ code. So Django applications can, in fact, be faster than their Java equivalents if one is careful to use native code where speed or complex data structures are required.

值得注意的是,Python 代码可以用 C/C++ 代码进行扩展。因此,事实上,如果在需要速度或复杂数据结构的情况下谨慎使用本机代码,Django 应用程序可以比它们的 Java 应用程序更快。

Obviously, my vote's for Django.

显然,我的票是给 Django 的。

回答by Stan

I choose Python with Django, because it is better in deployment. You don't need build war. You only copy files on server and that's all.
Django is easily scalable and production stable. see this.

我选择Python with Django,因为它在部署上更好。你不需要建造War。您只在服务器上复制文件,仅此而已。
Django 易于扩展且生产稳定。看到这个

If you prefer Java look at Grails. But it has 2 minuses: building war and a lot of memory usage(200 mb without users).

如果您更喜欢 Java,请查看 Grails。但它有两个缺点:构建War和大量内存使用(没有用户时为 200 mb)。