任务队列和数据存储区读写

时间:2023-02-11 23:12:40

I am using Objectify in my google cloud endpoints module , My endpoint project handles most of my datastore read and write ops , but i wanted to know if it is an efficient design practice to use Task queues to wrap a read or write operation on the datastore in google app engine .

我在我的谷歌云端点模块中使用Objectify,我的端点项目处理我的大多数数据存储区读写操作,但我想知道使用任务队列在数据存储区上包装读取或写入操作是否是一种有效的设计实践在谷歌应用引擎中。

2 个解决方案

#1


3  

All the data necessary for a task execution has to be written somewhere, and the App Engine persists this data in a task queue backed by the same Datastore. Unless your write operation involves number crunching, URL fetching, external API calls, updates of hundreds on entities, or some other expensive logic, there is no advantage to wrapping a write call in a task.

必须在某处编写执行任务所需的所有数据,并且App Engine会将此数据保留在由同一数据存储区支持的任务队列中。除非您的写入操作涉及数字运算,URL提取,外部API调用,数百个实体的更新或其他一些昂贵的逻辑,否则在任务中包装写入调用没有任何好处。

Wrapping read calls in tasks is impossible in most cases as you lose an ability to return this data in the same call.

在大多数情况下,无法在任务中包装读取调用,因为您无法在同一调用中返回此数据。

#2


0  

Consider to use write-behind-cache if you want to speed up your writes. There's a little chance that you will lose your data, but you will dramatically speed up the write speed (as seen by user).

如果要加快写入速度,请考虑使用write-behind-cache。您将丢失数据的可能性很小,但您将大大加快写入速度(用户可以看到)。

The idea is to write entity only into memcache first, so user will not wait for actual datastore write, and then pick up that memcached entity by task queue/cron and write it into datastore.

我们的想法是首先将实体写入memcache,这样用户就不会等待实际的数据存储区写入,然后通过任务队列/ cron获取该memcached实体并将其写入数据存储区。

#1


3  

All the data necessary for a task execution has to be written somewhere, and the App Engine persists this data in a task queue backed by the same Datastore. Unless your write operation involves number crunching, URL fetching, external API calls, updates of hundreds on entities, or some other expensive logic, there is no advantage to wrapping a write call in a task.

必须在某处编写执行任务所需的所有数据,并且App Engine会将此数据保留在由同一数据存储区支持的任务队列中。除非您的写入操作涉及数字运算,URL提取,外部API调用,数百个实体的更新或其他一些昂贵的逻辑,否则在任务中包装写入调用没有任何好处。

Wrapping read calls in tasks is impossible in most cases as you lose an ability to return this data in the same call.

在大多数情况下,无法在任务中包装读取调用,因为您无法在同一调用中返回此数据。

#2


0  

Consider to use write-behind-cache if you want to speed up your writes. There's a little chance that you will lose your data, but you will dramatically speed up the write speed (as seen by user).

如果要加快写入速度,请考虑使用write-behind-cache。您将丢失数据的可能性很小,但您将大大加快写入速度(用户可以看到)。

The idea is to write entity only into memcache first, so user will not wait for actual datastore write, and then pick up that memcached entity by task queue/cron and write it into datastore.

我们的想法是首先将实体写入memcache,这样用户就不会等待实际的数据存储区写入,然后通过任务队列/ cron获取该memcached实体并将其写入数据存储区。