简体   繁体   English

Google App Engine中的并发

[英]Concurrency in Google app engine

I have a chat application in google app engine. 我在Google App Engine中有一个聊天应用程序。 I am facing the concurrency issues. 我正面临并发问题。 When the chat starts from one end, that chat will broadcast to all available agents in the account. 当聊天从一端开始时,该聊天将广播到该帐户中的所有可用座席。 When 1 guy responds that guy will take ownership and remove all the remaining guys in that session. 当1个人回应时,该个人将获得所有权并删除该会话中所有剩余的个人。

Here i am facing problem with concurrent requests from more than 1 agent response at the same time. 在这里,我面临着同时来自多个代理响应的并发请求的问题。 At this point each request takes out the remaining agents in the session and no body is there in the session. 此时,每个请求都将删除会话中剩余的代理,会话中没有任何主体。

I thought this solves with code synchronization. 我认为这可以通过代码同步解决。 But with multiple instances doesn't work this logic. 但是,对于多个实例,此逻辑不起作用。 Since the code is in different servers. 由于代码位于不同的服务器中。

Is there a way to acheive this make synchronize using datastore/memcache. 有没有一种方法可以使用数据存储区/内存缓存来实现该同步。

Please suggest on this. 请对此提出建议。

Thanks in advance. 提前致谢。

Govind. 戈文德

Look at using CAS with memcache, alternately you can use transactions in the datastore and plan control entities with known keys. 看看将CAS与内存缓存结合使用,或者,您可以在数据存储区中使用事务,并使用已知密钥计划控制实体。 I don't use java so can't whip up an example , and I can only find api docs for java on cas 我不使用Java,所以无法举一个例子,而且我只能在cas上找到Java的api文档

https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/memcache/MemcacheService.CasValues https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/memcache/MemcacheService.CasValues

but the writeup in python would still explain what is going on . 但是用python写的仍然可以解释发生了什么。

https://developers.google.com/appengine/docs/python/memcache/#Python_Using_compare_and_set_in_Python https://developers.google.com/appengine/docs/python/memcache/#Python_Using_compare_and_set_in_Python

I tried this using Transactions. 我尝试使用交易。 But some reason it wont work out to me. 但是出于某种原因,它对我不起作用。 I dont know the reason. 我不知道原因。 But with Memcache increment/decrement we can solve the problem. 但是使用Memcache增量/减量我们可以解决问题。 These methods are atomic. 这些方法是原子的。 This is simple and optimistic. 这是简单而乐观的。

Please go through this group 请通过这个小组

https://groups.google.com/forum/#!topic/google-appengine-java/wtESRwKCF5U https://groups.google.com/forum/#!topic/google-appengine-java/wtESRwKCF5U

Thanks for your updates. 感谢您的更新。

Govind. 戈文德

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM