I'm also interested to hear on this from more experienced GAE developers. My understanding so far is that you can only reliably maintain state by persisting data to the data store on every request. You can put objects into the memory cache, but since that's volatie, i.e. can be blown away at any time, it's not reliable. Even using the servlet container for a single instance won't work because you have no control or notification over the number or lifespan of instances (e.g. it could be spun up to service your request and then be removed two seconds later). Intuitively, I don't see how maintaining state via per request retrieval and persistence could ever scale in a nontrivial app, but maybe that's a preconceived notion? I'd love to see some stats if someone has achieved this?
On Nov 21, 10:35 pm, Craig <[email protected]> wrote: > Hi, > > I have some questions regarding the limits of server code in GAE. Can > I write server code that isn't tied to an http request - i.e. a thread > that would always be running on the server and which servlets could > communicate with? From what I've read it isn't possible but I just > wanted to confirm. > > The application I'm writing is analogous to a chat system where 10 > users would log in and indicate their status (busy, idle, etc). I > would prefer to be able to write a single server thread which would > maintain this information and could give it to the individual servlets > as needed. I.e. if I could write a persistent thread to manage this > data I wouldn't need to deal with the data store, memcache, etc. I > understand that this isn't possible - but please let me know if it is > and what term I need to search for. > > Next, please let me know if the following architecture for my app > makes sense. Since I cannot write a central thread to manage the > information and respond to requests, I'll accomplish that using the > memcache & data store. As users update their status the servlets will > update the data. Then when the other clients refresh themselves, the > servlets that they spawn will retrieve everyone's status from the data > store and return it to the client. Does this structure make sense or > am I missing something? > > (Eventually I'll use ServerPush to accomplish the refresh but I don't > think that is relevant to the question). > > Thanks for your response and advice, > > Craig -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=.
