简体   繁体   English

AppEngine Java中的线程/后端

[英]Threads/backend in appengine java

I want to run some kind of Thread continuously in app engine. 我想在应用引擎中连续运行某种线程。 What the thread does is checks a hashmap and updates entries as per some business continuously. 该线程的作用是检查哈希表并根据某些业务连续更新条目。

My hashmap is a public memeber variable of class X. And X is a singleton class. 我的哈希图是类X的公共成员变量。而X是单例类。

Now I know that appengine do not support Thread and it has somethinking called backend. 现在我知道appengine不支持Thread,它具有某种称为后端的思想。

Now my question is: If I run backend continiously for 24*7 will I be charged? 现在我的问题是:如果我连续24 * 7连续运行后端,是否需要付费? There is no heavy processing in backend. 后端没有繁重的处理。 It just updates a hashmap based on some condition. 它只是基于某种条件更新哈希图。 Can I apply some trick so that am not charged? 我可以运用一些技巧以免收费吗? My webapp is not for commercial use and is for fun. 我的webapp并非用于商业用途,而是娱乐。

Yes, backends are billed per hour. 是的,后端按小时计费。 It does not matter how much they are used: https://developers.google.com/appengine/docs/billing#Billable_Resource_Unit_Costs 无论使用多少,都无关紧要: https//developers.google.com/appengine/docs/billing#Billable_Resource_Unit_Costs

Do you need this calculation to happen immediatelly? 您需要立即进行此计算吗? You could run a cron job, say ever 5 min and perform the task. 您可以运行一项cron作业,说5分钟一次,然后执行任务。

Or you can too enqueue a 10 minutes task and re-enqueue when is near to arrive to its 10 minutes limit time. 或者,您也可以排队10分钟的任务,然后在接近其10分钟限制时间时重新排队。 For that you can use the task parameters to pass the state of the process to the next task or also you can use datastore. 为此,您可以使用任务参数将流程的状态传递给下一个任务,也可以使用数据存储。

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

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