简体   繁体   English

Google App Engine:任务还是线程?

[英]Google App Engine: tasks vs threads?

I have a local scientific application that uses threads to process independent pieces of a large calculation. 我有一个本地科学应用程序,该应用程序使用线程来处理大型计算的独立部分。 My group would like this to become a web application, so now I'm figuring out how to port it (so please forgive any complete bonehead statements). 我的小组希望这成为一个Web应用程序,因此现在我想出了如何移植它(因此请原谅所有完整的骨头声明)。 I'm using Google App Engine to take care of the "web" part of it, but I'm still working out what other translations are appropriate. 我正在使用Google App Engine来处理其中的“网络”部分,但是我仍在研究其他合适的翻译版本。

My first inclination was to leave the calculation completely as is (eg, digest some web form data into the appropriate format, pass that into calculator which spawns threads, etc). 我的第一个倾向是完全不进行计算(例如,将某些Web表单数据摘要为适当的格式,将其传递到产生线程的计算器中,等等)。

However, I'm also reading about Queue s + TaskOptions - that sort of looks like what I should be using instead of ExecutorService + Callable . 但是,我还在阅读有关Queue + TaskOptions -类似于我应该使用的东西,而不是ExecutorService + Callable The individual sub-calculations can take a bit to process (though they can also differ widely in amount of time required), so I guess ideally I'd like a user to be request the whole calculation and then be taken to a page which loads the results as they become available. 各个子计算可能需要一点时间来处理(尽管它们在所需时间上也可能相差很大),因此我想理想情况下,我希望用户请求整个计算,然后转到加载该页面的页面结果可用。

Are Queue s + TaskOptions the right thing to be using? Queue s + TaskOptions是否正确使用? If not, what is? 如果没有,那是什么? If so, are there convenient parallel examples to what I'm looking to do? 如果是这样,是否有方便的并行示例供我参考?

Lastly, my group has some short-term qualms about wide-release of the internals of the calculation so its details are all server-side - should that allay those concerns? 最后,我的小组对广泛发布计算的内部结构有一些短期的疑虑,因此其详细信息都在服务器端-是否应该减轻这些担忧?

Eventually (after some publications etc) we plan to make those internals openly available and presumably then the web version could move the calculation client-side. 最终(在一些出版物发表之后),我们计划使这些内部组件公开可用,并且大概可以使Web版本可以移动计算客户端。 Is there a preferable way to do implementation now that will make that future translation simpler? 现在有没有更好的方法可以使将来的翻译变得更简单? Or is that not even worth worrying about (since I already effectively have a "client-side" version in my local application)? 还是不值得担心(因为我已经在本地应用程序中有效地拥有了“客户端”版本)?

  1. All requests (including tasks) in app engine have a time limit of 30 seconds. 应用引擎中的所有请求(包括任务)的时限为30秒。 If your calculations will take longer than that, you will need to figure out a way to break them down into smaller chunks. 如果您的计算需要更长的时间,则需要找出一种将其分解为较小块的方法。 App engine's sweet spot is web apps, not number crunching. App Engine最吸引人的地方是Web应用程序,而不是数字处理。

  2. If you want to be able to share code between the client and server side, one option is to look into GWT. 如果您希望能够在客户端和服务器端之间共享代码,一种选择是查看GWT。 (google web toolkit) It will allow you to write a client using java source code that it then converts to javascript. (Google Web工具包)它将允许您使用Java源代码编写客户端,然后将其转换为javascript。 This would be one method of reusing the number crunching code you already have. 这将是重用您已有的数字处理代码的一种方法。

You cannot create threads on App Engine. 您无法在App Engine上创建线程。 Task queues+ Task options would be the way to go. 任务队列+任务选项将是解决之道。

If you want to keep things internal - then keeping it on the server side would be the safest thing to do now. 如果您想将事情保留在内部-那么现在将其保留在服务器端将是最安全的事情。 However you can think of exposing your work flow as a service, so that in the future clients can talk to the same service. 但是,您可以考虑将工作流程作为服务公开,以便将来客户可以与同一服务进行对话。

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

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