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

Truy cập dữ liệu S3 qua giao diện file

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

Một số ứng dụng cũ chỉ biết đọc ghi file trong thư mục, trong khi dữ liệu lại nằm trên S3; cần một lớp chuyển đổi để ứng dụng dùng được dữ liệu đó mà không phải viết lại.

Team dữ liệu MFTECH lưu toàn bộ ảnh sản phẩm và dữ liệu huấn luyện mô hình gợi ý trên S3. Một số ứng dụng cũ chỉ đọc ghi tệp, không gọi S3 API. Mountpoint for Amazon S3 là file client mã nguồn mở, mount bucket thành thư mục cục bộ trên Linux và chuyển thao tác tệp (open, read) thành lời gọi S3 API. Mountpoint không phải file system POSIX đầy đủ: chạy thử các thao tác thường gặp trên Mountpoint và trên EFS:

Mount
Ứng dụngEC2 Linux · /mnt/shopMountpoint clientthao tác tệp → S3 APIS3 bucketobject · throughput co giãn

Chọn nơi mount, sau đó chạy lần lượt từng thao tác. Lặp lại với Amazon EFS để so sánh.

Mountpoint phù hợp với ứng dụng đọc nhiều trên quy mô lớn: data lake, huấn luyện machine learning, render ảnh, ETL. Mountpoint đọc được object ở mọi storage class trừ S3 Glacier Flexible Retrieval, S3 Glacier Deep Archive và hai tier Archive của S3 Intelligent-Tiering. Khi đọc lặp lại cùng một dữ liệu, có thể bật cache cục bộ (instance storage hoặc EBS) hoặc shared cache trên S3 Express One Zone. Với workload cần POSIX đầy đủ trên dữ liệu S3, AWS khuyến nghị FSx for Lustre liên kết với bucket. Chọn file interface cho từng tình huống:

Giải pháp đề xuấtMountpoint for Amazon S3

Mount bucket thành thư mục, đọc với throughput co giãn của S3, không phải sao chép dữ liệu. Job chỉ đọc và tạo tệp kết quả mới nên không gặp giới hạn của Mountpoint.

Amazon S3 Files là file system dùng chung, xây dựng trên Amazon EFS, liên kết với một bucket hoặc một prefix: ứng dụng đọc ghi tệp với đầy đủ ngữ nghĩa file system, còn S3 Files tự đồng bộ thay đổi giữa file system và bucket. S3 file system mount được trên EC2, Lambda, và được khai báo làm volume (s3filesVolumeConfiguration) cho ECS task trên Fargate, ECS Managed Instances và EC2; bắt buộc có task IAM role và mã hoá khi truyền. Tài liệu ôn tập cũ khẳng định “S3 không mount được như file system”; với S3 Files, dữ liệu S3 mount được qua một tài nguyên file system riêng, nhưng bucket vẫn không phải loại volume để gắn thẳng vào task. Với microservice cần thư mục POSIX dùng chung giữa nhiều AZ mà dữ liệu không cần nằm trong S3, EFS vẫn là phương án trực tiếp nhất.

Ghi nhớ:
  • Fargate task: volume EFS, EBS, bind mount (ephemeral storage) hoặc S3 Files; không mount bucket bằng script.
  • Mountpoint for Amazon S3: file client cho Linux, đọc tệp lớn và tạo tệp mới với throughput của S3; không sửa tệp đã có, không xoá thư mục, không hỗ trợ symbolic link và file locking.
  • Truy cập S3 dạng file từ on-premises data center với local cache: S3 File Gateway.
  • Cần POSIX đầy đủ: EFS, hoặc FSx for Lustre liên kết S3 cho HPC.
Part 5/5 · 10 phút

Accessing S3 data through a file interface

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

Some older applications can only read and write files in folders while the data lives in S3; they need a translation layer to use it without being rewritten.

The MFTECH data team keeps all product images and the recommendation model’s training data in S3. Some older applications only read and write files and cannot call the S3 API. Mountpoint for Amazon S3 is an open source file client that mounts a bucket as a local directory on Linux and translates file operations (open, read) into S3 API calls. Mountpoint is not a fully POSIX file system: try common operations on Mountpoint and on EFS:

Mount
Ứng dụngEC2 Linux · /mnt/shopMountpoint clientthao tác tệp → S3 APIS3 bucketobject · throughput co giãn

Chọn nơi mount, sau đó chạy lần lượt từng thao tác. Lặp lại với Amazon EFS để so sánh.

Mountpoint suits large-scale, read-heavy applications: data lakes, machine learning training, image rendering, ETL. It can read objects in every storage class except S3 Glacier Flexible Retrieval, S3 Glacier Deep Archive and the two Archive tiers of S3 Intelligent-Tiering. For repeated reads of the same data you can opt in to a local cache (instance storage or EBS) or a shared cache in S3 Express One Zone. For workloads that need full POSIX support on S3 data, AWS recommends FSx for Lustre linked to the bucket. Choose a file interface for each situation:

Giải pháp đề xuấtMountpoint for Amazon S3

Mount the bucket as a directory and read at S3's elastic throughput, with no data copy. The job only reads and creates new result files, so Mountpoint's limits do not apply.

Amazon S3 Files is a shared file system, built using Amazon EFS, linked to a bucket or a prefix: applications read and write files with full file system semantics, and S3 Files synchronizes changes between the file system and the bucket. An S3 file system can be mounted on EC2 and Lambda, and declared as a volume (s3filesVolumeConfiguration) for ECS tasks on Fargate, ECS Managed Instances and EC2; a task IAM role and encryption in transit are mandatory. Older study material states that “S3 cannot be mounted as a file system”; with S3 Files, S3 data can be mounted through a separate file system resource, but the bucket itself is still not a volume type you attach to a task. For microservices that need a shared POSIX directory across AZs and whose data does not need to live in S3, EFS remains the most direct option.

Ghi nhớ:
  • Fargate tasks: EFS, EBS, bind mount (ephemeral storage) or S3 Files volumes; no script that mounts a bucket.
  • Mountpoint for Amazon S3: a Linux file client that reads large files and creates new files at S3 throughput; it cannot modify existing files or delete directories, and does not support symbolic links or file locking.
  • File access to S3 from the on-premises data center with a local cache: S3 File Gateway.
  • Full POSIX: EFS, or FSx for Lustre linked to S3 for HPC.

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.

Job huấn luyện trên EC2 Linux đọc tuần tự hàng TB dữ liệu trên S3, ứng dụng chỉ biết đọc tệp và chỉ tạo tệp kết quả mới. Chọn gì?
Render server tại data center on-premises cần truy cập thường xuyên, độ trễ thấp tới tệp media lớn trên S3. Chọn gì?

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