Bỏ qua tới nội dung
CloudDojo
Phần 6/6 · 11 phút

Vòng đời instance: instance store, địa chỉ IP và những gì còn lại

0/8
Từ khóa của phần nàyChọn một từ để xem nghĩa trước khi đọc

Khi một EC2 instance được stop, reboot hoặc terminate, không phải mọi thứ gắn với nó đều được giữ lại; cần biết rõ dữ liệu và cấu hình nào còn, cái nào mất.

EC2 instance chuyển mã video của MFTECH cần đọc ghi khoảng 10 TB tệp tạm với hiệu năng I/O cao nhất. Instance store là ổ đĩa gắn vật lý vào host của instance; các instance storage optimized được tối ưu để cung cấp hàng chục nghìn IOPS ngẫu nhiên với độ trễ thấp. Instance store không tính phí riêng (đã gồm trong giá instance). Đổi lại, dữ liệu chỉ tồn tại trong vòng đời instance, nên kết quả cuối cùng phải được đẩy lên S3 để lưu trữ bền vững và S3 Glacier để lưu trữ dài hạn.

Instance còn có ba loại địa chỉ IPv4. Private IP dùng trong VPC, thường thuộc dải RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), được giữ qua stop/start. Public IP tự gán lấy từ pool của Amazon, không thuộc account, được release khi stop, hibernate hoặc terminate. Elastic IP là địa chỉ public tĩnh thuộc account cho tới khi release, có thể remap sang instance khác để che sự cố. Chọn một thao tác để xem thành phần nào còn lại:

Instance shop-transcode chuyển mã video sản phẩm. Tệp đang xử lý nằm trên instance store; đối tác CDN đưa địa chỉ public của instance vào allow list. Chọn một thao tác để xem thành phần nào còn lại.

Trạng thái: running
Instance IDBAN ĐẦUi-0a1b2c3d
Private IPv4BAN ĐẦU10.0.1.25
Public IPv4 (tự gán)BAN ĐẦU54.169.20.11
Elastic IPBAN ĐẦUChưa gắn
EBS root volumeBAN ĐẦUvol-root, 30 GiB
Instance store (tệp video tạm)BAN ĐẦU120 GB tệp đang xử lý
RAM (trạng thái ứng dụng)BAN ĐẦUCache đã nạp

Chọn một thao tác ở trên. Bật hoặc tắt Elastic IP để so sánh địa chỉ public tự gán với Elastic IP.

Theo tài liệu AWS: AWS tính phí mọi địa chỉ public IPv4, kể cả Elastic IP chưa gắn; mỗi Region mặc định có quota 5 Elastic IP.

Một số điểm thường bị nhầm lẫn khi thiết kế:

  • Elastic IP không thay thế kiến trúc sẵn sàng cao. Remap Elastic IP che được sự cố của một instance, còn phân phối traffic và thay thế instance lỗi là việc của load balancer và Auto Scaling group. Instance đứng sau Application Load Balancer không cần public IP hay Elastic IP: target đăng ký bằng instance ID nhận traffic qua primary private IP.
  • Elastic IP chỉ là địa chỉ. Để truy cập instance từ Internet (kể cả ping), route table của subnet vẫn phải có route tới internet gateway và security group phải cho phép traffic tương ứng (ping dùng ICMP).
  • Điều kiện aws:SourceIp trong IAM policy so khớp IP của bên gọi API, không phải địa chỉ của instance.
  • Instance store làm root volume chỉ có với Amazon S3-backed AMI trên một số instance type thế hệ cũ (C1, C3, D2, I2, M1, M2, M3, R3, X1); AWS coi loại AMI này là end of life. Instance như vậy không stop được và không khôi phục được sau khi lỗi hoặc terminate. EBS volume st1 và sc1 không dùng làm root volume.
Ghi nhớ:
  • Instance store: hiệu năng I/O cao nhất cho dữ liệu tạm; giữ dữ liệu khi reboot; mất khi stop, hibernate, terminate; chỉ chỉ định khi launch; không tách sang instance khác; dữ liệu không nằm trong AMI tạo từ instance.
  • Public IP tự gán đổi sau stop/start; Elastic IP giữ nguyên và bị tính phí kể cả khi chưa gắn.
  • Recover giữ nguyên instance ID và mọi địa chỉ IP; terminate là vĩnh viễn, không thể recover.
