作为附加资源的支持服务

Backing Services as attached resources

我在看 12 factor app principle 的时候看到了这个说法。我相信这个声明声明应用程序必须响应任何支持服务,如数据库或消息代理,并连接到它们,无论它们是什么。它与传统的连接方式有何不同?例如:在我的微服务中,我将数据库和 kafka 代理定义为云铸造厂中用户提供的服务。它只是提供连接参数作为 vcap 服务变量。我仍然有连接到完全不同的数据库和 kafka 代理的代码。此声明表示什么意思,它与我们在非云环境中所做的有何不同?

如下文所述:

https://12factor.net/backing-services

它指出:

A backing service is any service the app consumes over the network as part of its normal operation. Examples include datastores (such as MySQL or CouchDB), messaging/queueing systems (such as RabbitMQ or Beanstalkd), SMTP services for outbound email (such as Postfix), and caching systems (such as Memcached).

无论平台如何,微服务都可以连接到任何支持服务。在 PCF 中,您将服务绑定到您的微服务以进行连接。在其他云环境中,您可以指向任何支持服务,如 AWS RDS 或平台提供的其他服务。

真正的区别在于:

Backing services like the database are traditionally managed by the same systems administrators as the app’s runtime deploy. In addition to these locally-managed services, the app may also have services provided and managed by third parties. Resources can be attached and detached to deploys at will. For example, if the app’s database is misbehaving due to a hardware issue, the app’s administrator might spin up a new database server restored from a recent backup. The current production database could be detached, and the new database attached – all without any code changes.