1. 程式人生 > >Amazon雲端計算服務EC2、S3介紹

Amazon雲端計算服務EC2、S3介紹

•EC2主要功能
•EC2使用流程
•EC2模板映像
•EC2的流量和IP費用
•S3功能
•S3中的概念與操作
•S3客戶端
•S3使用例項
•S3的價格
•Amazon AWS影響力
•Amazon AWS側面影響力
•Amazon AWS潛力

EC2主要功能
建立包含應用、庫、資料和配置的機器映像。或者使用時限配置好的模板映像。
上傳映像到Amazon S3。
用Web Service配置安全性和網路訪問。
啟動、終止、監視映像的任意多個執行例項。
只為實際使用的資源付費。



•EC2使用流程
在Amazon Web Services上註冊使用者,輸入支付方式
下載並安裝最新的Java Runtime Environment,Amazon EC2 command-line tools ,PuTTY & PuTTYgen 。
建立並下載private key檔案和X.509 certificate
執行‘C:/EC2/bin>ec2-describe-images -o self -o amazon’ 來檢視所有公共的映象
執行例項 C:/EC2/bin>ec2-run-instances ami-25b6534c -k kiki-keypair
通過以下命令檢視狀態 C:/EC2/bin>ec2-describe-instances i-c3f31eaa
給例項授以網路訪問的許可權。C:/EC2/bin>ec2-authorize default -p 22
用PuTTY連線例項
中止例項 C:/EC2/bin>ec2-terminate-instances i-c3f31eaa


•EC2模板映像

Standard Instances

Instances of this family are well suited for most applications.

$0.10 - Small Instance (Default)
1.7 GB of memory, 1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit), 160 GB of instance storage, 32-bit platform

$0.40 - Large Instance
7.5 GB of memory, 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each), 850 GB of instance storage, 64-bit platform

$0.80 - Extra Large Instance
15 GB of memory, 8 EC2 Compute Units (4 virtual cores with 2 EC2 Compute Units each), 1690 GB of instance storage, 64-bit platform

High-CPU Instances

Instances of this family have proportionally more CPU resources than memory (RAM) and are well suited for compute-intensive applications.

$0.20 - High-CPU Medium Instance
1.7 GB of memory, 5 EC2 Compute Units (2 virtual cores with 2.5 EC2 Compute Units each), 350 GB of instance storage, 32-bit platform

$0.80 - High-CPU Extra Large Instance
7 GB of memory, 20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each), 1690 GB of instance storage, 64-bit platform



•EC2的流量和IP費用


Internet Data Transfer
$0.100 per GB - all data transfer in $0.170 per GB - first 10 TB / month data transfer out
$0.130 per GB - next 40 TB / month data transfer out
$0.110 per GB - next 100 TB / month data transfer out
$0.100 per GB - data transfer out / month over 150 TB

Elastic IP Addresses
    No cost for Elastic IP addresses while in use
$0.01 per non-attached Elastic IP address per complete hour
$0.00 per Elastic IP address remap - first 100 remaps / month
$0.10 per Elastic IP address remap - additional remap / month over 100


•S3功能


支援最小1byte,最大5G的儲存物件;
無存貯物件個數上的限制;
每個儲存物件儲存在bucket中,且由有個使用者定義的唯一性key來標識;
可以對每個存貯物件設定訪問許可權;
提供了REST和SOAP介面對物件進行讀寫、刪除等操作;
可靠時間為99.9%;

•S3中的概念與操作
S3中的概念
Account
註冊Amazon,申請開通S3後,得到AccessKey和Secret Key,你必須使用這兩個key來呼叫API。

Bucket:
是S3中儲存物件的容器,對應一個S3的域名,Bucket的名字不能重複,每個Bucket中可以儲存無限個物件。

Object:
是S3中的基本儲存單元,單個Object最大5G,放在Bucket中,由Key唯一標識,有ObjectData和metaData組成,metaData可以是標準的metadata或者自定義的metadata。

KEY
KEY在Bucket中用來唯一標識一個Object,也就是說使用Bucket+KEY可以在S3中唯一標識一個Object。


S3中的操作
Services --list all buckets.
Bucket  --Create,Delete,List,Get/Set Access Control,Get/Set logging status;
Object  --Put,Get,Delete,Set/Get Access Control.

