使用 Haskell 或 Erlang 等函数式编程语言编写 Web 应用程序是否会比 J2EE 更具可扩展性?

发布于 2024-08-23 04:41:59 字数 251 浏览 6 评论 0原文

我正在编写一个 Facebook 应用程序,该应用程序将使用 Postgres DB 和 Facebook API,并在 Amazon EC2 上运行。 (我希望负载很重)

对于 Java,我知道 DB 将是我的主要瓶颈,而 Tomcat 的并发限制将是次要瓶颈。我可以通过缓存来缓解数据库问题,通过水平扩展来缓解并发问题。 (但这会增加我的 EC2 成本)。

Erlang 或 Haskell 在这种情况下会如何提供帮助? (假设我能够掌握学习曲线)。

I am writing a Facebook application that would use a Postgres DB along with Facebook APIs and run on Amazon EC2. (and I am hoping for heavy loads )

With Java, I know that DB would be my primary bottleneck and concurrency limitations of Tomcat would be the secondary bottleneck. I could alleviate DB issues with caching and concurrency issues with horizontal scaling . ( but this would add to my EC2 costs).

How would Erlang or Haskell help in this situation ? ( assuming I am able to master the learning curve).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

つ可否回来 2024-08-30 04:41:59

两个半答案:

你有用户吗?没有?然后使用任何可以帮助您更快地启动项目的方法。如果需要的话,你可以稍后重写。 “用户太多”是大多数人希望遇到但却不愿意遇到的问题。如果您有真正的理由期望快速获得大量用户群(例如,您运行一个受欢迎的博客并希望许多读者立即加入),那么担心这一点是有道理的,否则您就会遇到麻烦。

您确定知道瓶颈在哪里吗?这样的横向扩展所引发的担忧与小型应用程序中的性能截然不同。在开始先发制人地修复问题之前,请确保您确实知道出了什么问题。无论如何,您的应用程序的架构可能比您构建它的内容更重要。

也就是说,如果你想这样做,Erlang 或 Haskell 都可以工作,但可能不会对你的要求产生巨大的影响。不过,还有很多其他理由让我们更喜欢它们而不是 Java......

Two semi-answers:

Do you have users yet? No? Then use whatever will help you get the project off the ground quicker. You can always rewrite things later if you have to. "Too many users" is a problem that most people would like to have, but don't. If you have real reason to expect a large user base quickly (e.g., you run a popular blog and expect many of your readers to join immediately) it's justified to worry about this, otherwise you're borrowing trouble.

Are you sure you know where the bottlenecks will be? Scaling out like that raises concerns very different from performance in a smaller application. Make sure you really know what's broken before you start preemptively fixing things. The architecture of your application will probably be more important that what you build it with, anyway.

That said, either Erlang or Haskell would work if you want to do it that way, but probably won't make a huge difference for what you're asking. There's plenty of other reasons to prefer them to Java, though...

缱倦旧时光 2024-08-30 04:41:59

我会看一下 http://www.highscalability.com 并查看如何进行的案例研究关于将应用程序扩展到越来越大的负载。特别是在那里搜索 Brad Fitzpatrick 关于他如何扩展 LiveJournal 和 Danga Interactive 的描述(例如, 2005 年的演示文稿)。

您关于数据库是第一个瓶颈,然后是 Web 服务器的直觉可能是正确的,但您当然需要进行测量。

扩展站点的主要方法将涉及集群、缓存以及数据库分片等。编程语言的选择是次要的,通常会影响每个盒子的原始性能。请参阅 Henderson 的 构建可扩展的网站 和 Schlossnagle 的 可扩展的互联网架构了解该领域的其他想法和背景。

话虽如此,函数式语言可能有助于提高整体可扩展性。 Twitter 使用 Scala 来提高后端性能。 Scala 是一种结合了面向对象和函数式风格的 JVM 语言,支持 Actors 并发模型,运行速度接近 Java(Scala 的创建者 Martin Odersky 也是当前 Sun Java 编译器的编写者)。因此,如果您遇到并发瓶颈,您可能需要在 Java 中加入一些 Scala。

I'd take a look at http://www.highscalability.com and look at case studies of how to go about scaling your application to larger and larger loads. In particular search there for Brad Fitzpatrick's description of how he scaled LiveJournal and Danga Interactive (eg, this 2005 presentation).

Your intuition about the database being the first bottleneck and then the web server is probably correct, but of course you need to measure.

The major ways to scale your site will involve clustering and caching and database sharding and so on. The choice of programming language is secondary, and generally affects the raw performance on each box. See Henderson's Building Scalable Web Sites and Schlossnagle's Scalable Internet Architectures for other ideas and background in this area.

Having said that, a functional language may help to improve your overall scalability. Twitter used Scala to improve back end performance. Scala is a JVM language that combines object-oriented and functional styles, supports the Actors concurrency model, and runs at nearly the speed of Java (Martin Odersky, the creator of Scala, also wrote the current Sun Java compiler). So if you should run into a concurrency bottleneck you might want to sprinkle a bit of Scala in with your Java.

小红帽 2024-08-30 04:41:59

当瓶颈已经被定义为与代码无关时,选择不同的语言不可能比 Java 等编译语言显着加快应用程序的速度。大多数函数式语言的开销都比 Java 多,因此如果您已经熟悉 Java,那么必须有一个令人信服的理由切换到一种语言。

There is no way that choosing a different language is going to significantly speed up an application over a compiled language such as Java when the bottlenecks are already defined as not being code related. Most functional languages have more overhead than Java and so there has to be a compelling reason to switch to one if you are already familiar with Java.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文