云本机应用程序简介Introduction to cloud-native applications

重要

预览版PREVIEW EDITION

本文提供的内容来自当前正在撰写的书籍的早期部分。This article provides early content from a book that is currently under construction. 如有任何反馈,请通过 https://aka.ms/ebookfeedback 进行提交。If you have any feedback, submit it at https://aka.ms/ebookfeedback.

另一天,在办公室,处理 "下一项重大事情"。Another day, at the office, working on "the next big thing."

你的手机环。Your cellphone rings. 这是你的友好招聘人员,一天向你致电两次新作业。It's your friendly recruiter - the one who calls you twice a day about new jobs.

但这种情况不同:启动、权益和大量投资。But this time it's different: Start-up, equity, and plenty of funding.

提到的云和先进的技术将会推动你的边缘。The mention of the cloud and cutting-edge technology pushes you over the edge.

快几周后,你现在就可以在设计会话中构建一个新的员工来构建主要的电子商务应用程序。Fast forward a few weeks and you're now a new employee in a design session architecting a major eCommerce application. 你将在其他领先的电子商务网站上完成。You're going to complete with other leading eCommerce sites.

您将如何生成它?How will you build it?

如果按照过去15年的指导进行操作,则很可能会生成图1.1 所示的系统。If you follow the guidance from past 15 years, you'll most likely build the system shown in Figure 1.1.

传统的整体设计

图 1-1Figure 1-1. 传统的整体设计Traditional monolithic design

构造包含所有域逻辑的大型核心应用程序。You construct a large core application containing all of your domain logic. 它包括标识、目录、排序等模块。It includes modules such as Identity, Catalog, Ordering, and more. 核心应用与大型关系数据库通信。The core app communicates with a large relational database. 核心通过 HTML 接口公开功能。The core exposes functionality via an HTML interface.

祝贺你!Congratulations! 刚刚创建了一个应用程序。You just created a monolithic application.

并非全部都是正确的。Not all is bad. 固化结构提供了一些独特的优势。Monoliths offer some distinct advantages. 例如,它们是非常简单的 。For example, they're straightforward to...

  • 生成build
  • 测试test
  • 满怀信心deploy
  • 相关troubleshoot
  • 小数位数scale

目前存在的许多成功应用都创建为固化结构。Many successful apps that exist today were created as monoliths. 该应用程序是点击的,在迭代后将继续发展,增加了更多的功能。The app is a hit and continues to evolve, iteration after iteration, adding more and more functionality.

但在某些时候,你会感到不安。At some point, however, you begin to feel uncomfortable. 你发现自己失去了对应用程序的控制。You find yourself losing control of the application. 随着时间的推出,感觉就变得越来越多,最终进入了所谓的状态。As time goes on, the feeling becomes more intense and you eventually enter a state known as the Fear Cycle.

  • 此应用已变得充分,因此不会有任何人理解它。The app has become so overwhelmingly complicated that no single person understands it.
  • 您担心进行更改-每个更改都有意想不到和昂贵的副作用。You fear making changes - each change has unintended and costly side effects.
  • 新功能/修补变得更加棘手、耗时且成本高昂。New features/fixes become tricky, time-consuming, and expensive to implement.
  • 每个版本都很小,因为它可能需要整个应用程序的完整部署。Each release as small as it may be requires a full deployment of the entire application.
  • 一个不稳定的组件可能会损坏整个系统。One unstable component can crash the entire system.
  • 不能选择新的技术和框架。New technologies and frameworks aren't an option.
  • 很难实现敏捷交付方法。It's difficult to implement agile delivery methodologies.
  • 体系结构 erosion 在中将设置为代码库 deteriorates,其中包含永不结束的 "特殊情况"。Architectural erosion sets in as the code base deteriorates with never-ending "special cases."
  • 顾问会告诉你重写它。The consultants tell you to rewrite it.

