How is Akka used in Play
所属分类 akka
浏览量 707
https://stackoverflow.com/questions/22718905/how-is-akka-used-in-play
Built on Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications.
scala akka playframework
netty spray akka-http(之前叫 spray )
In Play 2.0, Play delegated all requests to go through an actor.
It heavily depended on Akka's future API and other parts.
In Play 2.1, with the move of Akka's future API into Scala 2.10, Play started depending less directly on Akka.
It gets all it's execution contexts from Akka, and provides integration with Akka, but that's about the extent of it.
In Play 2.3, we're adding new features to aid Akka integration, particularly around WebSockets.
Play 2.3中,添加了一些新功能来帮助Akka的整合,特别是WebSockets
In Play 2.4, Play will be ported to the new akka-http (formerly known as spray),
at which point, Play will be as built on Akka as you can get.
Play 2.4中,Play将被移植到新的akka-http(以前称为spray),届时,Play将尽可能建立在Akka上。
What are the consequences?
Akka provides a paradigm for programming that makes concurrency simple to deal with.
It also provides great abstractions for distributed programming
the hardest thing about distributed programming is dealing with failures (which happen all the time) appropriately.
Most tools try to address this by trying to hide failures from you,
but unfortunately hiding something doesn't make it go away,
and actually really makes things harder because when you try to address specific types of failures,
the fact that they are hidden away from you gets in your way.
Akka pushes failures in your face, so that when you're coding,
you are forced to think about how your application will respond to failures.
Consequently you're forced to design/code your application in such a way that it is tolerant to failures.
It also gives you the tools to deal with them in a hierarchical fashion,
allowing you to specify at what level you want to handle what type of failure,
and how the failure should be responded to (die, retry up to n times, etc).
Akka提供了一个编程范例,使得并发处理变得简单
它还为分布式编程提供了很好的抽象
关于分布式编程,最困难的事情是正确地处理失败(总是发生)
大多数工具试图通过隐藏失败来解决这个问题,但不幸的是,隐瞒真相并不能让它消失,
这实际上会让事情变得更困难,因为当你试图解决特定类型的失败时,事实上,他们对你来说是一种阻碍。
Akka把失败推到你面前,所以当你写代码的时候,必须考虑应用程序将如何响应故障。
因此,你需要以一种能够容忍失败的方式来设计/编写应用程序。
它还提供了以等级方式处理它们的工具,指定在什么级别处理什么类型的失败,
应该如何响应失败(死亡,重试n次,等等)
So how does this help Play? The better question is how does it help a Play user?
Akka helps me to implement Play itself, but it's possible to implement it without Akka
(in fact Netty does most of the heavy lifting now, that will change in Play 2.4).
The important thing is that Play seamlessly integrates with Akka,
making it easy to handle HTTP requests with actors, handle failures etc,
and this helps Play users because it allows them to design their application in such a way that it is scalable and resilient.
Akka帮助执行Play本身,但也可以在没有Akka的情况下执行
事实上Netty现在做了大部分繁重的工作
Play与Akka无缝整合,让它更容易用actor处理HTTP请求,处理失败等,
以一种可伸缩和有弹性的方式设计应用程序
UPDATE: The above was written 3 years ago, a lot has changed since then.
Play 2.4 did provide experimental support for akka-http, but Play still by default uses Netty.
Play 2.4确实提供了对akka-http的实验性支持,但Play仍然默认使用Netty
In Play 2.5, we deprecated the iteratees API and switched to Akka streams.
This meant that now all asynchronous IO was going through Akka streams.
Soon (not sure if that will be Play 2.6 or later),
Play will flick the switch to make akka-http the default backing implementation of the server (though not yet the WS client).
Play 2.5中,弃用了 iteratees API,转而使用 Akka streams
这意味着现在所有的异步IO都要通过Akka streams
很快(不确定是2.6版还是以后),akka-http 成为服务器的默认支持实现(尽管还不是WS客户端)
UPDATE 2: Play 2.6 now makes akka-http the default backend implementation of it's HTTP server (Netty is still available as an option).
Play 2.6现在 默认使用 akka-http 实现HTTP服务器(Netty仍然是一个选项)
上一篇
下一篇
Scala 异常
scala 函数
scala case class
akka actor demo
akka http rest api demo
c语言 hello world 高逼格版本