Play从2.6.x开始使用Akka HTTP作为默认服务后端

在Play 2.6.x之前,Play默认使用Netty服务后端。 而到了2.6.x,默认服务后端换成了Akka HTTP, 但还是可以通过手动选择Netty服务后端。想升级到2.6.x,就需要注意到这一点了。因为Akka HTTP服务器要比Netty HTTP服务器慢。所以如果对性能特别敏感,升级完就需要手动选择Netty服务后端。

至于为什么会选择性能有所下降的Akka HTTP服务后端,Play项目的Tech Leader Greg Methvin在Google网上论坛给了一些解释。

Hi everyone,

I wanted to answer a few questions I have heard about Akka HTTP in Play 2.6. Hopefully this should clear up any concerns people have.

Why is Play switching to Akka HTTP as the default server?

Play is switching for a few reasons. Play already uses Akka and Akka streams internally, and the model Akka HTTP uses for representing requests and responses is much closer to Play's. Some of the improvements we plan to make in 3.0 will bring them closer together. We are optimistic about the Akka HTTP project and where it's headed in terms of features and performance.

While both Netty and Play are active projects, it's much easier for us to work with the Akka team. This is in part due to shared philosophy and goals but also due to the fact that both teams work for Lightbend. This improved communication will help us implement new features and fix bugs and security issues more quickly.

What's the difference in performance?

Currently we have done no optimization, so the Akka server on 2.6.0-M1 is actually slower than the Netty server. This is expected. We are working with the Akka team to bring the performance to the same level, or hopefully better. You should see the improvements on  prune as we continue this work.

Our contributor Christian Schmitt also published a  gist with nice benchmarks showing akka-http performance (without Play) actually exceeds that of play-netty-server in his test case, in terms of both latency and bytes transferred. Based on this and similar benchmarks we have done, we expect to see comparable performance to Netty once we've removed the unnecessary overhead introduced in the conversion between Play and Akka HTTP models.

Does Play still support the Netty server backend?

Yes. We will continue supporting both Netty and Akka HTTP backends for the foreseeable future, but will prioritize new features on Akka HTTP.

If you want to switch back to the Netty server, please see the  Netty server documentation.

What about HTTP/2?

HTTP/2 is coming as part of the improvements being made to the Akka HTTP server and will be included in a future milestone. We are interested in implementing it on Netty as well, but it's not a priority for the 2.6.0 release. We'd gladly accept contributions from the community, though.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值