许多组织都采用了一种用于构建系统的云本机方法来解决了单一的恐惧。Many organizations have addressed the monolithic fear cycle by adopting a cloud-native approach to building systems. 图1-2 显示了一种在应用程序本机技术和实践的同时构建的系统。Figure 1-2 shows the same system built applying cloud-native techniques and practices.

云-本机设计

图 1-2Figure 1-2. 云-本机设计Cloud-native design

请注意应用程序如何在一组小型独立微服务中分解。Note how the application is decomposed across a set of small isolated microservices. 每个服务都是自包含的,它封装自己的代码、数据和依赖项。Each service is self-contained and encapsulates its own code, data, and dependencies. 每个部署在软件容器中并由容器 orchestrator 管理。Each is deployed in a software container and managed by a container orchestrator. 每个服务都拥有其自己的数据存储,而不是大型关系数据库,而这种数据库的类型根据数据需求而有所不同。Instead of a large relational database, each service owns it own datastore, the type of which vary based upon the data needs. 请注意某些服务如何依赖于关系数据库,但其他服务依赖于 NoSQL 数据库。Note how some services depend on a relational database, but other on NoSQL databases. 一个服务将其状态存储在分布式缓存中。One service stores its state in a distributed cache. 请注意所有流量如何通过 API 网关服务进行路由,该服务负责将流量路由到核心后端服务,并强制执行许多交叉切削问题。Note how all traffic routes through an API Gateway service that is responsible for routing traffic to the core back-end services and enforcing many cross-cutting concerns. 最重要的是,应用程序充分利用了新式云平台中的可伸缩性和复原功能。Most importantly, the application takes full advantage of the scalability and resiliency features found in modern cloud platforms.

云本机计算Cloud-native computing

嗯 。我们刚才使用了 "云本机" 这一术语。Hmm... We just used the term, "Cloud Native." 首先,您可能会说 "这是什么意思呢?"You first thought might be, “What exactly does that mean?” 软件供应商 concocted 的另一个行业流行用语?Another industry buzzword concocted by software vendors to market more stuff?”

幸运的是,这种方法并不是很容易的,因此,这本书有助于说服你。Fortunately it’s far different and hopefully this book will help convince you.

在短期内,云本机已成为软件行业中的推动趋势。Within a short time, cloud native has become a driving trend in the software industry. 这是一种新的方法,可用于构建大型复杂系统,这是一种充分利用新式软件开发做法、技术和云基础结构的方法。It’s a new way to think about building large, complex systems, an approach that takes full advantage of modern software development practices, technologies, and cloud infrastructure. 此方法会改变您设计、实施、部署和操作系统的方式。The approach changes the way you design, implement, deploy, and operationalize systems.

与推动我们的行业的连续夸大宣传不同,云本机是 "真实的"。Unlike the continuous hype that drives our industry, cloud native is “for-real.” 请考虑云本机计算基础(CNCF),这是一位超过300的主要企业,旨在使云本机计算跨技术和云堆栈。Consider the Cloud Native Computing Foundation (CNCF), a consortium of over 300 major corporations with a charter to make cloud-native computing ubiquitous across technology and cloud stacks. 作为最具影响力的开源组之一,它在 GitHub 中托管了许多增长最快的开放源代码项目。As one of the most influential open-source groups, it hosts many of the fastest-growing open source-projects in GitHub. 其中包括KubernetesPrometheusHelmEnvoygRPC等项目。They include projects such as Kubernetes, Prometheus, Helm, Envoy, and gRPC.

CNCF 促进开源和供应商中立的生态系统。The CNCF fosters an ecosystem of open-source and vendor-neutrality. 接下来,我们提供了云本机原则、模式和最佳做法,它们与技术无关。Following that lead, we present cloud-native principles, patterns, and best practices that are technology agnostic. 同时,我们讨论 Microsoft Azure 云中提供的服务和基础结构,用于构造云本机系统。At the same time, we discuss the services and infrastructure available in the Microsoft Azure cloud for constructing cloud-native systems.

那么,云的确切情况如何呢?So, what exactly is Cloud Native? 让我们来帮助您探索这一新的世界。Sit back, relax, and let us help you explore this new world.