Section 6-10
Section 6: Amazon S3
6.1 Amazon S3 - Introduction
1. Amazon S3 - Buckets
- Amazon S3 allows people to store objects (files) in “buckets” (directories). Amazon S3 允许人们将对象(文件)存储在“桶”(目录)中。
- Buckets must have a globally unique name (across all regions all accounts). 桶必须有一个全球唯一的名字(跨所有地区所有账户)。
- Buckets are defined at the region level
- S3 looks like a global service but buckets are created in a region
- Naming convention
- No uppercase, No underscore
- 3-63 characters long
- Not an IP
- Must start with lowercase letter or number
- Must NOT start with the prefix xn--
- Must NOT end with the suffix -s3alias
2. Amazon S3 - Objects
- Objects (files) have a Key
- The key is the FULL path:
- s3://my-bucket/my_file.txt
- s3://my-bucket/my_folder1/another_folder/my_file.txt
- The key is composed of prefix + object name
- s3://my-bucket/my_folder1/another_folder/my_file.txt
- There’s no concept of “directories” within buckets (although the UI will trick you to think otherwise)
- Just keys with very long names that contain slashes (“/”)
- Object values are the content of the body:
- Max. Object Size is 5TB (5000GB)
- If uploading more than 5GB, must use “multi-part upload”
- Metadata (list of text key / value pairs – system or user metadata)
- Tags (Unicode key / value pair – up to 10) – useful for security / lifecycle
- Version ID (if versioning is enabled)
6.2 Amazon S3 – Security
- User-Based
- IAM Policies – which API calls should be allowed for a specific user from IAM
- Resource-Based
- Bucket Policies – bucket wide rules from the S3 console - allows cross account. 存储桶策略——来自 S3 控制台的存储桶范围规则——允许跨账户。
- Object Access Control List (ACL) – finer grain (can be disabled)
- Bucket Access Control List (ACL) – less common (can be disabled)
- Note: an IAM principal can access an S3 object if
- The user IAM permissions ALLOW it OR the resource policy ALLOWS it
- AND there’s no explicit DENY
- Encryption: encrypt objects in Amazon S3 using encryption keys

6.3 Amazon S3 – Static Website Hosting 静态网站托管
- S3 can host static websites and have them accessible on the Internet. S3 可以托管静态网站并在 Internet 上访问它们。
- The website URL will be (depending on the region)
http://bucket-name.s3-website-aws-region.amazonaws.comORhttp://bucket-name.s3-website.aws-region.amazonaws.com
- If you get a
403 Forbiddenerror, make sure the bucket policy allows public reads! 如果您收到 403 Forbidden 错误,请确保存储桶策略允许公开读取!
6.4 Amazon S3 - Versioning

- You can version your files in Amazon S3
- It is enabled at the bucket level
- Same key overwrite will change the “version”: 1, 2, 3….
- It is best practice to version your buckets
- Protect against unintended deletes (ability to restore a version). 防止意外删除(恢复版本的能力)。
- Easy roll back to previous version
- Notes:
- Any file that is not versioned prior to enabling versioning will have version “null”
- Suspending versioning does not delete the previous versions
6.5 Amazon S3 – Replication (CRR & SRR)
- Must enable Versioning in source and destination buckets
- Cross-Region Replication (CRR) 跨区域复制
- Same-Region Replication (SRR) 同区复制
- Buckets can be in different AWS accounts
- Copying is asynchronous
- Must give proper IAM permissions to S3
- Use cases:
- CRR – compliance, lower latency access, replication across accounts
- SRR – log aggregation, live replication between production and test accounts
6.6 S3 Storage Classes
Lifecycle Rules can be used to define when S3 objects should be transitioned to another storage class or when objects should be deleted after some time. 生命周期规则可用于定义何时应将 S3 对象转换为另一个存储类,或何时应在一段时间后删除对象。
1. S3 Durability and Availability
- Durability:
- High durability (99.999999999%, 11 9’s) of objects across multiple AZ. 跨多个 AZ 的对象的高持久性(99.999999999%,11 个 9)。
- If you store 10,000,000 objects with Amazon S3, you can on average expect to incur a loss of a single object once every 10,000 years
- Same for all storage classes
- Availability:
- Measures how readily available a service is
- Varies depending on storage class
- Example: S3 standard has 99.99% availability = not available 53 minutes a year

