Web应用程序中的并发 [英] Concurrency in web applications

查看:102
本文介绍了Web应用程序中的并发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,最近几乎所有平台提供商都强调为更好的并发提供新的工具/语言结构。这也是为什么很多来自函数式编程语言的想法被集成到主流语言如C#,Java等中的原因之一。



即使这些有很多今天的特别是多核CPU的引入,但我想知道如何在网络应用领域专门使用这些。在Web应用程序中,大量的并发性由Web服务器本身管理,我很少看到在网页中实现多线程。 AJAX还启用了pagelet这样的范式来帮助进一步。



Web应用程序通常包括快速获取结果,直到现在我们使用了诸如缓存,这个目标。如果有东西是计算密集型的,它必须在离线发生(并且客户端可以查询结果或回调可以实现)。



并发类已经在很多通常用于网络应用程序(例如数据库)中的库/框架中实现,在memcached的框架中多获取。



我找不到很多样例最近的并发平台和库可以在Web应用程序的上下文中使用的场景。所以我想知道他们是否在网络领域有很大的意义。

解决方案

并且一致性不够好。然后有一个倾向,有更多的东西异步,并接受最终一致性。这也反映了语言和框架的设计方式。



许多灵感来源于功能区域,因为它适合这种计算模式。功能编程有助于理解 执行而不是如何何时



这实际上是补充的传统机制来处理并发。


我找不到很多样例
的场景,其中最近的
并发平台和库
可以在web应用的上下文中使用。所以
我想知道他们是否在web域中有一个有意义的


取决于你的意思。你不需要使用低级结构,例如 java.util.concurrent 中的结构。但是异步支持沿着框架堆栈更好和更好。例如,Servlet 3.0引入了异步Web请求以缓解 AJAX 应用程序的开发。因此,EJB 3.1具有异步方法调用以与异步Web层集成。在底部,我们具有抽象计算本身的函数(或委托,闭包)的低级抽象,以及计算所需的信息(它的上下文)。我认为对于.NET也是一样。



与传统的Web应用程序无关,而是与Web相关的云,函数式编程帮助跨CPU和节点的分布式计算。一个着名的例子是map / reduce等,它们的目的是处理大量的数据。



所有这些都适合,我们看到一个web应用程序



但是,没有,你不需要所有的传统的网络应用程序!


So recently there has been a lot of emphasis by almost all platform providers to provide new tools/language constructs for better concurrency. And that is also one of the reasons why a lot of ideas from functional programming languages are being integrated into mainstream languages like C#, Java etc.

Even though these make a lot of sense today specially with the introduction of multi-core CPUs, but I wanted to know how one can use these in specially in the domain of web applications. In web apps a lot of the concurrency is managed by the web server itself and very seldom do I see multi-threading implemented inside web pages. AJAX also enabled "pagelets" like paradigm to help further.

Web applications typically consist of fetching results quickly and till now we utilized many tactics like caching, redundancy etc. to achieve this goal. If there was something that was compute intensive it had to happen offline (and the clients could query for the results later or callbacks could be implemented).

Concurrency kind of is already implemented in a lot of libraries/frameworks that are typically used in web apps like database, multi-gets in frameworks like memcached.

I couldn't find a lot of sample scenarios in which the recent concurrency platforms and libraries can be used in context of web apps. So I would like to know if they make a lot of sense in the web domain.

解决方案

The strict view of everything being synchronous and consistent is not scaling well enough. There is then a tendency to have more stuff asynchronous and to accept eventual consistency. This also reflects in the way languages and framework are designed.

Lots of inspiration is drawn from the functional area because it fits well with this mode of computation. Functional programming helps to reason about what to perform rather than how and when.

This actually complements the otherwise traditional mechanism to deal with concurrency.

I couldn’t find a lot of sample scenarios in which the recent concurrency platforms and libraries can be used in context of web apps. So I would like to know if they make a lot of sense in the web domain.

This depends on what you mean. You won’t necessary need to use low-level construction such as the one in java.util.concurrent. But asynchrony is supported better and better along the framework stacks. For instance, Servlet 3.0 introduces asynchronous web request to ease the development of AJAX applications. As a consequence, EJB 3.1 have asynchronous method invocation to integrate with the asynchronous web layer. At the bottom we have the low-level abstraction of function (or delegate, closure) which abstracts the computation itself, and the information necessary for the computation (its context). I guess the same is true for .NET.

Not related to traditional web application, but rather to the web as "the cloud," functional programming helps with distributed computation across CPU and nodes. A well-known example is map/reduce and the likes, which aim at processing large set of data.

All that fits together, and we see a web application which stays responsive, while large set of data are processed asynchronously.

But no, you won't necessary need all that for a traditional web app!

这篇关于Web应用程序中的并发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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