Part 6/6 · 11 phút

Instance lifecycle: instance store, IP addresses and what remains

0/8
Từ khóa của phần nàyChọn một từ để xem nghĩa trước khi đọc

When an EC2 instance is stopped, rebooted or terminated, not everything attached to it is kept; you need to know which data and settings survive and which are lost.

MFTECH’s video transcoding EC2 instance reads and writes about 10 TB of temporary files and needs the highest possible I/O performance. Instance store is disk physically attached to the instance’s host computer; storage optimized instances are optimized to deliver tens of thousands of low-latency, random IOPS. Instance store has no separate charge (it is included in the instance price). In exchange, the data exists only for the lifetime of the instance, so the final output must be pushed to S3 for durable storage and to S3 Glacier for archival.

An instance also has three kinds of IPv4 address. A private IP is used inside the VPC, typically from the RFC 1918 ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), and is kept across stop/start. An auto-assigned public IP comes from Amazon’s pool, is not associated with your account, and is released on stop, hibernate or terminate. An Elastic IP address is a static public address that belongs to your account until you release it and can be remapped to another instance to mask a failure. Pick an action to see what remains:

Instance shop-transcode chuyển mã video sản phẩm. Tệp đang xử lý nằm trên instance store; đối tác CDN đưa địa chỉ public của instance vào allow list. Chọn một thao tác để xem thành phần nào còn lại.

Trạng thái: running
Instance IDBAN ĐẦUi-0a1b2c3d
Private IPv4BAN ĐẦU10.0.1.25
Public IPv4 (tự gán)BAN ĐẦU54.169.20.11
Elastic IPBAN ĐẦUChưa gắn
EBS root volumeBAN ĐẦUvol-root, 30 GiB
Instance store (tệp video tạm)BAN ĐẦU120 GB tệp đang xử lý
RAM (trạng thái ứng dụng)BAN ĐẦUCache đã nạp

Chọn một thao tác ở trên. Bật hoặc tắt Elastic IP để so sánh địa chỉ public tự gán với Elastic IP.

Theo tài liệu AWS: AWS tính phí mọi địa chỉ public IPv4, kể cả Elastic IP chưa gắn; mỗi Region mặc định có quota 5 Elastic IP.

Common design mix-ups:

  • An Elastic IP address does not replace a highly available architecture. Remapping an Elastic IP masks the failure of one instance, but distributing traffic and replacing failed instances is the job of a load balancer and an Auto Scaling group. Instances behind an Application Load Balancer do not need a public or Elastic IP: targets registered by instance ID receive traffic on their primary private IP.
  • An Elastic IP is only an address. To reach the instance from the internet (ping included), the subnet’s route table still needs a route to an internet gateway, and the security group must allow the traffic (ping uses ICMP).
  • The aws:SourceIp condition in an IAM policy compares the IP of the API caller, not the address of the instance.
  • Instance store as a root volume exists only with Amazon S3-backed AMIs on some older instance types (C1, C3, D2, I2, M1, M2, M3, R3, X1); AWS considers this AMI type end of life. Such instances cannot be stopped and cannot be restored after they fail or terminate. EBS st1 and sc1 volumes cannot be root volumes.
Ghi nhớ:
  • Instance store: the highest I/O for temporary data; data survives a reboot; lost on stop, hibernate or terminate; specified only at launch; cannot be moved to another instance; not preserved in an AMI created from the instance.
  • An auto-assigned public IP changes after stop/start; an Elastic IP address stays and is charged even when unassociated.
  • Recovery keeps the instance ID and every IP address; termination is permanent and cannot be recovered.

Kiểm tra nhanh

Trả lời để ghi nhận đã đọc phần này. Câu trả lời sai sẽ được nhắc ôn lại vào những ngày sau.

Một instance có public IP tự gán và dữ liệu tạm trên instance store được stop rồi start lại. Điều gì xảy ra?
Các EC2 instance của MFTECH nằm sau Application Load Balancer, được đăng ký theo instance ID. Mỗi instance có cần public IP hoặc Elastic IP không?

Đã trả lời 0/2 câu