2. S3 Standard – General Purpose
- 99.99% Availability
- Used for frequently accessed data
- Low latency and high throughput
- Sustain 2 concurrent facility failures
- Use Cases: Big Data analytics, mobile & gaming applications, content distribution…
3. S3 Storage Classes – Infrequent Access
- For data that is less frequently accessed, but requires rapid access when needed. 适用于较少访问的数据,但在需要时需要快速访问。
- Lower cost than S3 Standard. 低于 S3 标准的成本。
- Amazon S3 Standard-Infrequent Access (S3 Standard-IA)
- 99.9% Availability
- Use cases: Disaster Recovery, backups
- Amazon S3 Standard-Infrequent Access allow you to store infrequently accessed data, with rapid access when needed, has a high durability, and is stored in several Availability Zones to avoid data loss in case of a disaster. It can be used to store data for disaster recovery, backups, etc. Amazon S3 Standard-Infrequent Access 允许您存储不常访问的数据,需要时快速访问,具有高持久性,并存储在多个可用区中,以避免在发生灾难时丢失数据。它可用于存储用于灾难恢复、备份等的数据。
- Amazon S3 One Zone-Infrequent Access (S3 One Zone-IA)
- High durability (99.999999999%) in a single AZ; data lost when AZ is destroyed
- 99.5% Availability
- Use Cases: Storing secondary backup copies of on-premise data, or data you can recreate
4. Amazon S3 Glacier Storage Classes
- Low-cost object storage meant for archiving / backup. 低成本对象存储,用于存档/备份。
- Pricing: price for storage + object retrieval cost. 定价:存储价格 + 对象检索成本。
- Amazon S3 Glacier Instant Retrieval 即时检索
- Millisecond retrieval, great for data accessed once a quarter
- Minimum storage duration of 90 days
- Amazon S3 Glacier Flexible Retrieval 灵活检索 (formerly Amazon S3 Glacier):
- Expedited (1 to 5 minutes), Standard (3 to 5 hours), Bulk (5 to 12 hours) – free
- Minimum storage duration of 90 days
- Amazon S3 Glacier Deep Archive – for long term storage:
- Standard (12 hours), Bulk (48 hours)
- Minimum storage duration of 180 days
- the most cost-effective option if you want to archive data and do not have a retrieval time requirement. You can retrieve data in 12 or 48 hours. 如果您想存档数据并且没有检索时间要求,则这是最具成本效益的选择。 您可以在 12 或 48 小时内检索数据。
5. S3 Intelligent-Tiering 智能分层
- Small monthly monitoring and auto-tiering fee. 小额每月监控和自动分层费用。
- Moves objects automatically between Access Tiers based on usage. 根据使用情况自动将对象移动到访问层。
- There are no retrieval charges in S3 Intelligent-Tiering. S3 智能分层中没有检索费用。
- Frequent Access tier (automatic): default tier
- Infrequent Access tier (automatic): objects not accessed for 30 days
- Archive Instant Access tier (automatic): objects not accessed for 90 days
- Archive Access tier (optional): configurable from 90 days to 700+ days
- Deep Archive Access tier (optional): config. from 180 days to 700+ days
6.7 AWS Snow Family

- Highly-secure, portable devices to collect and process data at the edge, and migrate data into and out of AWS. 高度安全的便携式设备,可在边缘收集和处理数据,并将数据迁入和迁出 AWS。