•S3客戶端
S3的API和庫
–REST 和SOAP
–JAVA
–C#
–Python
–Ruby
–PHP,PERL...
S3客戶端工具
–S3cmd
–S3sync
–FireFox plug-in
–etc...

•S3使用例項
class Up2S3
 
  def initialize
    puts "start..."
    start = Time.now
    conf_file = YAML.load_file(File.expand_path('amazon_conf.yml'))
    @@s3 =  RightAws::S3Interface.new(conf_file['access_key_id'], conf_file['secret_access_key'])
    puts "@@s3=#{@@s3.to_s}"
    puts "Init Spend Time #{Time.now - start}"
  end
 
  #下載測試程式碼
  def self.download(bucket,key)
    start = Time.now
    foo = File.new(key, "wb+")
    @@s3.get(bucket, key) do |chunk|
      foo.write(chunk)
    end
    foo.close
    puts "Download Spend Time #{Time.now - start}"
  end
 
  #上傳測試程式碼
  def self.upload(bucket,key,filename)
    start = Time.now
    @@s3.put(bucket,key, File.open(filename)) #=> true
    puts "Upload Spend Time #{Time.now - start}"
  end
 
end

•S3的價格
美國價格:
Storage
$0.15 per GB-Month of storage used Data Transfer
$0.100 per GB - all data transfer in

$0.170 per GB - first 10 TB / month data transfer out
$0.130 per GB - next 40 TB / month data transfer out
$0.110 per GB - next 100 TB / month data transfer out
$0.100 per GB - data transfer out / month over 150 TB

Requests
$0.01 per 1,000 PUT, POST, or LIST requests
$0.01 per 10,000 GET and all other requests*

Amazon AWS影響力
Top 10 Enterprises in the Cloud
•The NY Times
Amazon EC2
•Nasdaq
Amazon S3
•Major League Baseball
Joyent
•ESPN
Rightscale using Amazon EC2
•Hasbro
Amazon EC2
•British Telecom
3Tera
•Taylor Woodrow
Google Apps
•CSS
Amazon EC2
•Activision
Amazon EC2
•Business Objects (A SAP Company)
Rightscale using Amazon EC2

•Amazon AWS側面影響力
AWS對CDN的威脅。While Amazon's AWS service is not a fit for most of those who use a CDN today, it is interesting to see how some of the CDNs are using Amazon's service to their advantage. Digital Fountain is building their streaming only, U.S. based CDN on Amazon Web Services and other CDNs like Voxel.net have direct integration with Amazon's S3 API.
AWS2007年經產生約1億美元的收入
AWS流量需求2007年已經大於Amazon全球網站流量需求。As an indicator of adoption, bandwidth utilized by these services in fourth quarter 2007 was even greater than bandwidth utilized in the same period by all of Amazon.com’s global websites combined.
AWS吸引大量開發人員關注。Over 400,000 developers have registered to use Amazon Web Services (AWS), up more than 30,000 from last quarter.
除AWS四大服務外,正在部署按需視訊服務。Amazon.com introduced a limited beta version of Amazon Video On Demand. The service lets customers rent or buy ad-free movies and television shows and watch them instantly within their web browser on Macs or PCs and through Sony BRAVIA television sets with the use of the Sony BRAVIA Internet Video Link.

•Amazon AWS潛力
AWS已經在個人和初創企業獲得口碑和大量使用者,並開始浸入企業級市場
In a recent TechCrunch article about Amazon Web Services, it‘s revealed that “the biggest customers in both number and amount of computing resources consumed are divisions of banks, pharmaceuticals companies and other large corporations who try AWS once, for a temporary project, and then get hooked.
Photo sharing service SmugMug received much attention when they published their business case for using Amazon's S3 storage service. The 2002 startup describes how the service saves them between half a million to a million USD per year.
  • It's too small. I had the same trouble with EC2 until recently. Normal  accounts are limited to 18 VCPUs. I have 1500 now after talking ith   them so I'm hoping to use it more. We do testing on internal farms of   boxes much bigger than the proposed HP cloud, I think it's about 120  boxes figuring 8 cores per box minimum.