天天看點

翻譯 | 3種方式提升雲可擴充性

背景知識

有相關知識的讀者可以跳過此部分内容
           

雲計算作為一種資源, 它的可擴充性是指關于如何處理可變規模業務的能力. 包括 水準擴充 和 垂直擴充.

什麼意思呢?

水準擴充(horizontal scaling)

也稱為橫向擴充, 指能夠連接配接多個軟硬體的特性,這樣可以将多個伺服器從邏輯上看成一個實體.

垂直擴充(vertical scaling)

當一個現有IT資源被具有更大或更小容量的資源所代替,則為垂直擴充. 也就是對目前伺服器的CPU性能等進行原地的擴大和縮小. 由于在進行垂直擴充的時候伺服器需要停機(就如同我們平時使用虛拟機時, 要重新配置設定它的記憶體或CPU的時候需要先關機, 是以在雲環境中這類擴充并不常見.

INTRO

在亞馬遜雲服務中部署被盛贊為是一個很好的方式來實作高擴充性, 并且你隻需要支付你所使用的雲計算機性能即可。那麼,如何從這項技術中獲得最佳的擴充性呢?

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産品提供彈性伸縮這一雲計算的獨特功能。像往常一樣為你的應用程式設定一個負載均衡器和幾個Web伺服器。在模闆AMI的基礎上設計你将不斷複用的Web伺服器。然後設定彈性伸縮并根據你預測的流量設定門檻值。當超過門檻值時,AWS将啟動你的Web伺服器的新執行個體,并自動将其置于負載均衡器池中。一旦流量低于最低門檻值,亞馬遜将從負載均衡器池中為你移除一台伺服器。

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.

請務必要監視此活動的開始,并為之運作一些負載和壓力測試。你需要確定它能如你所期望地正常運轉,并且沒有異常的情況就不會不必要地運轉伺服器。

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. 橫向伸縮資料庫層(Horizontally Scale the Database Tier)

MySQL在這裡提供了一系列的解決方案。你可以在Master-Master(主對主)主動被動叢集(也稱為循環複制)中配置MySQL。在這種配置中,MySQL将把所有已完成的事務發送到叢集中的其他伺服器。你的被動伺服器也可以處理你的應用程式的讀取流量。在實作高可用性的同時,你也可以通過将大部分的SELECT操作流量發送到另一個伺服器來獲得可擴充性。

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) 轉入你的設定, 你就可以進一步擴大讀取操作的規模。在執行此操作時,你可以繼續将所有寫入的内容發送到單個處于活動狀态的主資料庫。

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.
[注]我們為PC配置額外硬碟時, 原有的裝有系統的盤可以稱為主盤(Master)
作為擴充的硬碟稱為從盤(Slave), 在伺服器上類似.
           

或者,你希望采用基于MySQL社群版( community)伺服器的亞馬遜RDS解決方案,但需要某些設定保持鎖定。在這個配置中,你将不能使用諸如Percona的高速伺服器之類的另一種MySQL發行版。這個配置提供的是multi-az(多可用區)配置。請記住,任何你啟動的MySQL伺服器都将有一個區域和可用性空間作為其配置的一部分,是以你可以在亞馬遜網絡服務中自由使用這些功能來提高可用性。

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.

如果單個主資料庫上的負載仍存在問題,那麼可以垂直擴充該節點。通過在EBS的根卷(root volume)上執行個體化一個新的更大的EC2執行個體來完成此操作。然後分離該root volume,停止你的舊執行個體,分離舊執行個體的root volume,并将其移動到新的伺服器。當你将那個活動的root volume附加上去,新的更大的EC2執行個體将是你原來的伺服器,也就是你的伺服器就地擴大了!

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是一項非常棒的技術,因為它為每個EC2執行個體帶來了存儲區域網絡的靈活性。這不是沒有挑戰,并且有時在磁盤I / O (input/output) 的吞吐量上還會有很大的變化。這個變化對資料庫層而言是一個挑戰。請記住,亞馬遜的基礎架構虛拟化層将根據執行個體的大小增加或減少執行個體接收的磁盤I / O數量。

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技術。由于EBS内置備援,是以你可以簡單地在多個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
即磁盤陣列, 利用數組方式來作磁盤組, 将資料切割成許多區段
分别存放在各個硬碟上, 在數組中任意一個硬碟故障時,仍可讀出資料

一共有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
來源:知乎
           

要小心地進行這些配置,因為現在每個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