Re: [google-appengine] Question about "Using Concurrent Requests (Python 2.7)"

59 views
Skip to first unread message

PK Koug

unread,
Dec 12, 2012, 4:16:11 AM12/12/12
to google-a...@googlegroups.com
Hi Brave,

Even if you set threadsafe to false requests can still be handled in parallel by different instances. If you set it to true more than one requests can be handled in parallel by the same instance, as well. 

PK

On Dec 12, 2012, at 12:43 AM, brave yao <brav...@gmail.com> wrote:

Hi, 
The GAE doc says "By default, App Engine sends requests serially to a given web server. If you are using the Python 2.7 runtime, you can configure App Engine to send multiple, parallel requests by adding the threadsafe: true element to the header of app.yaml.". How should I understand this statement?
In fact I define 'threadsafe: false' in my app.yaml. But still I can see requests are routed to my handlers at same time. I suppose with 'threadsafe: false', no other request won't be sent into my server before current handler returns. Is this understanding correct?
Is this a bug or I miss something here?


Thanks!

/Brave

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/q0sEgcGSLqgJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

brave yao

unread,
Dec 17, 2012, 1:52:05 AM12/17/12
to google-a...@googlegroups.com
Hi PK,

What's the 'instances' you mean here? 
Take my app as example:

app = webapp2.WSGIApplication([
    ('/', MainPage),
    ('/message', MessagePage),
    ('/_ah/channel/connected/', ConnectPage),
    ('/_ah/channel/disconnected/', DisconnectPage)
  ], debug=True)
Do you mean each RequestHandler class is an instance and requests could be passed concurrently to i.e. MessagePage and ConnectPage?

Thanks!
/Brave

PK

unread,
Dec 17, 2012, 2:00:51 AM12/17/12
to google-a...@googlegroups.com
The instances I mean are the ones reported in the dashboard. With threadsafe set to false, each instance will run only one Request handler at a time BUT multiple instances can run simultaneously. Click Instances and then look at the log of each instance to see what it is doing.

To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/VL3SFMaTOukJ.

brave yao

unread,
Dec 17, 2012, 3:14:01 AM12/17/12
to google-a...@googlegroups.com
Hi PK,

OK. There are two instanses in dashboard. 
 
Total number of instancesAverage QPS*Average Latency*Average Memory
2 total0.000Unknown ms24.6 MBytes
Instances help
QPS*Latency*RequestsErrorsAgeMemoryLogsAvailabilityShutdown
0.0000.0 ms6901:06:3824.2 MBytesView LogsDynamic IconDynamic
0.0000.0 ms274204:09:1125.0 MBytesView LogsDynamic IconDynamic


I don't understand why there would be 2 instances. The one with Age 4:09:11 is the expected one, which I deployed this morning. I have no idea why there is a 1-hour-age instance. I didn't touch it since 4 hours ago(from Admin logs, there is no other operation too.).

But anyway it doesn't matter. Even with one instance, I can see two requests arriving concurrently. I suppose if the previous request didn't return, AppEngine wouldn't send the next request. Is that true? Below log is one example:

2012-12-12 00:44:26.114 /_ah/channel/disconnected/ 200 1212ms 0kb
I 2012-12-12 00:44:24.992 Deleted the saved message for 62521007/40633129
I 2012-12-12 00:44:26.078 User 40633129 removed from room 62521007
I 2012-12-12 00:44:26.078 Room 62521007 has state [75621126-True]
I 2012-12-12 00:44:26.113 Sent BYE to 75621126
W 2012-12-12 00:44:26.113 User 40633129 disconnected from room 62521007

2012-12-12 00:44:25.101 /message?r=62521007&u=40633129 200 243ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/25.0.1357.0 Safari/537.21
I 2012-12-12 00:44:24.980 Deleted the saved message for 62521007/40633129
I 2012-12-12 00:44:25.064 User 40633129 quit from room 62521007
I 2012-12-12 00:44:25.065 Room 62521007 has state [75621126-True]
I 2012-12-12 00:44:25.100 Delivered message to user 75621126

The message and /disconnect are processed within overlapped period by the same instance. So is this a problem?
I'm not sure whether the DB processing would have any impact or not, which might take dozens of milliseconds in each handler. 

Thanks!
/Brave
Reply all
Reply to author
Forward
0 new messages