简体   繁体   English

是否可以在Google App Engine Flexible中运行Postgres?

[英]Is it possible to run Postgres in Google App Engine Flexible?

Is it possible to run postgres (essentially, a non-HTTP service) in a custom Google App Engine Flexible container? 是否可以在自定义Google App Engine Flexible容器中运行postgres(本质上是非HTTP服务)? Or will I be forced to use Google's Cloud SQL solution? 还是会被迫使用Google的Cloud SQL解决方案?

TL;DR : You could do that, but don't. TL; DR :您可以这样做,但不能这样做。 It's better to externalize the persistent data storage. 最好将持久化数据存储外部化。

Yes, it is possible to run a PostgreSQL database as a microservice (named simply a 'service' in Google Cloud Platform) in a custom Google App Engine Flexible container. 是的,可以在自定义Google App Engine Flexible容器中将PostgreSQL数据库作为微服务(在Google Cloud Platform中简称为“服务”)运行。 However, that raises another important question, namely why would you like to run an SQL database inside a container. 但是,这提出了另一个重要的问题,即为什么要在容器内运行SQL数据库。 This is a risky solution, unless you are perfectly sure about what you are doing and how to manage that. 这是一个冒险的解决方案,除非您完全确定自己在做什么以及如何进行管理。

Typical container orchestration is based on stateless services which means that they are not intended to store persistent data. 典型的容器编排基于无状态服务,这意味着它们不打算存储持久性数据。 This kind of containers do have some form of storage sometimes, like NoSQL databases for cache or user session information. 这种容器有时确实具有某种形式的存储,例如用于缓存或用户会话信息的NoSQL数据库。 This data is not persistent, it can be lost during restarts or destruction of instances in an agile containerized application environment. 此数据不是永久性的,在敏捷的容器化应用程序环境中重新启动或销毁实例时可能会丢失数据。 PostgreSQL databases are rather used as stateful services and do not suit the aforementioned model. PostgreSQL数据库被用作有状态服务,不适合上述模型。 Putting such database into a container, one can run into problems like data corruption or direct concurrency when accessing some shared data directory. 将这样的数据库放入容器中时,访问某些共享数据目录时可能会遇到诸如数据损坏或直接并发之类的问题。 Also, in Google App Engine Flexible it's not possible to add a shared persistent disk, the volumes are attached to instances and destroyed together with them. 另外,在Google App Engine Flexible中,无法添加共享的永久磁盘,这些卷将附加到实例并与它们一起销毁。 Much safer solution is keeping the SQL database in an external, durable storage, as Cloud SQL that you have mentioned. 像您提到的Cloud SQL一样,更安全的解决方案是将SQL数据库保留在外部持久存储中。 There are numerous blog posts and articles that elaborate this issue with the stateless/stateful services, like this one . 有许多博客帖子和文章,阐述这一问题的无状态/有状态的服务,如这一个

It should be mentioned that if you are to use the container in a local environment or for test/development (and you are not looking for a durable state of the database), putting a PostgreSQL inside a container should be perfectly ok. 应该提到的是,如果要在本地环境中使用容器或进行测试/开发(并且您不是在寻找数据库的持久状态),那么将PostgreSQL放入容器中应该是可以的。 Also, if you design a special way of splitting your data across instances this could work fine, as the guys did with their MySQL servers in this article . 此外,如果您设计了一种在实例之间拆分数据的特殊方法,则可以很好地工作,就像本文中的MySQL服务器一样。 So once again, the idea of putting a PostgreSQL database in a container should be carefully thought-out, especially that there are so many options of a safe externalization of such a service. 因此,再次考虑将PostgreSQL数据库放入容器的想法,特别是要考虑到安全地将此类服务外部化的选项太多。

And just as a side note, you are not forced to use Cloud SQL. 只是作为旁注,您没有被迫使用Cloud SQL。 The database can be hosted on Compute Engine, another cloud provider, on premises, or can be managed by a third-party vendor. 该数据库可以托管在本地的另一个云提供商Compute Engine上,也可以由第三方供应商进行管理。 In case of hosting it in Compute Engine the application is able to communicate with the database inside the same project using the internal IP of the Compute Engine instance. 如果将其托管在Compute Engine中,则应用程序可以使用Compute Engine实例的内部IP与同一项目中的数据库进行通信。 Using Cloud Launcher you can quickly deploy PostgreSQL and other popular databases to Compute Engine. 使用Cloud Launcher,您可以将PostgreSQL和其他流行的数据库快速部署到Compute Engine。 Check these Google docs for more information about using third-party databases. 查看这些Google文档 ,以获取有关使用第三方数据库的更多信息。

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

相关问题 是否可以在Google App Engine ** Flexible **环境中运行Windows可执行文件? - Is it possible to run a Windows executable in Google App Engine **Flexible** environment? 是否可以使用golang灵活地从app引擎连接到google cloud sql postgres实例? - Is it possible to connect to a google cloud sql postgres instance from app engine flexible using golang? 如何在Google App Engine灵活环境中运行TensorFlow? - How to run TensorFlow in Google App Engine Flexible Enviroment? 如何在Google App Engine灵活部署步骤中运行Django迁移? - How to run Django migrations in Google App Engine Flexible deployment step? Python Google应用引擎灵活 - Python google app engine flexible Google App Engine 弹性价格 - Google App Engine flexible price 是否可以在Google App Engine上运行Google Omaha? - Is it possible to run Google Omaha on Google App Engine? 是否可以在Google App Engine上运行比特币? / 备择方案? - Is it possible to run Bitcoin on Google App Engine? / alternatives? 是否可以在Google App Engine PHP上运行整洁 - Is it possible to run tidy at google app engine PHP 将Google App Engine应用程序升级到灵活环境时,如何运行Google的aefix工具? - How do I run Google's aefix tool when upgrading a Google App Engine app to the flexible environment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM