云本机应用程序呢?What about Cloud-Native applications?

尽管云本机应用程序并不是本指南的主要重点,但可以帮助你了解此现代化成熟度级别,并将其与云优化应用程序进行区分。Although Cloud-Native applications are not the main focus of this guide, it's helpful to have an understanding of this modernization maturity level, and to distinguish it from Cloud-Optimized applications.

图 4-3 在应用程序现代化成熟度级别中定位云本机应用:Figure 4-3 positions Cloud-Native apps in the application modernization maturity levels:

演示如何定位云本机应用程序的关系图。

图 4-3.Figure 4-3. 定位云本机应用程序Positioning Cloud-Native applications

云本机现代化成熟度级别通常需要新的开发投资。The Cloud-Native modernization maturity level usually requires new development investments. 迁移到云本机级别通常由尽可能多地现代化应用程序以大幅改进大型应用程序规模的业务需求驱动,方法是:在长期降低成本的同时创建可从应用程序的其他区域单独部署和缩放的自治子系统(微服务),并提高这些自治应用部件(提供巨大的竞争优势)的演变灵活性。Moving to the Cloud-Native level typically is driven by business need to modernize applications as much as possible to drastically improve scale in large applications by creating autonomous subsystems (microservices) that can be deployed and scale independently from other areas of the application while lowering costs in the long term and increase evolution agility of those autonomous app’s parts that provide significant compete advantages.

云本机应用程序的主要要素基于微服务体系结构方法,这些方法可以灵活地进行发展,并调整为在部署到本地或云环境的整体式体系结构中难以实现的限制。The main pillars of Cloud-Native applications are based on microservices architecture approaches, which can evolve with agility and scale to limits that would be difficult to achieve in a monolithic architecture, deployed to either on-premises or cloud environment.

图 4-4 显示了云本机模型的主要特征。Figure 4-4 shows the main characteristics of the Cloud-Native model.

列出云本机主要特征的关系图。

图 4-4.Figure 4-4. 云本机特征Cloud-Native characteristics

此外,还可以通过添加其他服务(如人工智能 (AI)、机器学习 (ML) 和 IoT)来扩展基本的新式 Web 应用和云本机应用。In addition, you can extend basic modern web apps and cloud-native apps by adding other services, like artificial intelligence (AI), machine learning (ML), and IoT. 可以使用其中任何服务来扩展任何可能的云优化方法。You might use any of these services to extend any of the possible Cloud-Optimized approaches.

云本机级别的应用程序的根本区别在于应用程序体系结构。The fundamental difference in applications at the Cloud-Native level is in the application architecture. 根据定义,云本机应用程序是基于微服务的应用。Cloud-native applications are, by definition, apps that are based on microservices. 与整体式 Web 应用程序或传统 N 层应用程序相比,云本机应用需要特殊的体系结构、技术和平台。Cloud-native apps require special architectures, technologies, and platforms, compared to a monolithic web application or traditional N-Tier application.

云本机应用程序详细信息Cloud-native applications details

对于大型和任务关键型应用程序而言,云本地是一种更高级或更成熟的状态。Cloud-Native is a more advanced or mature state for large and mission-critical applications. 云本机应用程序通常需要从头开始创建的体系结构和设计,而不是现代化现有应用程序。Cloud-Native applications usually require architecture and design that are created from scratch instead of by modernizing existing applications. 云本机应用程序和更简单的云优化 Web 应用之间的主要区别是,建议使用云本机方法中的微服务体系结构。The key difference between a Cloud-Native application and a simpler Cloud-Optimized web app is the recommendation to use microservices architectures in a cloud-native approach. 云优化应用也可以是整体式 Web 应用或 N 层应用。Cloud-Optimized apps can also be monolithic web apps or N-Tier apps.

十二因素应用(与微服务方法密切相关的模式集合)也被视为云本机应用程序体系结构的要求。The Twelve-Factor App (a collection of patterns that are closely related to microservices approaches) is also considered a requirement for cloud-native application architectures.

云本机计算基础 (CNCF) 是云本机原则的主要推动者。The Cloud Native Computing Foundation (CNCF) is a primary promoter of cloud-native principles. Microsoft 是 CNCF 的 成员Microsoft is a member of the CNCF.

有关如何设计和开发云本机应用程序的详细指导,请阅读以下免费电子书:For detailed guidance on how to design and develop cloud-native applications, read the following free e-books:

如果将整个应用程序迁移到云本机模型,则要考虑的最重要因素是,必须重新架构到基于微服务的体系结构。The most important factor to consider if you migrate a full application to the cloud-native model is that you must rearchitect to a microservices-based architecture. 由于涉及大型重构过程,因此这显然需要大量开发工作。This clearly requires a significant investment in development because of the large refactoring process involved. 对于需要新级别的可伸缩性和长期的灵活性的任务关键型应用程序,通常选择此选项。This option usually is chosen for mission-critical applications that need new levels of scalability and long-term agility. 但是,可以通过只为几个新方案添加微服务来开始迁移到云本机,最终将应用程序完全重构为微服务。But, you could start moving toward cloud-native by adding microservices for just a few new scenarios, and eventually refactor the application fully as microservices. 这是最适合某些方案的增量方法。This is an incremental approach that is the best option for some scenarios.

