gpt4 book ai didi

playframework - playframework 真的是异步的吗?

转载 作者:行者123 更新时间:2023-12-04 07:57:37 28 4
gpt4 key购买 nike

最佳答案在评论部分(所以我不能给他们答案:()。

我想知道 playframework 是否以这种方式异步(这将是真正的异步或完全异步)。是的, Play 在前端是异步的,允许 100 个线程上的 1000 个客户端,但在后端,没有办法实现这一点,或者我错了(我希望是).....

public static void someRequest(String id) {

//This method adds listener to a nio socket listener so it returns
//IMMEDIATELY and page can't be rendered at this point
fetchRemoteDataFromOtherSystem(id, new MyListener());

// DO NOT RENDER PAGE YET but return so thread can be used for other requests
}

public class MyListener extends SomeListener {
public void fireResponse(Response response) {
renderPage(response);
}
}

请注意,这将是极端的异步行为,还请注意,如果您的后端系统需要几秒钟来响应每个请求,那么您现在需要减少大约 100 台机器来为相同数量的用户提供服务。在后端系统非常快的正常情况下,当然不会有性能差异。

谢谢,
院长

最佳答案

看看Play 2.0 .它仍然是一个测试版,但它有 some nice asynchronous stuff .

第一次玩,看this documentation page ,它涵盖了 Play 的异步特性,以及 Play Akka module (当您使用它时,还有 Akka itself :) )。

关于playframework - playframework 真的是异步的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9141767/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com