Memcache and DataStore as shared, Variables are not.  If you built a hit
counter you would need to increment the datastore with every hit.

 

Data store only allows you to change a value once a second, so you'd have to
create new values.

 

Likely you would be doing something like

 

Hit!

Add IP to Datastore as new entity (  <increment> , IP, Time)

Display the <increment> Value as Hit counter

 

You can also do things like 

Add IP to Memache array,

Echo Memcache array,

 

Which would return IP's from all visitors on all instances, until the
memcache flush occurred.

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Randy Walsh
Sent: Monday, November 28, 2011 12:25 PM
To: [email protected]
Subject: [google-appengine] Multiple Server Instances - How do they work?

 

Multiple Server Instances - How do they work?

 

I'm new to Google AppEngine and am trying to understand more about how
applications run distributed across multiple servers.

 

What I'm wondering is this.  If I create a GO application, with a global
variable, such "Counter" in the code below.  Each time a user hit's the
page, the counter is shown and incremented.  In all cases that I've tried,
this works fine, even with multiple users.  Each user getting the next
counter. However, what if the google infrastructure starts spreading my
application to other servers.  What happens then?

 

#1) Does each new server instance get a copy of the active memory space
(starting off from the last known Counter)? do they start at zero again? 

#2) If multiple server instances are created, are they ever consolidated
again (who wins in a consolidated memory roundup?)  

#3) When a user connects during a session (eh, whatever that is), is he
guaranteed to get the same server again? The same memory space again (if
moved to another server)?

 

Is this stuff documented somewhere?  

 

 

Thanks in advance,

 

Randy

 

package main

 

import (

    "http"

    "fmt"

)

 

var Counter int

 

func init() {

       http.HandleFunc("/", httpRootHandler) 

}

 

func httpRootHandler(response http.ResponseWriter, request *http.Request) {

    response.Header().Set("Content-Type", "text/plain; charset=utf-8")

 

       fmt.Fprint(response, "Current counter is ", Counter)

       Counter++

}

 

 

 

-- 
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/-/JxW2kx72hfUJ.
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?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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?hl=en.

Reply via email to