微服务呢?What about microservices?

在考虑组织的云本机应用程序时,了解微服务及其工作原理非常重要。Understanding microservices and how they work is important when you are considering cloud-native applications for your organization.

微服务体系结构是一种高级方法,可以将该方法用于从头开始创建的应用程序,也可以在将现有应用程序发展为云本机应用程序时将该方法用于应用程序。The microservices architecture is an advanced approach that you can use for applications that are created from scratch or when you evolve existing applications toward cloud-native applications. 首先,可以将一些微服务添加到现有应用程序,以了解新的微服务范例。You can start by adding a few microservices to existing applications to learn about the new microservices paradigms. 但很显然,你需要进行构建并编写代码,特别是对于这种类型的体系结构方法。But clearly, you need to architect and code, especially for this type of architectural approach.

但是,对于任何新的或新式应用程序,微服务不是必需的。However, microservices are not mandatory for any new or modern application. 微服务并不是“万能的”,也不是创建每个应用程序的唯一最佳方法。Microservices are not a "magic bullet," and they aren't the single, best way to create every application. 使用微服务的方式和时间取决于需要构建的应用程序的类型。How and when you use microservices depends on the type of application that you need to build.

微服务体系结构正成为基于多个独立子系统的分布式和大型或复杂的任务关键型应用程序的首选方法,其形式是自治服务。The microservices architecture is becoming the preferred approach for distributed and large or complex mission-critical applications that are based on multiple, independent subsystems in the form of autonomous services. 在基于微服务的体系结构中,将应用程序生成为可独立开发、测试、版本控制、部署和缩放的一系列服务。In a microservices-based architecture, an application is built as a collection of services that can be independently developed, tested, versioned, deployed, and scaled. 每个服务可以包含任何相关的自治数据库。This can include any related, autonomous database per microservice.

有关可使用 .NET Core 实现的微服务体系结构的详细信息,请参阅可下载的 PDF 电子书 .NET 微服务:适用于容器化 .NET 应用程序的体系结构For a detailed look at a microservices architecture that you can implement by using .NET Core, see the downloadable PDF e-book .NET microservices: Architecture for containerized .NET applications. 可以在线获得本指南。The guide also is available online.

但即使是在微服务提供功能强大的独立部署、强子系统边界和技术多样性的情况下,它们也会带来许多新挑战。But even in scenarios in which microservices offer powerful capabilities-independent deployment, strong subsystem boundaries, and technology diversity-they also raise many new challenges. 这些挑战与分布式应用程序开发相关,如零碎和独立的数据模型;实现微服务之间的可复原通信;需要最终一致性;以及操作复杂性。The challenges are related to distributed application development, such as fragmented and independent data models; achieving resilient communication between microservices; the need for eventual consistency; and operational complexity. 与传统整体式应用程序相比,微服务加深了复杂性。Microservices introduce a higher level of complexity compared to traditional monolithic applications.

由于微服务体系结构的复杂性,因此只有特定方案和特定应用程序类型适用于基于微服务的应用程序。Because of the complexity of a microservices architecture, only specific scenarios and certain application types are suitable for microservice-based applications. 其中包括具有多个不断发展的子系统的大型复杂应用程序。These include large and complex applications that have multiple, evolving subsystems. 在这些情况下,值得投资更复杂的软件体系结构,因为它将增强长期灵活性并提高应用程序维护效率。In these cases, it's worth investing in a more complex software architecture, for increased long-term agility and more efficient application maintenance. 但对于不太复杂的方案,最好使用整体式应用程序方法或更简单的 N 层方法。But for less complex scenarios, it might be better to continue with a monolithic application approach or simpler N-Tier approaches.

最后要注意的是,即使冒着重复此概念的风险,也不应在应用程序中将微服务用作“全有或全无”。As a final note, even at the risk of being repetitive about this concept, you shouldn't look at using microservices in your applications as "all-in or nothing at all." 可以通过基于微服务添加全新小型方案来扩展和改进现有整体式应用程序。You can extend and evolve existing monolithic applications by adding new, small scenarios based on microservices. 无需从头开始即可使用微服务体系结构方法。You don't need to start from scratch to start working with a microservices architecture approach. 事实上,我们建议通过添加新方案来改进现有整体式或 N 层应用程序。In fact, we recommend that you evolve from using an existing monolithic or N-Tier application by adding new scenarios. 最终,可以将应用程序细分为自治组件或微服务。Eventually, you can break down the application into autonomous components or microservices. 可以沿微服务的方向逐步开始改进整体式应用程序。You can start evolving your monolithic applications in a microservices direction, step by step.

在任何情况下,本指南的其余部分都集中于“没有基于微服务的应用”,因为本指南主要旨在实现通常具有整体式或 N 层体系结构的现有应用的现代化。In any case, the rest of this present guidance focuses most of all on "no microservices-based apps" because this guidance is mainly targeting the modernization of existing apps that usually have monolithic or N-Tier architectures.