google app engine - First connection to userEndpoint takes long time in Android with appEngine -


in android app, after sometime (hour or so.. not determined) connection , response google-appengine takes long, 10 seconds or more.
after first connection other enpoint requests done pretty , why believe sw issue , not internet connection issue.
should establish 'dummy' connection app loaded ?
here sample code of asynctask tried user entity appengine endpoint :

private class getuser extends asynctask<void, void, boolean> {      long mtaskuserid = constants.user_id_no_id_infdicator;     string midinplatform = constants.user_id_no_id_infdicator.tostring();     long mserverscore;     context mcontext;     string musername;      getuser(string idinplatform, string username, context c) {         midinplatform = idinplatform;         musername = username;         mcontext = c;     }      @override     protected boolean doinbackground(void... params) {          userendpoint.builder builder = new userendpoint.builder(                 androidhttp.newcompatibletransport(), new jacksonfactory(), null);         builder = cloudendpointutils.updatebuilder(builder);         userendpoint endpoint = builder.build();          try {             user user = endpoint.getuser().execute();         } catch (ioexception e) {             log.e(tag, "error getting user details server ", e);             return false;         }         this.musername = user.getusername();         this.mserverscore = user.getscore();         this.mtaskuserid = user.getid();          return true;     }      @override     protected void onpostexecute(boolean result) {         if (result) {             setuserfacebookidinpreferences(midinplatform, mcontext);             setuseridinpreferences(this.mtaskuserid, mcontext);             setscoreinpreferences(this.mserverscore, mcontext);             setusernameinpreferences(this.musername, mcontext);         } else {             toast.maketext(mcontext, r.string.string_login_failed, toast.length_short).show();         }         // restart login activity.         movetologinactivity(result);         super.onpostexecute(result);     } } 

your application in google app engine uses 2 types of server instances: dynamic instances , resident instances. difference dynamic instances created in demand serve traffic requests. resident instances on.

when traffic stops, dynamic instances shut down save resources (and save money). first time request hits server, new dynamic instance spin off serve request. process of starting new instance might take time.

this seeing in application. avoid initial latency can 2 different things:

1) optimize time takes code load up. 2) set resident instance.

you can find more information on google documentation here:

https://developers.google.com/appengine/docs/adminconsole/instances#introduction_to_instances


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -