本文在騰訊云+社區(qū)首發(fā), 為原創(chuàng)翻譯文章.
原文面向?qū)^為專業(yè)的IT從業(yè)者, 為此譯者將對文中一些概念進行注解
以擴大文章所面向的讀者群體. 幫助讀者更好理解本文
文章正文部分以引用格式給出正文
原文中以亞馬遜為例, 實際上很多云服務(wù)廠商均有類似服務(wù)
背景知識
有相關(guān)知識的讀者可以跳過此部分內(nèi)容
云計算作為一種資源, 它的可擴展性是指關(guān)于如何處理可變規(guī)模業(yè)務(wù)的能力. 包括 水平擴展 和 垂直擴展.
什么意思呢?
水平擴展(horizontal scaling)
也稱為橫向擴展, 指能夠連接多個軟硬件的特性,這樣可以將多個服務(wù)器從邏輯上看成一個實體.
垂直擴展(vertical scaling)
當一個現(xiàn)有IT資源被具有更大或更小容量的資源所代替,則為垂直擴展. 也就是對當前服務(wù)器的CPU性能等進行原地的擴大和縮小. 由于在進行垂直擴展的時候服務(wù)器需要停機(就如同我們平時使用虛擬機時, 要重新分配它的內(nèi)存或CPU的時候需要先關(guān)機, 因此在云環(huán)境中這類擴展并不常見.
INTRO
在亞馬遜云服務(wù)中部署被盛贊為是一個很好的方式來實現(xiàn)高擴展性, 并且你只需要支付你所使用的云計算機性能即可。那么壁查,如何從這項技術(shù)中獲得最佳的擴展性呢?
Deploying in the Amazon cloud is touted as a great way to achieve high scalability while paying only for the computing power you use. How do you get the best scalability from the technology?
1. 使用彈性伸縮(Use Auto-scaling)
亞馬遜的EC2產(chǎn)品提供彈性伸縮這一云計算的獨特功能矮嫉。像往常一樣為你的應(yīng)用程序設(shè)置一個負載均衡器和幾個Web服務(wù)器臊诊。在模板AMI的基礎(chǔ)上設(shè)計你將不斷復(fù)用的Web服務(wù)器坡慌。然后設(shè)置彈性伸縮并根據(jù)你預(yù)測的流量設(shè)置閾值。當超過閾值時挚赊,AWS將啟動你的Web服務(wù)器的新實例诡壁,并自動將其置于負載均衡器池中。一旦流量低于最低閾值荠割,亞馬遜將從負載均衡器池中為你移除一臺服務(wù)器妹卿。
Auto-scaling is a unique feature of cloud computing and Amazon's EC2 offering. Setup a load balancer and a couple of webservers for your application as you normally would. Design your webserver based on a template AMI that you'll reuse over and over. Then setup auto-scaling and set thresholds based on the traffic you forecast. When a threshold is passed, AWS will spinup a new instance of your webserver, and roll it into the load balancer pool automatically. Once traffic falls below the scale back threshold, Amazon will take a server out of the pool for you.
請務(wù)必要監(jiān)視此活動的開始,并為之運行一些負載和壓力測試涨共。你需要確保它能如你所期望地正常運轉(zhuǎn)纽帖,并且沒有異常的情況就不會不必要地運轉(zhuǎn)服務(wù)器宠漩。
Be sure to monitor this activity to start with, and also run some load and stress tests on it. You want to ensure that it behaves as you expect, and no anomalous cases will cause you to spinup servers unnecessarily.
2. 橫向伸縮數(shù)據(jù)庫層(Horizontally Scale the Database Tier)
MySQL在這里提供了一系列的解決方案举反。你可以在Master-Master(主對主)主動被動集群(也稱為循環(huán)復(fù)制)中配置MySQL。在這種配置中扒吁,MySQL將把所有已完成的事務(wù)發(fā)送到集群中的其他服務(wù)器火鼻。你的被動服務(wù)器也可以處理你的應(yīng)用程序的讀取流量。在實現(xiàn)高可用性的同時雕崩,你也可以通過將大部分的SELECT操作流量發(fā)送到另一個服務(wù)器來獲得可擴展性魁索。
MySQL offers a number of solutions here. You can configure MySQL in a master-master active passive cluster, also known as circular replication. In this configuration, MySQL will send all completed transactions to the other server in the cluster. Your passive server can also handle read traffic for your application. At the same time as you achieve high availability, you also get scalability by sending much of the SELECT traffic off to another server.
隨著負載的進一步增長,將額外的只讀的從盤(read-only slave) 轉(zhuǎn)入你的設(shè)置, 你就可以進一步擴大讀取操作的規(guī)模盼铁。在執(zhí)行此操作時粗蔚,你可以繼續(xù)將所有寫入的內(nèi)容發(fā)送到單個處于活動狀態(tài)的主數(shù)據(jù)庫。
As the load grows further, roll in an additional read-only slave into your setup. You can then further scale out reads. As you do this, you'll continue to send all writes to the single active master database.
[注]我們?yōu)镻C配置額外硬盤時, 原有的裝有系統(tǒng)的盤可以稱為主盤(Master)
作為擴展的硬盤稱為從盤(Slave), 在服務(wù)器上類似.
或者饶火,你希望采用基于MySQL社區(qū)版( community)服務(wù)器的亞馬遜RDS解決方案鹏控,但需要某些設(shè)置保持鎖定。在這個配置中肤寝,你將不能使用諸如Percona的高速服務(wù)器之類的另一種MySQL發(fā)行版当辐。這個配置提供的是multi-az(多可用區(qū))配置。請記住鲤看,任何你啟動的MySQL服務(wù)器都將有一個區(qū)域和可用性空間作為其配置的一部分缘揪,所以你可以在亞馬遜網(wǎng)絡(luò)服務(wù)中自由使用這些功能來提高可用性。
As an alternative, you may wish to employ Amazon's RDS solution, which is based on the MySQL community server, but with certain locked in settings. In this configuration you will not be able to use an alternate MySQL distribution such as Percona's high speed server. What this configuration does offer is multi-az configuration. Keep in mind though that any MySQL server you spinup will have a region and availability zone as part of it's configuration, so you are always free to use those features of Amazon's network to increase availability.
如果單個主數(shù)據(jù)庫上的負載仍存在問題义桂,那么可以垂直擴展該節(jié)點找筝。通過在EBS的根卷(root volume)上實例化一個新的更大的EC2實例來完成此操作。然后分離該root volume慷吊,停止你的舊實例袖裕,分離舊實例的root volume,并將其移動到新的服務(wù)器罢浇。當你將那個活動的root volume附加上去陆赋,新的更大的EC2實例將是你原來的服務(wù)器沐祷,也就是你的服務(wù)器就地擴大了!
If the load on the single master database continues to be a problem, you can vertically scale that node in place. Do this by spinning up a new larger EC2 instance on and EBS root volume. Then detach that root volume, stop your old instance, detach it's root volume and move it over to the new server. Once you attach that live root volume, your new larger EC2 instance will be your original server, scaled UP in place!
3. 使用 條帶化(Striped) EBS root volume
[注] EBS, Elastic Block Store, 即彈性塊存儲
EBS是一項非常棒的技術(shù)攒岛,因為它為每個EC2實例帶來了存儲區(qū)域網(wǎng)絡(luò)的靈活性赖临。這不是沒有挑戰(zhàn),并且有時在磁盤I / O (input/output) 的吞吐量上還會有很大的變化灾锯。這個變化對數(shù)據(jù)庫層而言是一個挑戰(zhàn)兢榨。請記住,亞馬遜的基礎(chǔ)架構(gòu)虛擬化層將根據(jù)實例的大小增加或減少實例接收的磁盤I / O數(shù)量顺饮。
EBS is a great technology, as it brings the flexibility of a storage area network to each of your EC2 instances. It's not without it's challenges though, and at times you will experience great variability in disk I/O throughput. This can pose a challenge for the database tier especially. Keep in mind too, that Amazon's infrastructure virtualization layer will dial up or dial down the amount of disk I/O your instance receives based on how large the instance is.
另一個獲得更好EBS性能的方法是使用Linux軟件的RAID技術(shù)吵聪。由于EBS內(nèi)置冗余,因此你可以簡單地在多個EBS卷上使用Striping或RAID 0 -- 我們推薦使用4個兼雄。
One additional way to get better EBS performance is by using Linux's software raid technology. Since EBS already has redundancy built in, you can simply use striping or RAID 0 across a number of EBS volumes - we recommend four.
[注] RAID, Redundant Arrays of Independent Disks
即磁盤陣列, 利用數(shù)組方式來作磁盤組, 將數(shù)據(jù)切割成許多區(qū)段
分別存放在各個硬盤上, 在數(shù)組中任意一個硬盤故障時吟逝,仍可讀出數(shù)據(jù)
一共有0~6一共7種,這其中RAID 0赦肋、RAID1块攒、RAID 5和RAID6比較常用。
RAID 0 又稱為Stripe(條帶化,串列)或Striping
它代表了所有RAID級別中最高的存儲性能
RAID 0:如果你有n塊磁盤佃乘,原來只能同時寫一塊磁盤囱井,寫滿了再下一塊,
做了RAID 0之后趣避,n塊可以同時寫庞呕,速度提升很快,但由于沒有備份程帕,
可靠性很差住练。n最少為2。
引自知乎
作者:孫小霞
鏈接:https://www.zhihu.com/question/20131784/answer/28026813
來源:知乎
要小心地進行這些配置骆捧,因為現(xiàn)在每個EBS卷都不能自動操作澎羞,但要求四個都要完成。這也會影響EBS快照備份敛苇。
Be careful with such configurations as each of your EBS volumes won't operate by themselves now, but require all four to be complete. This will impact EBS snapshot backups, as well.
翻譯人:FesonX
文章鏈接 : https://cloud.tencent.com/developer/article/1020235
原文鏈接:https://dzone.com/articles/3-ways-boost-cloud-scalability
原文作者:Sean Hull
封面圖案:Julien Deveaux