6.8 Amazon S3 – Summary
- Buckets vs Objects: global unique name, tied to a region
- S3 security: IAM policy, S3 Bucket Policy (public access), S3 Encryption
- S3 Websites: host a static website on Amazon S3
- S3 Versioning: multiple versions for files, prevent accidental deletes
- S3 Replication: same-region or cross-region, must enable versioning
- S3 Storage Classes: Standard, IA, 1Z-IA, Intelligent, Glacier (Instant, Flexible, Deep)
- Snow Family: import data onto S3 through a physical device, edge computing
- OpsHub: desktop application to manage Snow Family devices
- Storage Gateway: hybrid solution to extend on-premises storage to S3
Section 7: Databases & Analytics
- Storing data on disk (EFS, EBS, EC2 Instance Store, S3) can have its limits
- Sometimes, you want to store data in a database…
- You can structure the data
- You build indexes to efficiently query / search through the data
- You define relationships between your datasets
- Databases are optimized for a purpose and come with different features, shapes and constraints
7.1 NoSQL Databases

- NoSQL = non-SQL = non relational databases
- NoSQL databases are purpose built for specific data models and have flexible schemas for building modern applications.
- Benefits:
- Flexibility: easy to evolve data model
- Scalability: designed to scale-out by using distributed clusters
- High-performance: optimized for a specific data model
- Highly functional: types optimized for the data model
- Examples: Key-value, document, graph, in-memory, search databases
7.2 AWS RDS

- RDS stands for Relational Database Service
- It’s a managed DB service for DB use SQL as a query language.
- It allows you to create databases in the cloud that are managed by AWS
- Postgres
- MySQL
- MariaDB
- Oracle
- Microsoft SQL Server
- Aurora (AWS Proprietary database)
1. Advantage over using RDS versus deploying DB on EC2
- RDS is a managed service:
- Automated provisioning, OS patching
- Continuous backups and restore to specific timestamp (Point in Time Restore)!
- Monitoring dashboards
- Read replicas for improved read performance
- Multi AZ setup for DR (Disaster Recovery)
- Maintenance windows for upgrades
- Scaling capability (vertical and horizontal)
- Storage backed by EBS (gp2 or io1)
- BUT you can’t SSH into your instances
2. RDS Deployments: Read Replicas, Multi-AZ 只读副本,多可用区

- RDS Multi-AZ deployments’ main purpose is high availability, and RDS Read replicas’ main purpose is scalability. RDS 多可用区部署的主要目的是高可用性,而 RDS 只读副本的主要目的是可扩展性。
3. RDS Deployments: Multi-Region 多区域

- Multi-Region deployments’ main purpose is disaster recovery and local performance. 多区域部署的主要目的是灾难恢复和本地性能。
7.3 Amazon Aurora
- Aurora is a proprietary technology from AWS (not open sourced). Aurora 是 AWS 的专有技术(非开源)。
- PostgreSQL and MySQL are both supported as Aurora DB
- Aurora is “AWS cloud optimized” and claims 5x performance improvement over MySQL on RDS, over 3x the performance of Postgres on RDS
- Aurora storage automatically grows in increments of 10GB, up to 64 TB.
- Aurora costs more than RDS (20% more) – but is more efficient
- Not in the free tier
7.4 Amazon ElastiCache

- The same way RDS is to get managed Relational Databases…
- ElastiCache is to get managed Redis or Memcached. ElastiCache 是获取托管 Redis 或 Memcached 的方式。
- Caches are in-memory databases with high performance, low latency. 缓存是具有高性能,低延迟的内存数据库。
- Helps reduce load off databases for read intensive workloads
- AWS takes care of OS maintenance / patching, optimizations, setup, configuration, monitoring, failure recovery and backups
7.5 Amazon DynamoDB
- Fully Managed Highly available with replication across 3 AZ. 完全托管,高可用性,跨 3 个可用区复制。
- NoSQL database - not a relational database
- Scales to massive workloads, distributed “serverless” database. 扩展到大型工作负载,分布式“无服务器”数据库。
- Millions of requests per seconds, trillions of row, 100s of TB of storage. 每秒数百万次请求,万亿行,100 TB 的存储空间。
- Fast and consistent in performance
- Single-digit millisecond latency – low latency retrieval. 单位毫秒的延迟 - 低延迟检索。
- Integrated with IAM for security, authorization and administration
- Low cost and auto scaling capabilities
- Standard & Infrequent Access (IA) Table Class
1. DynamoDB – type of data

