简体   繁体   English

Google App Engine与Google Container Engine与Google Compute

[英]Google App Engine vs Google Container Engine vs Google Compute

I have the following common scenario and I'm not sure which google cloud tool will fit best. 我有以下几种常见情况,但我不确定哪种Google云工具最适合。 I am new to google cloud. 我是Google Cloud的新手。

I have a process (the collector) which collects data from producers every N minutes and consolidates it in a database. 我有一个过程(收集器),它每N分钟从生产者那里收集一次数据,并将其合并到数据库中。 The data is published but is transient in the sense that if the collector does not collect it within a few periods it is lost. 数据已发布,但从某种意义上讲是瞬态的,即如果收集器在短时间内没有收集到数据,则它将丢失。 The collector is a background process that runs 24/7 and has a terminal logging interface for diagnostics. 收集器是一个运行24/7的后台进程,并具有用于诊断的终端日志记录界面。 At the moment the collector runs on a server/PC as a python script but I would like to move it to the cloud. 目前,收集器以python脚本的形式在服务器/ PC上运行,但我想将其移至云中。 However, I am unsure whether I need to deploy this script as a google app on Google App Engine or a docker container on the Container Engine or just run it on a Compute Engine Node. 但是,我不确定是否需要将此脚本部署为Google App Engine上的google app或Container Engine上的docker容器,还是仅在Compute Engine节点上运行它。

EDIT: 编辑:

I've done my research and I've deployed the script on Google App Engine. 我已经完成研究,并将脚本部署在Google App Engine上。 However, my understanding is that App Engine might run several instances of the app to scale per usage and it certainly has done that. 但是,我的理解是App Engine可能会运行该应用程序的多个实例以根据使用情况扩展规模,并且它确实做到了。 However, I do not end up with duplicate entries in the DB which is what I would expect if I just happen to start several instances of the script on my laptop. 但是,我不会在数据库中得到重复的条目,如果我刚巧在笔记本电脑上启动脚本的多个实例,那将是我期望的。

There are many ways to bell this cat. 有很多方法可以给这只猫敲钟。

Using kubenaties is obviously easy, however you do not necessary need to use container-engine(which may be overly pricy), just for this. 使用kubenaty显然很容易,但是,为此您不必使用container-engine(可能过于昂贵)。

If you have a compute-instance, which contains a script listening to a pub-sub, you can horizontally scale it by creating an instance template and choose to automatically scale based on processor usage. 如果您有一个compute-instance,其中包含侦听pub-sub的脚本,则可以通过创建实例模板来水平扩展它,并选择根据处理器使用情况自动扩展。

In whatever way you choose to do this, duplicity of records is more tied to the publisher, rather than the subscriber (your python script) 无论选择哪种方式,记录的重复性都与发布者而不是订阅者(您的python脚本)联系在一起

I would never use appengine for such a task, even though you easily can do it in GAE, one should try and use it only in a front-end kinda roles IMHO 即使您可以轻松地在GAE中完成应用程序引擎,我也永远不会使用它,但应该只在前端角色恕我直言中使用它

GAE-oriented answer. GAE导向的答案。

The lack of duplicate DB entries could theoretically be caused by: 理论上,缺少重复的数据库条目可能是由于:

  • a well-thought implementation, specifically designed to prevent such duplicates regardless of how many GAE instances are running :) 一个经过深思熟虑的实现,专门用于防止此类重复,无论运行多少GAE实例:)
  • accident - just because you didn't see them so far it doesn't mean they won't appear in the future. 意外-只是因为您到目前为止没有看到它们,并不表示它们将来不会出现。

You can prevent multiple GAE instances executing in parallel by using basic scaling with a max_instances config set to 1. From Scaling types and instance classes : 通过使用max_instances配置设置为1的基本扩展,可以防止多个GAE实例并行执行。从扩展类型和实例类

Basic Scaling 基本缩放

A service with basic scaling will create an instance when the application receives a request. 具有基本扩展功能的服务将在应用程序收到请求时创建一个实例。 The instance will be turned down when the app becomes idle. 当应用程序变得空闲时,实例将被关闭。 Basic scaling is ideal for work that is intermittent or driven by user activity. 基本缩放是间歇性或由用户活动驱动的工作的理想选择。

and the Scaling row in the table: 以及表格中的缩放列:

Scaling 缩放

A service with basic scaling is configured by setting the maximum number of instances in the max_instances parameter of the basic_scaling setting. 通过在basic_scaling设置的max_instances参数中设置最大实例数,可以配置具有基本扩展的服务。 The number of live instances scales with the processing volume. 活动实例的数量与处理量成比例。

See also Scaling elements . 另请参见缩放元素

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

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