gpt4 book ai didi

java - 如何迁移到 Java App Engine 中的并发请求?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:36:31 26 4
gpt4 key购买 nike

鉴于 App Engine 上的新计费更改,我看到您可以在 Java App Engine 中启用并发请求。开启并发请求有哪些具体需要注意的地方?

文档说:

By default, App Engine sends requests serially to a given web server. You can configure App Engine to send multiple requests in parallel by adding the <threadsafe> element to appengine-web.xml: <threadsafe>true</threadsafe>
Note: If you wish to use concurrent requests, your application code needs to use proper thread synchronization before you enable <threadsafe>.

这到底意味着什么?我已经针对 App Engine 进行了开发,假设请求由任意数量的机器并行处理。当您假设在一台机器上并发请求时,实际发生了什么变化。我没有运行单独的线程,也没有全局静态变量。还有什么我需要担心的吗?

最佳答案

只需将元素添加到 appengine-web.xml 即可。你遇到麻烦的唯一原因是你有可变的全局变量;这些可以由多个线程并行修改,因此您需要使用并发原语来保护它们。

关于java - 如何迁移到 Java App Engine 中的并发请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7303596/

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