Thank you Vinny.

How large are the objects you're storing in Memcache? Memcache objects can 
> be as large as 1 MB: you can fit a lot of data into a single object.  Push 
> as much data into a single object or set of objects as you can, then 
> retrieve them in one call. 
>

Just for the record, in case someone reads this thread in the future. I did 
many changes, and reduced the time from 10 seconds to few ms (although this 
is the server time, the user perceived time is still too long). There are 
no brilliant ideas, just pure logic. Basically:

1- Using "multi" functions improves quite significantly.
2- Storing big object in the cache is not such a good idea, at least in my 
case it did not work (or I did not know how to implement it). What I had to 
do is to divide the item in 2 parts: a summary and detailed view. So when I 
am getting a list of items on the screen, I just get the minimal necessary 
information. Most of the fields removed where just numbers, but the fact of 
using JSON makes the payload to be much bigger.

On a second step I did something that can be "tricky". Instead of storing 
the Datastore object and convert it to endpoints message, I store the 
message itself. In this way I save the processing of generating the 
endpoints message. 

Accessing large items in memcache is "expensive" (80ms-100ms in my case). 
So I did a list of the datastore keys ID (notice, 
datastore_object.key.id()) of the summary objects. I use this list of keys 
id to multi_get all the datastore summary elements from the memcache in 1 
batch.  

The final result (41ms):

<https://lh3.googleusercontent.com/-80sbZbwWdY4/U2taP6qY6tI/AAAAAAAAEm0/_psdz4g9HCQ/s1600/divide_and_conquer.png>
The real time is a bit more than what the chart shows, because the decoding 
and encoding  of endpoints is not taken into account. The log shows about 
120ms to 240ms (so yes, I am still "suspecting" endpoints is slow). The 
browser shows about 1.5 seconds (and that is what I really perceive). I am 
investigating now where the time is gone. I am not sure it is due to the 
network speed as I have tested in high-speed networks too. 

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to