Using amazon web services as google app engine bac

2019-03-27 11:08发布

I am currently using google app engine as my mobile application back end. I have a few tasks that can not be performed in the gae environment (mainly image recognition using opencv). My intention is to retain gae and use AWS to perform these specific tasks.

Is there a simple way to pass specific tasks from gae to AWS? E.g. A task queue?

5条回答
放我归山
2楼-- · 2019-03-27 11:17

Disclaimer: I'm a lead developer on the AppScale project.

One way that you could go is with AppScale - it's an open source implementation of the App Engine APIs that runs over Amazon EC2 (as well as other clouds). Since it's open source, you could alter the AppServer that we ship with it to enable OpenCV to be used. This would require you to run your App Engine app in AWS, but you could get creative and have a copy of your app running with Google, and have it send Task Queue requests to the version of your app running in AWS only when you need to use the OpenCV libraries.

查看更多
我想做一个坏孩纸
3楼-- · 2019-03-27 11:23

Have you considered using amazon simple queue service ? http://aws.amazon.com/sqs/

You should be able to add items to the queue from gae using a standard http clint.

查看更多
Explosion°爆炸
4楼-- · 2019-03-27 11:24

Sure. AppEngine has a Task Queue, where you can put in your tasks by simply implementing DeferredTask. In that task you can make requests to AWS.

查看更多
SAY GOODBYE
5楼-- · 2019-03-27 11:27

You could either push tasks from GAE towards AWS, or have your AWS instances pull tasks from GAE.

If you push tasks from GAE towards AWS, you could use URLFetch to push your data towards your AWS instances.

If you prefer to have your AWS instances pull tasks from GAE, you could have your GAE instances put their tasks in the GAE Pull Queue, and then have your AWS instances use the Task Queue REST API to lease tasks from the queue.

In either case, the AWS instance could report back the processing result through a simple POST request to your GAE servlets, or through inserting tasks via the abovementioned REST API which would later be leased by your GAE instances. The latter could be useful if you want to control the rate of which your GAE app process the results.

查看更多
Animai°情兽
6楼-- · 2019-03-27 11:41

Your intention to retain the application in GAE and use AWS to perform a few tasks, that can not be performed in the GAE, seems for me a right scenario.

I'd like to share a few ideas along with some resources to answer the main part of your question:

Is there a simple way to pass specific tasks from gae to AWS? E.g. A task queue?

If you need GAE and AWS to perform the task all the time (24/7) then your application will definitely depend on batch schedule or task queue. They are available by GAE.

However if you could arrange to pull the task in GAE and perform by AWG on interval basis (say twice a day of less than an hour each), you may no need to use them as long you can manage the GAE to put the data on Google Cloud Storage (GCS) as public.

For this scenario, you need to setup AWS EC2 Instance for On/Off Schedule and let the instance to run a boot script using cloud-init to collect the data through your domain that pointed to GCS (c.storage.googleapis.com) like so:

wget -q --read-timeout=0.0 --waitretry=5 --tries=400 \\
--background http://your.domain.com/yourfile?q=XXX... 

By having the data from GCS, then AWS can perform these specific tasks. Let it fire up GAE to clean the data and put the result back to GCS to be ready to be used as your mobile application back end.

Following are some options to consider:

  • You should note that not all of the EC2 types are suitable for On/Off Schedule. I recommend to use EC2-VPC/EBS if you want to setup AWS EC2 Instance for On/Off Schedule
  • You may no need to setup EC2 if you can set AWS Lambda to perform the task without EC2. The cost is cheaper, a task running twice a day for typically less than 3 seconds with memory consumption up to 128MB typically costs less than $0.0004 USD/month
  • As outcome of rearranging you your application in GAE and set AWG to perform some of the tasks, it might finally rise your billing rates, try to to optimize the instance class in GAE.
查看更多
登录 后发表回答