AWS SAA 学習ノート②:EC2
Overview (概要)
- EC2 = Elastic Compute Cloud = Infrastructure as a Service (エラスティックコンピュートクラウド = サービスとしてのインフラストラクチャ)
EC2のサイジングと設定オプション
OS
- Linux
- Windows
- Mac OS
ハードウェア仕様
- Compute power & cores (CPU) (計算能力とコア数)
- Random-access memory (RAM) (ランダムアクセスメモリ)
- Storage space (ストレージ容量):
- Network-attached (EBS & EFS) (ネットワーク接続型)
- Hardware (EC2 Instance Store) (ハードウェア型)
ネットワーク設定
- Network card: speed of the card, Public IP address (ネットワークカード:カードの速度、パブリックIPアドレス)
- Firewall rules: security group (ファイアウォールルール:セキュリティグループ)
- Bootstrap script (configure at first launch): EC2 User Data (ブートストラップスクリプト(初回起動時設定))
EC2 User Data
- It is possible to bootstrap our instances using an EC2 User data script (EC2 User dataスクリプトを使用してインスタンスをブートストラップすることが可能)
- Bootstrapping means launching commands when a machine starts (ブートストラップとは、マシン起動時にコマンドを実行すること)
- That script is only run once at the instance first start (このスクリプトはインスタンスの初回起動時に一度だけ実行される)
使用例
- Installing updates (アップデートのインストール)
- Installing software (ソフトウェアのインストール)
- Downloading common files from the internet (インターネットから共通ファイルのダウンロード)
注意点!!!
- The EC2 User Data Script runs with the root user (EC2 User Dataスクリプトはrootユーザーで実行される)
インスタンスタイプ
命名規則
Example: m5.2xlarge
- m: instance class (インスタンスクラス)
- 5: generation (AWS improves them over time) (世代(AWSが時間とともに改善))
- 2xlarge: size within the instance class (インスタンスクラス内のサイズ)
インスタンスタイプのカテゴリ
1. General Purpose (汎用)
Great for: A diversity of workloads such as web servers or code repositories (Webサーバーやコードリポジトリなど多様なワークロードに最適)
Balance between (バランスの取れた):
- Compute (計算処理)
- Memory (メモリ)
- Networking (ネットワーキング)
Course Example: t2.micro which is a General Purpose EC2 instance (コースではGeneral Purpose EC2インスタンスであるt2.microを使用)
2. Compute Optimized (コンピュート最適化)
Great for: Compute-intensive tasks that require high performance processors (高性能プロセッサを必要とするコンピュート集約的なタスクに最適)
Use Cases (使用例):
- Batch processing workloads (バッチ処理ワークロード)
- Media transcoding (メディアトランスコーディング)
- High performance web servers (高性能Webサーバー)
- High performance computing (HPC) (高性能コンピューティング)
- Scientific modeling & machine learning (科学的モデリングと機械学習)
- Dedicated gaming servers (専用ゲームサーバー)
3. Memory Optimized (メモリ最適化)
Great for: Fast performance for workloads that process large data sets in memory (メモリ内で大規模データセットを処理するワークロードの高速パフォーマンスに最適)
Use Cases (使用例):
- High performance, relational/non-relational databases (高性能なリレーショナル/非リレーショナルデータベース)
- Distributed web scale cache stores (分散Webスケールキャッシュストア)
- In-memory databases optimized for BI (business intelligence) (BI用に最適化されたインメモリデータベース)
- Applications performing real-time processing of big unstructured data (大規模非構造化データのリアルタイム処理を行うアプリケーション)
4. Storage Optimized (ストレージ最適化)
Great for: Storage-intensive tasks that require high, sequential read and write access to large data sets on local storage (ローカルストレージ上の大規模データセットに対する高速・順次読み書きアクセスを必要とするストレージ集約的タスクに最適)
Use Cases (使用例):
- High frequency online transaction processing (OLTP) systems (高頻度オンライントランザクション処理システム)
- Relational & NoSQL databases (リレーショナル・NoSQLデータベース)
- Cache for in-memory databases (for example, Redis) (インメモリデータベース用キャッシュ(例:Redis))
- Data warehousing applications (データウェアハウジングアプリケーション)
- Distributed file systems (分散ファイルシステム)
EC2 Pricing Model
EC2インスタンスには複数の料金モデルがあり、ユースケースに応じて選択できます。
Elastic IP(EIP)
概要
- 静的なIPv4アドレスで、停止・再起動しても同じIPが使える。
- デフォルトでは、5個まで無料で割り当て可能(リージョンごと)
課金の仕組み
- インスタンスに関連付けられていないときのみ課金される。
- 全てのパブリックIPv4アドレス(Elastic IP含む)に対して課金対象
- 使用中でも未使用でも $0.005/時間
Reference