简体   繁体   中英

How to migrate to concurrent requests in Java App Engine?

In light of the new billing changes on App Engine, I saw that you can enable concurrent requests in Java App Engine. What specifically do you have to be careful of when enabling concurrent requests?

The docs say:

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>.

What exactly does this entail? I've developed against App Engine assuming requests are served in parallel by any number of machines. What actually changes when you assume concurrent requests on a single machine. I run no separate threads and have no global static variables. Is there anything else I need to worry about?

Adding the element to appengine-web.xml is all that should be required. The only reason you'd have trouble is if you have mutable globals; these could be modified in parallel by multiple threads, so you need to protect them with concurrency primitives.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM