从应用引擎访问计算引擎 [英] Access compute engine from app engine

查看:29
本文介绍了从应用引擎访问计算引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Compute Engine 上运行的实例,它使用 Torch 来预测图像中的对象.我想制作一个简单的 Web 界面,用户可以使用它上传图像,将图像发送到服务器(计算引擎),预测对象并将列表返回给用户.在我的计算引擎 (Ubuntu 14.04) 中,这行代码用于预测图像中的对象.(所有其他设置都已在计算引擎中完成.)

I have an instance running on the Compute Engine which uses Torch to predict objects in images. I wanted to make a simple web interface using which a user can upload an image, the image is sent to the server(compute engine), the objects are predicted and the list is returned back to the user. In my compute engine (Ubuntu 14.04) this line of code is used to predict objects in images. (All the other setup has been already done in the compute engine.)

th eval.lua -model /path/to/model -image_folder /path/to/image/directory -num_images 10 

我想从 Web 应用程序调用此行并将图像传递到图像文件夹并取回对象列表.我该怎么做?

I want to call this line from the web app and pass the image to the image folder and get back the list of objects. How do I go about it?

推荐答案

在过去的项目中,我讨论并使用了不同的方法在 Google App Engine 和 Google Compute Engine 之间进行通信.一般来说,两个常见的嫌疑人是:

In past projects I have discussed and used different approaches to communicate between Google App Engine and Google Compute Engine. Generally speaking the two usual suspects are:

  • 来自 App Engine 的编排:在这种方法中,App Engine 应用程序是活动部分,并向计算实例上的服务发送请求.这就是 Igor Artamonov 在他的评论中已经描述的内容.我们在计算实例上使用了一个 tomcat 实例,它运行了一个完整的 rest api 来调用实例上的命令.可能的帮手:
    • 使用 App Engine 的 Google Compute API 时,您可以获得计算实例的外部 IP 地址.因此,您知道您的请求必须发送到哪里.
    • Orchestration from App Engine: In this approach the App Engine application is the active part and sends requests to a service on the compute instance. This is what Igor Artamonov already described in his comment. We used a tomcat instance on the compute instances which ran a full rest api to invoke commands on the instance. Possible helpers:
      • When using the Google Compute API from App Engine you can get the external IP address of compute instances. So you know where your requests will have to go.

      这两种方法都很有效.如果您使用 Compute API 并知道您的计算实例的 IP,您可以将您的轮询端点和命令调用请求限制到这些 IP 以获得基本安全性.

      Both approaches work well. If you use the Compute API and know the IPs of your compute instances you can restrict your polling endpoints and command invoke requests to these IPs for basic security.

      尽管如此,我会尽量避免过多的投票,让我给你一个报价:

      I would try to avoid too much polling though since, well let me give you a quote:

      主动轮询是启动工作流程的穷人的解决方案.(javaworld.com)

      Actively polling is the poor man's solution to kicking off a workflow process. (javaworld.com)

      但是,如果您在计算实例完成其工作负载后关闭它们,我看不出您不应该使用轮询的充分理由.如果您不这样做并且将计算实例的数量增加到几个实例,则您的 App Engine 应用程序将有负载,除了成本之外没有任何实现.

      But if you shut down your compute instances when they are finished with their workload i don't see a good reason why you shouldn't use polling. If you don't and you increase the number of compute instances to a couple instances you will have load on your App Engine application without achieving anything but cost.

      这篇关于从应用引擎访问计算引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