- DynamoDB is a key/value database
2. DynamoDB Accelerator - DAX
- Fully Managed in-memory cache for DynamoDB. 用于 DynamoDB 的完全托管内存缓存。
- 10x performance improvement– singledigit millisecond latency to microseconds latency – when accessing your DynamoDB tables
- Secure, highly scalable & highly available
- Difference with ElastiCache at the CCP level: DAX is only used for and is integrated with DynamoDB, while ElastiCache can be used for other databases. DAX 仅用于和与 DynamoDB 集成,而 ElastiCache 可用于其他数据库。
3. DynamoDB – Global Tables

- Make a DynamoDB table accessible with low latency in multiple-regions. 使 DynamoDB 表在多个区域中具有低延迟访问。
- Active-Active replication (read/write to any AWS Region).
7.6 Amazon Redshift
- Redshift is based on PostgreSQL, but it’s not used for OLTP. Redshift 基于 PostgreSQL,但不用于 OLTP。
- It’s OLAP – online analytical processing (analytics and data warehousing). 它是 OLAP - 在线分析处理(分析和数据仓库)。
- Load data once every hour, not every second
- 10x better performance than other data warehouses, scale to PBs of data
- Columnar storage of data (instead of row based). 列存储数据(而不是基于行的)。
- Massively Parallel Query Execution (MPP), highly available. 大规模并行查询执行(MPP),高可用性。
- Pay as you go based on the instances provisioned
- Has a SQL interface for performing the queries. 有 SQL 接口用于执行查询。
- BI tools such as AWS Quicksight or Tableau integrate with it
7.7 Amazon EMR Elastic MapReduce
- EMR stands for “Elastic MapReduce”. EMR 代表“弹性 MapReduce”。
- EMR helps creating Hadoop clusters (Big Data) to analyze and process vast amount of data. EMR 帮助创建 Hadoop 集群(大数据)来分析和处理大量数据。
- The clusters can be made of hundreds of EC2 instances
- Also supports Apache Spark, HBase, Presto, Flink…
- EMR takes care of all the provisioning and configuration
- Auto-scaling and integrated with Spot instances
- Use cases: data processing, machine learning, web indexing, big data…
7.8 Amazon Athena

- Serverless query service to analyze data stored in Amazon S3. 用于分析存储在 Amazon S3 中的数据的无服务器查询服务。
- Uses standard SQL language to query the files
- Supports CSV, JSON, ORC, Avro, and Parquet (built on Presto)
- Pricing: $5.00 per TB of data scanned
- Use compressed or columnar data for cost-savings (less scan)
- Use cases: Business intelligence / analytics / reporting, analyze &query VPC Flow Logs, ELB Logs, CloudTrail trails, etc
- Exam Tip: analyze data in S3 using serverless SQL, use Athena
7.9 Amazon QuickSight

- Serverless machine learning-powered business intelligence service to create interactive dashboards. 用于创建交互式仪表板的无服务器机器学习驱动的商业智能服务。
- Fast, automatically scalable, embeddable, with per-session pricing
- Use cases:
- Business analytics
- Building visualizations
- Perform ad-hoc analysis
- Get business insights using data
- Integrated with RDS, Aurora, Athena, Redshift, S3…
7.10 Amazon DocumentDB
- Aurora is an “AWS-implementation” of PostgreSQL / MySQL …
- DocumentDB is the same for MongoDB (which is a NoSQL database). DocumentDB 是 MongoDB 的同一实现(MongoDB 是 NoSQL 数据库)。
- MongoDB is used to store, query, and index JSON data
- Similar “deployment concepts” as Aurora
- Fully Managed, highly available with replication across 3 AZ
- DocumentDB storage automatically grows in increments of 10GB, up to 64 TB.
- Automatically scales to workloads with millions of requests per seconds
7.11 Amazon Neptune
- Fully managed graph database. 完全托管的图数据库。
- A popular graph dataset would be a social network
- Users have friends
- Posts have comments
- Comments have likes from users
- Users share and like posts…
- Highly available across 3 AZ, with up to 15 read replicas
- Build and run applications working with highly connected datasets – optimized for these complex and hard queries. 构建和运行使用高度连接的数据集的应用程序 - 优化这些复杂和困难的查询。
- Can store up to billions of relations and query the graph with milliseconds latency. 可以存储数十亿个关系,并以毫秒延迟查询图形。
- Highly available with replications across multiple AZs
- Great for knowledge graphs (Wikipedia), fraud detection, recommendation engines, social networking. 适用于知识图(维基百科),欺诈检测,推荐引擎,社交网络。
7.12 Amazon Quantum Ledger Database(QLDB)

