Sync Memcache and Datastore on Google App Engine

I am writing a chat application using the Google App Engine. I would like chats to register. Unfortunately, the Google App Engine datastore only allows you to write once per second. To get around this limitation, I thought about using memcache to write a buffer. In order not to lose data, I need to periodically push data from memcache to the data warehouse.

Is there a way to schedule such tasks in the Google App. Engine? Or am I not quite right about this?

I am using a version of the API for Python, so it would be preferable to use a Python solution, but I know Java well enough so that I can convert the Java solution to Python.

+3
source share
5 answers

To get around the restriction on writing / updating entity groups (note that entities without a parent are their own entity group), you can create a new object for each chat message and save a property in it that will refer to the chat to which they belong. .

Then you will find all the chat messages belonging to the chat through the request. But that would be very inefficient, since then you would need to make a request for each user for each new message.

So, go to the tip above, but optionally do:

  • backends. - , ( / ). -, ( Datastore). , 100% , - .

  • API . . , .

+2

, memcache.

.

. , . , , . 1MB.

, , , .

, . - , , , .

, , . sharding, : https://developers.google.com/appengine/articles/sharding_counters

Sharding , . . , 3 , 5x/sec ( , , ).

3 . . .

, 3 1 .

+2

pull? Google, . 15 , . , , re: database op, , - . : https://www.youtube.com/watch?v=AM0ZPO7-lcE&feature=player_embedded

, on-line-, . id + , TextProperty. , , cron , , . : .

+1

, , . , , memcached, .

, . . 1 ( ) , , ( ), , .

0

I think it’s good for you to use the chat session as a group of entities and save the chat messages.
this time per second the limit is not a reality, you can update / save at a higher speed and they do it all the time, and I have no problems with it. memcache is unstable and is the wrong choice for what you want to do. If you start to encounter problems with write speed, you can start setting up tasks to save data.

0
source

All Articles