aws 彈性三劍客
I’ll assume that, one way or another, you’re already familiar with many of AWS’s core deployment services. That means you now know about:
我假設您已經熟悉許多AWS的核心部署服務。 這意味著您現在知道:
? EC2 instances and AMIs (Amazon Machine Images), and the “peripheral” tools that support their deployment like security groups and EBS volumes
?EC2實例和AMI(Amazon機器映像),以及支持其部署的“外圍”工具,例如安全組和EBS卷
? Incorporating databases into our applications, both on-instance and through the managed RDS service
?實例化和通過托管RDS服務將數據庫整合到我們的應用程序中
? Using S3 buckets to deliver media files through our EC2 applications and for server backup storage
?使用S3存儲桶通過我們的EC2應用程序傳遞媒體文件并用于服務器備份存儲
? Controlling access to our AWS resources with IAM (Identity and Access Management)
?使用IAM(身份和訪問管理)控制對我們AWS資源的訪問
? Managing growing resource sets by intelligently applying tags, and
?通過智能地應用標簽來管理不斷增長的資源集,以及
? Accessing our resources using either the browser interface or the AWS CLI (Command Line Interface)
?使用瀏覽器界面或AWS CLI(命令行界面)訪問我們的資源
All that can be represented by the schematic in figure 1.
所有這些都可以由圖1中的示意圖表示。
Now I’m going to shift the focus just a bit and explore some best-practices for application optimization. Figure 2 can help you visualize how all that infrastructure can be made highly available through the magic of network segmenting, auto scaling, and load balancing.
現在,我將重點轉移一點,并探索一些應用程序優化的最佳實踐。 圖2可以幫助您可視化如何通過網絡分段,自動擴展和負載平衡的魔力使所有基礎設施高度可用。
While you probably won’t yet be familiar with many of the tools and relationships represented in the diagram, you should spend a minute making a mental note of at least a few key points, including:
盡管您可能還不熟悉圖中所示的許多工具和關系,但是您應該花一點時間至少記下一些關鍵點,包括:
? The Virtual Private Cloud (VPC) that encompasses all the AWS resources in our application deployment
?虛擬私有云(VPC)包含我們應用程序部署中的所有AWS資源
? The two kinds of availability zones: private and public?—?used to manage and, where needed, isolate resources
?兩種可用性區域:私有和公共-用于管理資源,并在需要時隔離資源
? The security groups whose rules control the movement of data between resources
?其規則控制資源之間的數據移動的安全組
? The EC2 AMI (Amazon Machine Image) that acts as a template for replicating precise operating system environments
?EC2 AMI(Amazon機器映像),用作復制精確的操作系統環境的模板
? The S3 (Simple Storage Service) bucket that can store and deliver data?—?both for backup and delivery to users
?S3(簡單存儲服務)存儲桶,可以存儲和交付數據-既可以備份又可以交付給用戶
? The EBS volumes that act as data volumes (like hard drives) for an instance
?充當實例的數據卷(例如硬盤驅動器)的EBS卷
? The auto scaler that permits automatic provisioning of greater (or fewer) instances to meet changing demands on an application, and
?自動縮放器,允許自動設置更多(或更少)的實例,以滿足對應用程序不斷變化的需求,以及
? The load balancer that routes traffic among multiple servers to ensure the smoothest and most efficient user experience
?在多個服務器之間路由流量的負載平衡器,以確保最流暢,最有效的用戶體驗
I’m pretty sure you’ve picked up on this already: the “e” in many AWS service names (EC2, ECS, EFS, EMR…) doesn’t stand for “electronic” the way it does in the names of some older technologies like email, but “elastic.” You can, nevertheless, be excused for wondering just what it is about the AWS vision of cloud computing that’s so elastic.
我敢肯定,您已經掌握了這一點:許多AWS服務名稱(EC2,ECS,EFS,EMR…)中的“ e”并不代表某些名稱中的“電子”方式較早的技術(例如電子郵件),但具有“彈性”。 但是,您可以因懷疑AWS如此靈活的云計算愿景而感到困惑。
But before I get to answering that question, it might be useful to talk a bit about cloud computing in general. Understanding what makes the cloud unique is probably essential to taking full advantage of all that it has to offer.
但是,在我開始回答這個問題之前,通常先討論一下云計算可能會很有用。 要充分利用云所提供的一切,了解云獨特的原因可能是必不可少的。
云計算 (Cloud Computing)
The US National Institute of Standards and Technology (NIST) defines cloud computing as services that offer their users all of these five qualities:
美國國家標準技術研究院(NIST)將云計算定義為為用戶提供以下五種品質的服務:
? On-demand self-service: Customers are able to access public cloud resources whenever needed and without having to order them through a human representative.
?按需自助服務:客戶可以在需要時訪問公共云資源,而不必通過人工代表訂購。
? Broad network access: Cloud resources are accessible from any network-connected (i.e., Internet) location.
?廣泛的網絡訪問:可從任何網絡連接(即Internet)位置訪問云資源。
? Resource pooling: Cloud providers offer a multi-tenant model, whereby individual customers can safely share resources with each other, and dynamic resource assignment, through which resources can be allocated and deallocated according to customer demand.
?資源池:云提供商提供了多租戶模型,單個客戶可以安全地共享彼此的資源,并可以動態分配資源,從而可以根據客戶需求分配和重新分配資源。
? Rapid elasticity: Resource availability and performance can be automatically increased or decreased to meet changing customer demand.
?快速彈性:可以自動增加或減少資源可用性和性能,以滿足不斷變化的客戶需求。
? Measured service: Customers are able to consume services at varying levels through a single billing period and be charged only for those resources that they actually use.
?計量服務:客戶可以在一個計費周期內使用不同級別的服務,并且僅對其實際使用的資源付費。
These five qualities describe a deeply flexible and highly automated system whose elements can be freely mixed and matched to provide the most efficient and cost-effective service possible. But, a great deal of what makes this possible is the existence of integrated systems that can dynamically adjust themselves based on what’s going on around them. These adjustments are examples of elastic behavior.
這五種品質描述了一個高度靈活且高度自動化的系統,該系統的各個要素可以自由混合和匹配,以提供最高效,最具成本效益的服務。 但是,使這成為可能的很多原因是存在集成系統,這些系統可以根據周圍發生的事情動態地進行自我調整。 這些調整是彈性行為的示例。
彈性與可伸縮性 (Elasticity vs Scalability)
So elasticity, as we have established, is a system’s ability to monitor user demand and automatically increase and decrease deployed resources accordingly. Scalability, by contrast, is a system’s ability to monitor user demand and automatically increase and decrease…wait: didn’t I just say that about elasticity?
因此,正如我們已經建立的,彈性是系統監視用戶需求并相應地自動增加和減少已部署資源的能力。 相比之下,可伸縮性是系統監視用戶需求并自動增加和減少…的能力……等等:我不是只是說彈性嗎?
It’s a bit complicated. In fact, the two terms are sometimes used interchangeably. However I think it’s worthwhile distinguishing between them. Now bear in mind that the way I explain the relationship between these two ideas is by no means the last word on the subject -– look around a bit and you will find some other approaches. But, I think, within the context of understanding how AWS works, my spin should be useful.
這有點復雜。 實際上,這兩個術語有時可以互換使用。 但是,我認為有必要區分它們。 現在請記住,我解釋這兩種想法之間關系的方式絕不是該主題的最后一句話-環顧四周,您會發現其他一些方法。 但是,我認為,在了解AWS如何工作的背景下,我的旋轉應該會很有用。
What makes an elastic band elastic, is partly its ability to stretch under pressure, but also the way it quickly returns to its original size when the pressure is released. In AWS terms, that would mean the way, for instance, EC2 makes instances available to you when needed, but lets you drop them when they’re not; charging you only for up time. See figure 3.
使松緊帶具有彈性的部分原因是其在壓力下拉伸的能力,而且還在于在釋放壓力后Swift恢復其原始大小的方式。 用AWS術語來說,這意味著,例如,EC2可以在需要時向您提供實例,而在不需要時可以將它們刪除; 僅向您收費。 參見圖3。
Scalability describes the way a system is designed to meet changing demand. That might include the fact that you’ve got 24-hour access to any resources you might need (which, of course, is an elastic feature), but it also means that the underlying design itself supports rapid and unpredictable changes.
可伸縮性描述了系統滿足不斷變化的需求的方式。 這可能包括以下事實:您可以24小時訪問您可能需要的任何資源(這當然是一種彈性功能),但這也意味著底層設計本身支持快速且不可預測的更改。
As an example, software that’s scalable can be easily picked up and dropped onto a new server -– possibly within a new network environment -– and just run without any manual configuration. Similarly, as is illustrated in figure 4, the composition of a scalable infrastructure can be quickly changed in a way that all the old bits and pieces immediately know how to work together with the new ones.
例如,可以輕松地將可伸縮的軟件安裝到新服務器上(可能在新的網絡環境中)并放到新服務器上,而無需任何手動配置即可運行。 類似地,如圖4所示,可伸縮基礎結構的組成可以以所有舊的點點滴滴都立即知道如何與新的點點滴滴一起工作的方式快速更改。
With that in mind, we can say that Amazon’s EC2 is not only elastic but, since its elements (instances, storage volumes, security groups, etc.) can be smoothly dropped into and out of running infrastructures, it’s also very scalable. Ah, but what kind of scalable? There are two, you know:
考慮到這一點,我們可以說Amazon EC2不僅具有彈性,而且由于其元素(實例,存儲量,安全組等)可以順利地放入和退出運行的基礎架構,因此它也具有很好的可擴展性。 嗯,但是什么樣的可擴展性? 有兩個,您知道的:
? Horizontal scaling is “scaling out”?—?where you add more lightweight server nodes (or “instances”) to meet growing demand.
?水平擴展是“向外擴展” —在其中添加更多輕量級服務器節點(或“實例”)以滿足不斷增長的需求。
? Vertical scaling is “scaling up”?—?where you move your application from a single lightweight server to one with greater compute capacity.
?垂直擴展是“向上擴展” —您將應用程序從單個輕量級服務器移至具有更大計算能力的服務器。
It is certainly possible to transfer AWS-based applications from lighter to heavier servers, and for some payloads?—?like many high-load transaction databases, it’s preferred. But in an AWS context, if you hear some conjugation of the word “scale”, the odds are that it’s referring to horizontal scaling.
當然,可以將基于AWS的應用程序從較輕的服務器轉移到較重的服務器,并且對于某些負載(例如許多高負載事務數據庫),它是首選。 但是在AWS環境中,如果您聽到“ scale”一詞的一些變化,那么很可能是指水平縮放。
實際應用 (Practical applications)
Ok. But who cares? Well, as the customer demand on our WordPress site continues to grow, we will, and in a big way. You see, for some reason -– perhaps related to the fact that we discount the price of our product by 75% for just a half an hour each evening -– customers arrive in their greatest numbers in the early evening, local time. So while the single server we’ve been running stands largely unused throughout most of the day, it simply melts under the pressure of thousands of visits squeezed into such a short stretch of time.
好。 但誰在乎? 好吧,隨著我們WordPress網站上的客戶需求持續增長,我們將以極大的方式發展。 您會看到某些原因-也許與我們每晚將產品價格降低75%的事實有關-每天晚上半小時客戶到達的數量最多。 因此,盡管我們一直在運行的單個服務器在一天中的大部分時間里都處于閑置狀態,但它卻在成千上萬次訪問的壓力下融化了,而訪問卻被壓縮到如此短的時間內。
And then there’s that question one of the guys in the office asked the other day: “Our entire business is running on a single web server; what happens if it goes down?” What indeed.
那天辦公室里的一個人問了一個問題:“我們的整個業務都在一臺Web服務器上運行; 如果它下降怎么辦?” 的確如此。
We could provision four or five extra servers and run them full time. That way, we’d be covered for the high-volume periods and for the failure of any one server. But it would still involve colossal waste, since for most of each day we’d be paying for most of the instances to sit idle. Nor would it necessarily be much help in the event of a network failure, which would likely cut connectivity to all the servers at the same time.
我們可以提供四到五臺額外的服務器,并全時運行它們。 這樣一來,我們就可以應對大批量交易以及任何一臺服務器的故障。 但這仍然會帶來巨大的浪費,因為在每天的大部分時間里,我們都會為大多數實例保持空閑狀態付費。 如果發生網絡故障,也不一定會有太大幫助,因為這可能會同時切斷與所有服務器的連接。
We could always address at least the customer demand issue by arranging for someone to be at the office every evening to manually fire up as many extra servers as we’ll need. But we asked around, and no one volunteered. And besides, the best way to ensure a daily job won’t get done is to assume that an admin will remember to do it.
我們總是可以安排每天晚上到辦公室來手動啟動盡可能多的額外服務器,從而至少解決客戶需求問題。 但是我們四處詢問,沒有人自愿參加。 此外,確保日常工作不會完成的最好方法是假設管理員會記得這樣做。
自動化高可用性 (Automating High Availability)
Alternatively, we could spend some time incorporating high availability capability into our setup and let the whole thing be quietly and efficiently managed by software. This will be the subject of the next few chapters of my book, where we will learn to leverage AWS’s geographically remote availability zones to make total application failure much less likely, use load balancing to coordinate between parallel servers and monitor their health, and auto scaling to let AWS automatically respond to the peaks and valleys of changing demand by launching and shutting down instances according to need.
另外,我們可以花一些時間將高可用性功能整合到我們的設置中,然后讓整個過程由軟件安靜有效地管理。 這將是本書接下來幾章的主題,我們將在其中學習如何利用AWS的地理位置遠程可用性區域來降低應用程序整體故障的可能性,使用負載平衡來協調并行服務器之間的狀態并監控其運行狀況,并自動擴展讓AWS通過根據需要啟動和關閉實例來自動響應需求變化的高峰和低谷。
For more info on Amazon Web Services, download the free first chapter of Learn Amazon Web Service in a Month of Lunches and see this Slideshare presentation. Don’t forget to use code ssclinton to save 42% off your purchase.
有關Amazon Web Services的更多信息, 請在一個月的午餐中下載學習Amazon Web Service的免費第一章,并參閱此Slideshare演示文稿 。 不要忘了使用代碼ssclinton節省42%的購買費用。
翻譯自: https://www.freecodecamp.org/news/aws-and-elasticity-keeping-ahead-of-user-demand/
aws 彈性三劍客