- QLDB stands for ”Quantum Ledger Database”. QLDB 代表“量子分类帐数据库”。
- A ledger is a book recording financial transactions. 分类帐是一本记录财务交易的书。
- Fully Managed, Serverless, High available, Replication across 3 AZ
- Used to review history of all the changes made to your application data over time. 用于查看随时间推移对应用程序数据所做的所有更改的历史记录。
- Immutable system: no entry can be removed or modified, cryptographically verifiable. 不可变系统:无法删除或修改任何条目,可加密验证。
- 2-3x better performance than common ledger blockchain frameworks, manipulate data using SQL
- Difference with Amazon Managed Blockchain: no decentralization component, in accordance with financial regulation rules. 与 Amazon Managed Blockchain 的区别:没有去中心化组件,符合金融监管规则。
7.13 Amazon Managed Blockchain
- Blockchain makes it possible to build applications where multiple parties can execute transactions without the need for a trusted, central authority. 区块链使得可以构建应用程序,多个方可以执行交易,而无需信任的中央机构。
- Amazon Managed Blockchain is a managed service to:
- Join public blockchain networks. 加入公共区块链网络。
- Or create your own scalable private network. 或创建自己的可扩展的私有网络。
- Compatible with the frameworks Hyperledger Fabric & Ethereum. 与 Hyperledger Fabric 和以太坊框架兼容。
7.14 Amazon Glue

- Managed extract, transform, and load (ETL) service. 托管的提取,转换和加载(ETL)服务。
- Useful to prepare and transform data for analytics
- Fully serverless service
- Glue Data Catalog: catalog of datasets
- The AWS Glue Data Catalog is a central repository to store structural and operational metadata for all your data assets. For a given data set, you can store its table definition, physical location, add business relevant attributes, as well as track how this data has changed over time. AWS Glue Data Catalog 是存储所有数据资产的结构和操作元数据的中央存储库。 对于给定的数据集,您可以存储其表定义,物理位置,添加业务相关属性,以及跟踪此数据随时间而变化的方式。
- can be used by Athena, Redshift, EMR
7.15 DMS – Database Migration Service 数据库迁移服务

- Quickly and securely migrate databases to AWS, resilient, self healing. 快速安全地将数据库迁移到 AWS,弹性,自我愈合。
- The source database remains available during the migration. 迁移期间源数据库仍然可用。
- Supports:
• Homogeneous migrations: ex Oracle to Oracle. 同质迁移:例如 Oracle 到 Oracle。
- Heterogeneous migrations: ex Microsoft SQL Server to Aurora. 异质迁移:例如 Microsoft SQL Server 到 Aurora。
7.16 Databases & Analytics Summary in AWS
- Relational Databases - OLTP: RDS & Aurora (SQL)
- Differences between Multi-AZ, Read Replicas, Multi-Region. 多可用区,读取副本,多区域之间的区别。
- In-memory Database: ElastiCache
- Key/Value Database: DynamoDB (serverless) & DAX (cache for DynamoDB)
- Warehouse - OLAP: Redshift (SQL)
- Hadoop Cluster: EMR
- Athena: query data on Amazon S3 (serverless & SQL)
- QuickSight: dashboards on your data (serverless)
- DocumentDB: “Aurora for MongoDB” (JSON – NoSQL database)
- Amazon QLDB: Financial Transactions Ledger (immutable journal, cryptographically verifiable). 金融交易分类帐(不可变的日志,可加密验证)。
- Amazon Managed Blockchain: managed Hyperledger Fabric & Ethereum blockchains. 管理 Hyperledger Fabric 和以太坊区块链。
- Glue: Managed ETL (Extract Transform Load) and Data Catalog service. 托管 ETL(提取转换负载)和数据目录服务。
- Database Migration: DMS
- Neptune: graph database
Section 8: Other Compute Services: ECS, Lambda, Batch, Lightsail
8.1 Amazon Elastic Container Service (ECS) 弹性容器服务
- ECS = Elastic Container Service
- Launch Docker containers on AWS
- You must provision & maintain the infrastructure (the EC2 instances). 你必须配置和维护基础架构(EC2 实例)。
- AWS takes care of starting / stopping containers
- Has integrations with the Application Load Balancer
8.2 Fargate
- Launch Docker containers on AWS
- You do not provision the infrastructure (no EC2 instances to manage)– simpler!. 你不需要配置基础架构(不需要管理 EC2 实例)——更简单!
- Serverless offering
- AWS just runs containers for you based on the CPU / RAM you need
8.3 ECR – Elastic Container Registry 弹性容器注册表

