4-14学习记录
最佳实践部分看起来有点吃力
Security
加密方式:
- AWS owned CMK
由dynamoDB进行管理 - AWS managed CMK
由aws进行管理 - Customer managed CMK
由用户进行管理
CLI创建方式(默认开启AWS owned CMK)
- with the AWS managed CMK
--sse-specification Enabled=true,SSEType=KMS
- with a customer managed CMK
--sse-specification Enabled=true,SSEType=KMS,KMSMasterKeyId=abcd1234-abcd-1234-a123-ab1234a1b234
CLI更新加密方式
aws dynamodb update-table \
--table-name Music \
--sse-specification Enabled=true
安全连接方式
- AWS Site-to-Site VPN connection
- AWS Direct Connect connection
权限管理
- AWS account root user
- IAM user
- IAM role
Logging and Monitoring
Monitoring Tools
自动监控工具
- Amazon CloudWatch Alarms
- Amazon CloudWatch Logs
- Amazon CloudWatch Events
- AWS CloudTrail Log Monitoring
Best Practices
NoSQL Design
需要先了解业务问题和应用程序使用案例
尽量使用更少的表
需要了解的特性
- Data size
了解每次存储和请求的数据量 - Data shape
- Data velocity
整理数据
- Keep related data together
将相关数据集中放置到一个位置来优化性能 - Use sort order
使用sort key进行管理 - Distribute queries
queries不能设计得过于集中在数据库的一部分上面 - Use global secondary indexes
创建索引来查询数据
Partition Key Design
Uploading Data Efficiently
同时在多个partition上面传数据,即此序列中的每次上传都使用不同的partition key。
Sort Key Design
Secondary Indexes
General Guidelines
- Global secondary index
没有大小限制且具有其自己的读取和写入活动的预配置吞吐量设置 - Local secondary index
与base table共享吞吐量设置,最多索引的数据不超过10GB
减少index的数量
Sparse Indexes
如果index并未出现在每个item中,则说这个index是sparse(稀疏的)
例如给未发货的订单一个 isOpen的attribute,利用CustomerId和isOpen会比扫描整个table更快。
总结:给特定的item属性可以使用index快速锁定这些属性
Aggregation
聚合数据方便统计数据特征
GSI Overloading
不同item中的同一attribute还可以包含完全不同类型的信息。
GSI Sharding
根据特定attribute来分类达到切片的目的
Large Items
压缩算法 (如 GZIP 或 LZO) 将生成之后可存储在 Binary 属性类型中的二进制输出。
还可以使用 Amazon S3 存储无法放入 DynamoDB 项目的大型属性值。可以将它们作为对象存储在 Amazon S3 中,然后将对象标识符存储在 DynamoDB 项目中。
Time Series Data
可以每个时间段为每个应用程序使用一个table
一种处理方式是将当前日期和时间构建成primary key
Many-to-Many Relationships
比较复杂 暂时搁置
Querying and Scanning
scan的效率非常低,建议使用query
使用并行scan