- Elastic Container Registry
- Private Docker Registry on AWS
- This is where you store your Docker images so they can be run by ECS or Fargate. 这是你存储 Docker 镜像的地方,以便 ECS 或 Fargate 运行它们。
8.4 What’s serverless?
- Serverless is a new paradigm in which the developers don’t have to manage servers anymore… 服务器即服务是一种新的范例,开发人员不再需要管理服务器。
- They just deploy code
- They just deploy… functions !
- Initially... Serverless == FaaS (Function as a Service)
- Serverless was pioneered by AWS Lambda but now also includes anything that’s managed: “databases, messaging, storage, etc.”
- Serverless does not mean there are no servers… it means you just don’t manage / provision / see them. 服务器即服务并不意味着没有服务器……这意味着你只是不管理/配置/看到它们。
8.5 Amazon Lambda

1. Benefits of AWS Lambda
- Easy Pricing:
- Pay per request and compute time
- Free tier of 1,000,000 AWS Lambda requests and 400,000 GBs of compute time
- Integrated with the whole AWS suite of services
- Event-Driven: functions get invoked by AWS when needed
- Integrated with many programming languages
- Easy monitoring through AWS CloudWatch
- Easy to get more resources per functions (up to 10GB of RAM!)
- Increasing RAM will also improve CPU and network!

2. AWS Lambda Pricing
- Pay per calls:
- First 1,000,000 requests are free
- 0.0000002 per request)
- Pay per duration: (in increment of 1 ms)
- 400,000 GB-seconds of compute time per month for FREE
- == 400,000 seconds if function is 1GB RAM
- == 3,200,000 seconds if function is 128 MB RAM
- After that $1.00 for 600,000 GB-seconds
- It is usually very cheap to run AWS Lambda so it’s very popular
8.6 AWS API Gateway

- Example: building a serverless API
- Fully managed service for developers to easily create, publish, maintain, monitor, and secure APIs. 为开发人员提供的完全托管服务,可轻松创建,发布,维护,监视和保护 API。
- Serverless and scalable
- Supports RESTful APIs and WebSocket APIs
- Support for security, user authentication, API throttling, API keys, monitoring...
8.7 AWS Batch

- Fully managed batch processing at any scale. 任何规模的批处理处理。
- Efficiently run 100,000s of computing batch jobs on AWS
- A “batch” job is a job with a start and an end (opposed to continuous)
- Batch will dynamically launch EC2 instances or Spot Instances
- AWS Batch provisions the right amount of compute / memory
- You submit or schedule batch jobs and AWS Batch does the rest!
- Batch jobs are defined as Docker images and run on ECS. 批处理作业被定义为 Docker 镜像,并在 ECS 上运行。
- Helpful for cost optimizations and focusing less on the infrastructure
Batch vs Lambda
- Lambda:
- Time limit
- Limited runtimes
- Limited temporary disk space
- Serverless
- Batch:
- No time limit
- Any runtime as long as it’s packaged as a Docker image
- Rely on EBS / instance store for disk space
- Relies on EC2 (can be managed by AWS)