

# 資料管理
<a name="a-data-management"></a>

**Topics**
+ [PERF 3. 如何在工作負載中儲存、管理和存取資料？](perf-03.md)

# PERF 3. 如何在工作負載中儲存、管理和存取資料？
<a name="perf-03"></a>

 特定系統的最佳資料管理解決方案會根據資料類型 (區塊、檔案或物件)、存取模式 (隨機或循序)、所需輸送量、存取頻率 (線上、離線、封存)、更新頻率 (WORM、動態) 及可用性和耐用性限制而有所不同。Well-Architected 工作負載會使用專用資料存放區，這些存放區採用不同的功能以提升效能。

**Topics**
+ [PERF03-BP01 使用最能滿足資料存取和儲存需求的專用資料存放區](perf_data_use_purpose_built_data_store.md)
+ [PERF03-BP02 評估資料存放區的可用組態選項](perf_data_evaluate_configuration_options_data_store.md)
+ [PERF03-BP03 收集並記錄資料存放區效能指標](perf_data_collect_record_data_store_performance_metrics.md)
+ [PERF03-BP04 實作策略以提高資料存放區中的查詢效能](perf_data_implement_strategies_to_improve_query_performance.md)
+ [PERF03-BP05 實作利用快取的資料存取模式](perf_data_access_patterns_caching.md)

# PERF03-BP01 使用最能滿足資料存取和儲存需求的專用資料存放區
<a name="perf_data_use_purpose_built_data_store"></a>

 了解資料特性 (例如可共用、大小、快取大小、存取模式、延遲、輸送量和資料的持續性)，為工作負載選擇適合的專用資料存放區 (儲存或資料庫)。

 **常見的反模式：**
+  由於具備某種特定類型資料庫解決方案的內部經驗和知識，您堅持使用某個資料存取區。
+  您假設所有工作負載都有類似的資料儲存和存取需求。
+  您未實作資料目錄以清查資料資產。

 **建立此最佳實務的優勢：**了解資料特性和需求，可協助您判斷能滿足工作負載需求的最有效率且效能最高的儲存技術。

 **未建立此最佳實務時的曝險等級：**高 

## 實作指引
<a name="implementation-guidance"></a>

 選取和實作資料儲存時，請確定查詢、擴展和儲存特性支援工作負載資料需求。AWS 提供多種資料儲存和資料庫技術，包括區塊儲存、物件儲存、串流儲存、檔案系統、關聯式、鍵值、文件、記憶體內、圖形、時間序列和總帳資料庫。每個資料管理解決方案都有為您提供的選項和組態，以支援您的使用案例和資料模型。透過了解資料特性和需求，您可以擺脫整體式儲存技術和限制性、一刀切的方法，以專注於適當地管理資料。

### 實作步驟
<a name="implementation-steps"></a>
+  對您工作負載現有的各種資料類型執行清查。
+  了解並記錄資料特性和需求，包括：
  +  資料類型 (非結構化、半結構化、關聯式) 
  +  資料量與成長 
  +  資料耐用性：持續性、暫時性、臨時 
  +  ACID (原子性、一致性、隔離性、耐久性) 要求 
  +  資料存取模式 (大量讀取或大量寫入) 
  +  延遲 
  +  輸送量 
  +  IOPS (每秒輸入/輸出操作次數) 
  +  資料保留期間 
+  了解 AWS 上可用於工作負載的不同資料存放區 ([儲存體](https://docs.aws.amazon.com/whitepapers/latest/aws-overview/storage-services.html)和[資料庫](https://docs.aws.amazon.com/whitepapers/latest/aws-overview/database.html)服務)，這些資料存放區可以滿足資料特性，詳情請參閱 [PERF01-BP01 了解並理解可用的雲端服務和功能](perf_architecture_understand_cloud_services_and_features.md)。AWS 儲存技術及其重要特性的一些範例包含：    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/wellarchitected/latest/framework/perf_data_use_purpose_built_data_store.html)
+  如果您要建置資料平台，請利用 AWS 上的[現代資料架構](https://aws.amazon.com/big-data/datalakes-and-analytics/modern-data-architecture/)來整合資料湖、資料倉儲和專用資料存放區。
+  為工作負載選擇資料存放區時，需要考慮的關鍵問題如下：    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/wellarchitected/latest/framework/perf_data_use_purpose_built_data_store.html)
+  在非生產環境中執行實驗和基準測試，以確定哪個資料存放區最能滿足您的工作負載需求。

## 資源
<a name="resources"></a>

 **相關文件：**
+  [Amazon EBS 磁碟區類型](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html) 
+  [Amazon EC2 儲存](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Storage.html) 
+  [Amazon EFS：Amazon EFS 效能](https://docs.aws.amazon.com/efs/latest/ug/performance.html) 
+  [Amazon FSx for Lustre 效能](https://docs.aws.amazon.com/fsx/latest/LustreGuide/performance.html) 
+  [Amazon FSx for Windows File Server 效能](https://docs.aws.amazon.com/fsx/latest/WindowsGuide/performance.html) 
+  [Amazon Glacier：Amazon Glacier 文件](https://docs.aws.amazon.com/amazonglacier/latest/dev/introduction.html) 
+  [Amazon S3：請求率和效能考量](https://docs.aws.amazon.com/AmazonS3/latest/dev/request-rate-perf-considerations.html) 
+  [AWS 的雲端儲存](https://aws.amazon.com/products/storage/) 
+  [Amazon EBS I/O 特性](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-io-characteristics.html) 
+  [ 的雲端資料庫AWS](https://aws.amazon.com/products/databases/?ref=wellarchitected) 
+  [AWS 資料庫快取](https://aws.amazon.com/caching/database-caching/?ref=wellarchitected) 
+  [DynamoDB Accelerator](https://aws.amazon.com/dynamodb/dax/?ref=wellarchitected) 
+  [Amazon Aurora 最佳實務](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Aurora.BestPractices.html?ref=wellarchitected) 
+  [Amazon Redshift 效能](https://docs.aws.amazon.com/redshift/latest/dg/c_challenges_achieving_high_performance_queries.html?ref=wellarchitected) 
+  [Amazon Athena 10 大效能秘訣](https://aws.amazon.com/blogs/big-data/top-10-performance-tuning-tips-for-amazon-athena/?ref=wellarchitected) 
+  [Amazon Redshift Spectrum 最佳實務](https://aws.amazon.com/blogs/big-data/10-best-practices-for-amazon-redshift-spectrum/?ref=wellarchitected) 
+  [Amazon DynamoDB 最佳實務](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/BestPractices.html?ref=wellarchitected) 
+  [在 Amazon EC2 和 Amazon RDS 之間進行選擇](https://docs.aws.amazon.com/prescriptive-guidance/latest/migration-sql-server/comparison.html) 
+ [實作 Amazon ElastiCache 的最佳實務](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/BestPractices.html)

 **相關影片：**
+  [AWS re:Invent 2023：提高 Amazon Elastic Block Store 效率並更具成本效益](https://www.youtube.com/watch?v=7-CB02rqiuw) 
+  [AWS re:Invent 2023：使用 Amazon Simple Storage Service 最佳化儲存價格和效能](https://www.youtube.com/watch?v=RxgYNrXPOLw) 
+  [AWS re:Invent 2023：在 Amazon Simple Storage Service 上建置和最佳化資料湖](https://www.youtube.com/watch?v=mpQa_Zm1xW8) 
+  [AWS re:Invent 2022：在 AWS 上建置現代資料架構](https://www.youtube.com/watch?v=Uk2CqEt5f0o) 
+  [AWS re:Invent 2022：在 AWS 上建置資料網格架構](https://www.youtube.com/watch?v=nGRvlobeM_U) 
+  [AWS re:Invent 2023：深入探索 Amazon Aurora 及其創新](https://www.youtube.com/watch?v=je6GCOZ22lI) 
+  [AWS re:Invent 2023：使用 Amazon DynamoDB 的進階資料建模](https://www.youtube.com/watch?v=PVUofrFiS_A) 
+ [AWS re:Invent 2022：使用專用資料庫將應用程式現代化](https://www.youtube.com/watch?v=V-DiplATdi0)
+ [深入探討 Amazon DynamoDB：進階設計模式](https://www.youtube.com/watch?v=6yqfmXiZTlM)

 **相關範例：**
+  [AWS 專用資料庫研討會](https://catalog.us-east-1.prod.workshops.aws/workshops/93f64257-52be-4c12-a95b-c0a1ff3b7e2b/en-US) 
+  [專為開發人員打造的資料庫](https://catalog.workshops.aws/db4devs/en-US) 
+  [AWS 現代資料架構 Immersion Day](https://catalog.us-east-1.prod.workshops.aws/workshops/32f3e732-d67d-4c63-b967-c8c5eabd9ebf/en-US) 
+  [在 AWS 上建置資料網格](https://catalog.us-east-1.prod.workshops.aws/workshops/23e6326b-58ee-4ab0-9bc7-3c8d730eb851/en-US) 
+  [ Amazon S3 範例](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-examples.html) 
+  [使用 Amazon Redshift 資料共用來最佳化資料模式](https://wellarchitectedlabs.com/sustainability/300_labs/300_optimize_data_pattern_using_redshift_data_sharing/) 
+  [資料庫遷移](https://github.com/aws-samples/aws-database-migration-samples) 
+  [MS SQL Server - AWS Database Migration Service (AWS DMS) 複寫示範](https://github.com/aws-samples/aws-dms-sql-server) 
+  [資料庫現代化實際操作研討會](https://github.com/aws-samples/amazon-rds-purpose-built-workshop) 
+  [Amazon Neptune 範例](https://github.com/aws-samples/amazon-neptune-samples) 

# PERF03-BP02 評估資料存放區的可用組態選項
<a name="perf_data_evaluate_configuration_options_data_store"></a>

 了解並評估資料存放區可用的各種功能和組態選項，以最佳化工作負載的儲存空間和效能。

 **常見的反模式：**
+  所有工作負載只能使用一種儲存類型，例如 Amazon EBS。
+  您為所有工作負載使用已佈建的 IOPS，卻未針對所有儲存層進行實際測試。
+  您不知道所選資料管理解決方案的組態選項。
+  您完全依賴於增加執行個體大小，而不查看其他可用的組態選項。
+  您並不測試資料存放區的擴展特性。

 **建立此最佳實務的優勢：**藉由探索和試驗資料存放區組態，您能夠降低基礎架構成本、改善效能，以及減少維護工作負載所需的工作量。

 **未建立此最佳實務時的曝險等級：**中 

## 實作指引
<a name="implementation-guidance"></a>

 工作負載可以根據資料儲存和存取需求，使用一個或多個資料存放區。要優化效能達成效率和成本，您必須評估資料存取模式，以判斷適當的資料存放區組態。在探索資料存放區選項時，請考量各種層面，例如儲存選項、記憶體、運算、讀取複本、一致性要求、連線集區以及快取選項。嘗試使用這些不同的組態選項來改善效能達成效率指標。

### 實作步驟
<a name="implementation-steps"></a>
+  了解資料存放區的目前組態 (例如執行個體類型、儲存體大小或資料庫引擎版本)。
+  審核 AWS 文件和最佳實務，以了解可協助改善資料存放區效能的建議組態選項。要考慮的關鍵資料存放區選項如下：    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/wellarchitected/latest/framework/perf_data_evaluate_configuration_options_data_store.html)
+  在非生產環境中執行實驗和基準測試，以確定哪個組態選項能滿足您的工作負載需求。
+  完成試驗之後，請規劃遷移並確認效能指標。
+  使用 AWS 監控 (例如 [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/)) 和最佳化 (例如 [Amazon S3 Storage Lens](https://aws.amazon.com/s3/storage-lens/)) 工具，以透過實際使用模式持續最佳化資料存放區。

## 資源
<a name="resources"></a>

 **相關文件：**
+  [AWS 的雲端儲存](https://aws.amazon.com/products/storage/?ref=wellarchitected) 
+  [Amazon EBS 磁碟區類型](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html) 
+  [Amazon EC2 儲存](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Storage.html) 
+  [Amazon EFS：Amazon EFS 效能](https://docs.aws.amazon.com/efs/latest/ug/performance.html) 
+  [Amazon FSx for Lustre 效能](https://docs.aws.amazon.com/fsx/latest/LustreGuide/performance.html) 
+  [Amazon FSx for Windows File Server 效能](https://docs.aws.amazon.com/fsx/latest/WindowsGuide/performance.html) 
+  [Amazon Glacier：Amazon Glacier 文件](https://docs.aws.amazon.com/amazonglacier/latest/dev/introduction.html) 
+  [Amazon S3：請求率和效能考量](https://docs.aws.amazon.com/AmazonS3/latest/dev/request-rate-perf-considerations.html) 
+  [Amazon EBS I/O 特性](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-io-characteristics.html) 
+  [AWS 的雲端資料庫](https://aws.amazon.com/products/databases/?ref=wellarchitected) 
+  [AWS 資料庫快取](https://aws.amazon.com/caching/database-caching/?ref=wellarchitected) 
+  [DynamoDB Accelerator](https://aws.amazon.com/dynamodb/dax/?ref=wellarchitected) 
+  [Amazon Aurora 最佳實務](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Aurora.BestPractices.html?ref=wellarchitected) 
+  [Amazon Redshift 效能](https://docs.aws.amazon.com/redshift/latest/dg/c_challenges_achieving_high_performance_queries.html?ref=wellarchitected) 
+  [Amazon Athena 10 大效能秘訣](https://aws.amazon.com/blogs/big-data/top-10-performance-tuning-tips-for-amazon-athena/?ref=wellarchitected) 
+  [Amazon Redshift Spectrum 最佳實務](https://aws.amazon.com/blogs/big-data/10-best-practices-for-amazon-redshift-spectrum/?ref=wellarchitected) 
+  [Amazon DynamoDB 最佳實務](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/BestPractices.html?ref=wellarchitected) 

 **相關影片：**
+  [AWS re:Invent 2023：提高 Amazon Elastic Block Store 效率並更具成本效益](https://www.youtube.com/watch?v=7-CB02rqiuw) 
+  [AWS re:Invent 2023：使用 Amazon Simple Storage Service 最佳化儲存價格和效能](https://www.youtube.com/watch?v=RxgYNrXPOLw) 
+  [AWS re:Invent 2023：在 Amazon Simple Storage Service 上建置和最佳化資料湖](https://www.youtube.com/watch?v=mpQa_Zm1xW8) 
+  [AWS re:Invent 2023：AWS 檔案儲存最新消息](https://www.youtube.com/watch?v=yXIeIKlTFV0) 
+  [AWS re:Invent 2023：深入了解 Amazon DynamoDB](https://www.youtube.com/watch?v=ld-xoehkJuU) 

 **相關範例：**
+  [AWS 專用資料庫研討會](https://catalog.us-east-1.prod.workshops.aws/workshops/93f64257-52be-4c12-a95b-c0a1ff3b7e2b/en-US) 
+  [專為開發人員打造的資料庫](https://catalog.workshops.aws/db4devs/en-US) 
+  [AWS 現代資料架構 Immersion Day](https://catalog.us-east-1.prod.workshops.aws/workshops/32f3e732-d67d-4c63-b967-c8c5eabd9ebf/en-US) 
+  [Amazon EBS 自動擴展](https://github.com/awslabs/amazon-ebs-autoscale) 
+  [ Amazon S3 範例](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-examples.html) 
+  [Amazon DynamoDB 範例](https://github.com/aws-samples/aws-dynamodb-examples) 
+  [AWS 資料庫遷移範例](https://github.com/aws-samples/aws-database-migration-samples) 
+  [資料庫現代化研討會](https://github.com/aws-samples/amazon-rds-purpose-built-workshop) 
+  [使用 Amazon RDS for Postgress 資料庫上的參數](https://github.com/awsdocs/amazon-rds-user-guide/blob/main/doc_source/Appendix.PostgreSQL.CommonDBATasks.Parameters.md) 

# PERF03-BP03 收集並記錄資料存放區效能指標
<a name="perf_data_collect_record_data_store_performance_metrics"></a>

 追蹤並記錄資料存放區的相關績效指標，以了解資料管理解決方案的成效。這些指標可協助您最佳化資料存放區、確認是否符合工作負載需求，並提供工作負載執行方式的清晰概觀。

 **常見的反模式：**
+  您只使用手動日誌檔案來搜尋指標。
+  您只會將指標發佈到團隊使用的內部工具，而不會全面了解您的工作負載。
+  您只會使用所選監控軟體記錄的預設指標。
+  您只會在有問題時審查指標。
+  您只監控系統層級指標，而沒有擷取資料存取或用量指標。

 **建立此最佳實務的優勢：**建立效能基準可協助您了解工作負載的正常行為和需求。異常模式可以更快地識別和偵錯，進而改善資料存放區的效能和可靠性。

 **未建立此最佳實務時的曝險等級：**高 

## 實作指引
<a name="implementation-guidance"></a>

 要監控資料存放區的效能，您必須記錄一段時間的多個效能指標。這可讓您偵測異常情況，並根據業務指標衡量效能，以確認您是否滿足工作負載需求。

 指標應包括支援資料存放區的基礎系統和資料庫指標。基礎系統指標可能包括 CPU 使用率、記憶體、可用磁碟儲存體、磁碟 I/O、快取命中率以及網路輸入和輸出指標，而資料存放區指標可能包括每秒交易數、常用查詢、平均查詢速率、回應時間、索引使用狀況、表格鎖定、查詢逾時以及開啟的連線數目。此資料對於了解工作負載的執行情況以及資料管理解決方案的使用方式至關重要。將這些指標納入資料驅動的方法，以調整和優化工作負載的資源。  

 使用工具、程式庫和系統來記錄與資料庫效能有關的效能測量值。

## 實作步驟
<a name="implementation-steps"></a>
+  找出要追蹤的資料存放區關鍵效能指標。
  +  [Amazon S3 指標和維度](https://docs.aws.amazon.com/AmazonS3/latest/userguide/metrics-dimensions.html) 
  +  [監控 Amazon RDS 執行個體中的指標](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Monitoring.html) 
  +  [在 Amazon RDS 上使用 Performance Insights 監控資料庫負載](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.html) 
  +  [增強型監視概觀](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monitoring.OS.overview.html) 
  +  [DynamoDB 指標和維度](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/metrics-dimensions.html) 
  +  [監控 DynamoDB Accelerator](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DAX.Monitoring.html) 
  +  [使用 Amazon CloudWatch 監控 Amazon MemoryDB](https://docs.aws.amazon.com/memorydb/latest/devguide/monitoring-cloudwatch.html) 
  +  [應監控哪些指標？](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheMetrics.WhichShouldIMonitor.html) 
  +  [監控 Amazon Redshift 叢集效能](https://docs.aws.amazon.com/redshift/latest/mgmt/metrics.html) 
  +  [Timestream 指標和維度](https://docs.aws.amazon.com/timestream/latest/developerguide/metrics-dimensions.html) 
  +  [Amazon Aurora 的 Amazon CloudWatch 指標](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.AuroraMonitoring.Metrics.html) 
  +  [Amazon Keyspaces (適用於 Apache Cassandra) 中的日誌記錄和監控](https://docs.aws.amazon.com/keyspaces/latest/devguide/monitoring.html) 
  +  [監控 Amazon Neptune 資源](https://docs.aws.amazon.com/neptune/latest/userguide/monitoring.html) 
+  使用核准的日誌記錄和監控解決方案來收集這些指標。[Amazon CloudWatch](https://aws.amazon.com/cloudwatch/) 可以收集架構中各種資源的指標。您還可以收集和發佈自訂指標以顯示業務或衍生指標。使用 CloudWatch 或第三方解決方案，設定可指出何時超過閾值的警示。
+  檢查資料存放區監控是否能從可偵測效能異常的機器學習解決方案中獲益。
  +  [適用於 Amazon RDS 的 Amazon DevOps Guru](https://docs.aws.amazon.com/devops-guru/latest/userguide/working-with-rds.overview.how-it-works.html) 可檢視效能問題，並提出修正動作的建議。
+  在監控和日誌記錄解決方案中設定資料保留，以符合安全性和營運目標。
  +  [CloudWatch 指標的預設資料保留](https://aws.amazon.com/cloudwatch/faqs/#AWS_resource_.26_custom_metrics_monitoring) 
  +  [CloudWatch Logs 的預設資料保留](https://aws.amazon.com/cloudwatch/faqs/#Log_management) 

## 資源
<a name="resources"></a>

 **相關文件：**
+  [AWS 資料庫快取](https://aws.amazon.com/caching/database-caching/) 
+  [Amazon Athena 10 大效能秘訣](https://aws.amazon.com/blogs/big-data/top-10-performance-tuning-tips-for-amazon-athena/) 
+  [Amazon Aurora 最佳實務](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Aurora.BestPractices.html) 
+  [DynamoDB Accelerator](https://aws.amazon.com/dynamodb/dax/) 
+  [Amazon DynamoDB 最佳實務](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/BestPractices.html) 
+  [Amazon Redshift Spectrum 最佳實務](https://aws.amazon.com/blogs/big-data/10-best-practices-for-amazon-redshift-spectrum/) 
+  [Amazon Redshift 效能](https://docs.aws.amazon.com/redshift/latest/dg/c_challenges_achieving_high_performance_queries.html) 
+  [AWS 的雲端資料庫](https://aws.amazon.com/products/databases/) 
+  [Amazon RDS Performance Insights](https://aws.amazon.com/rds/performance-insights/) 

 **相關影片：**
+ [AWS re:Invent 2022 - 使用 Amazon RDS 和 Aurora 進行效能監控，採用 Autodesk](https://www.youtube.com/watch?v=wokRbwK4YLo)
+ [使用 Amazon DevOps Guru for Amazon RDS 進行資料庫效能監控和調整](https://www.youtube.com/watch?v=cHKuVH7YGBE)
+ [AWS re:Invent 2023 - AWS 檔案儲存最新消息](https://www.youtube.com/watch?v=yXIeIKlTFV0)
+ [AWS re:Invent 2023 - 深入了解 Amazon DynamoDB](https://www.youtube.com/watch?v=ld-xoehkJuU)
+ [AWS re:Invent 2023 - 在 Amazon S3 上建置和最佳化資料湖](https://www.youtube.com/watch?v=mpQa_Zm1xW8)
+ [AWS re:Invent 2023 - AWS 檔案儲存最新消息](https://www.youtube.com/watch?v=yXIeIKlTFV0)
+ [AWS re:Invent 2023 - 深入了解 Amazon DynamoDB](https://www.youtube.com/watch?v=ld-xoehkJuU)
+  [在 Amazon ElastiCache 上監控 Redis 工作負載的最佳實務](https://www.youtube.com/watch?v=c-hTMLN35BY&ab_channel=AWSOnlineTechTalks) 

 **相關範例：**
+  [AWS 資料集擷取指標收集架構](https://github.com/awslabs/aws-dataset-ingestion-metrics-collection-framework) 
+  [Amazon RDS 監控研討會](https://www.workshops.aws/?tag=Enhanced%20Monitoring) 
+ [AWS 專用資料庫研討會](https://catalog.us-east-1.prod.workshops.aws/workshops/93f64257-52be-4c12-a95b-c0a1ff3b7e2b/en-US)

# PERF03-BP04 實作策略以提高資料存放區中的查詢效能
<a name="perf_data_implement_strategies_to_improve_query_performance"></a>

 實作策略以最佳化資料並改善資料查詢，以便為工作負載提供更高的可擴展性和更高效的效能。

 **常見的反模式：**
+  您沒有分割資料存放區中的資料。
+  您在資料存放區中僅以一種檔案格式儲存資料。
+  您沒有在資料存放區中使用索引。

 **建立此最佳實務的優勢：**最佳化資料和查詢效能可提高效率、降低成本並改善使用者體驗。

 **未建立此最佳實務時的曝險等級：**中 

## 實作指引
<a name="implementation-guidance"></a>

資料最佳化和查詢調整是資料存放區中效能效率的關鍵層面，因為其會影響整個雲端工作負載的效能和回應能力。未經過最佳化的查詢可能會使用更多資源和造成更大的瓶頸，進而降低資料存放區的整體效率。

資料最佳化包括數個技術，以確保高效的資料儲存和存取。這也有助於提高資料存放區中的查詢效能。關鍵策略包括資料分割、資料壓縮和資料去常規化，這些都有助最佳化資料的儲存和存取。

### 實作步驟
<a name="implementation-steps"></a>
+  了解和分析在資料存放區中執行的重要資料查詢。
+  找出資料存放區中執行速度緩慢的查詢，並使用查詢計畫了解其目前狀態。
  +  [分析 Amazon Redshift 中的查詢計劃](https://docs.aws.amazon.com/redshift/latest/dg/c-analyzing-the-query-plan.html) 
  +  [在 Athena 中使用 EXPLAIN 和 EXPLAIN ANALYZE](https://docs.aws.amazon.com/athena/latest/ug/athena-explain-statement.html) 
+  實作策略以改善查詢效能。有些關鍵策略包括下列情況：
  +  使用[單欄式檔案格式](https://docs.aws.amazon.com/athena/latest/ug/columnar-storage.html) (例如 Parquet 或 ORC)。
  + 壓縮資料存放區中的資料以減少儲存空間和 I/O 作業。
  +  資料分割可將資料拆分為較小的部分並縮短資料掃描時間。
    + [在 Athena 中分割資料](https://docs.aws.amazon.com/athena/latest/ug/partitions.html)
    + [分割區與資料分配](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.Partitions.html)
  +  在查詢中對共同欄進行資料索引編制。
  +  針對頻繁查詢使用具體化視觀表。
    + [了解具體化視觀表](https://docs.aws.amazon.com/prescriptive-guidance/latest/materialized-views-redshift/understanding-materialized-views.html)
    + [在 Amazon Redshift 中建立具體化視觀表](https://docs.aws.amazon.com/redshift/latest/dg/materialized-view-overview.html)
  +  選擇正確的聯結作業以進行查詢。當您聯結兩個資料表時，請在聯結左側指定較大的資料表，並在聯結右側指定較小的資料表。
  +  分散式快取解決方案可改善延遲並減少資料庫 I/O 操作的次數。
  +  定期維護，例如[清空](https://docs.aws.amazon.com/prescriptive-guidance/latest/postgresql-maintenance-rds-aurora/autovacuum.html)、重新索引以及[執行統計](https://docs.aws.amazon.com/redshift/latest/dg/t_Analyzing_tables.html)。
+  在非生產環境中實驗和測試策略。

## 資源
<a name="resources"></a>

 **相關文件：**
+  [Amazon Aurora 最佳實務](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Aurora.BestPractices.html?ref=wellarchitected) 
+  [Amazon Redshift 效能](https://docs.aws.amazon.com/redshift/latest/dg/c_challenges_achieving_high_performance_queries.html?ref=wellarchitected) 
+  [Amazon Athena 10 大效能秘訣](https://aws.amazon.com/blogs/big-data/top-10-performance-tuning-tips-for-amazon-athena/?ref=wellarchitected) 
+  [AWS 資料庫快取](https://aws.amazon.com/caching/database-caching/?ref=wellarchitected) 
+  [實作 Amazon ElastiCache 的最佳實務](https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/BestPractices.html) 
+  [在 Athena 中分割資料](https://docs.aws.amazon.com/athena/latest/ug/partitions.html) 

 **相關影片：**
+ [AWS re:Invent 2023 - AWS 儲存成本最佳化最佳實務](https://www.youtube.com/watch?v=8LVKNHcA6RY)
+ [AWS re:Invent 2022 - 使用 Amazon RDS 和 Aurora 進行效能監控，採用 Autodesk](https://www.youtube.com/watch?v=wokRbwK4YLo)
+  [使用新的查詢分析工具最佳化 Amazon Athena 查詢](https://www.youtube.com/watch?v=7JUyTqglmNU&ab_channel=AmazonWebServices) 

 **相關範例：**
+ [AWS 專用資料庫研討會](https://catalog.us-east-1.prod.workshops.aws/workshops/93f64257-52be-4c12-a95b-c0a1ff3b7e2b/en-US)

# PERF03-BP05 實作利用快取的資料存取模式
<a name="perf_data_access_patterns_caching"></a>

 實作可受益於快取資料的存取模式，以便快速擷取經常存取的資料。

 **常見的反模式：**
+  快取頻繁變更的資料。
+  您依賴快取資料，就好像它是持久存儲並始終可用一樣。
+  您不考慮快取資料的一致性。
+  您不監控快取實作的效率。

 **建立此最佳實務的優勢：**將資料儲存在快取中可改善讀取延遲、讀取輸送量、使用者體驗和整體效率，並降低成本。

 **未建立此最佳實務時的風險暴露等級：**中 

## 實作指引
<a name="implementation-guidance"></a>

 快取是旨在存儲資料的軟體或硬體組件，以便更快或更有效地滿足未來對相同資料的請求。如果存儲在快取中的資料丟失，可以透過重複之前的計算或從另一個資料存放區中擷取來進行重建。

 資料快取可能是改善整體應用程式效能並減輕基礎主要資料來源負擔的最有效策略之一。可以在應用程式的多個層級快取資料，例如在進行遠端呼叫的應用程式內 (稱為*用戶端快取*)，或使用快速次要服務來儲存資料 (稱為*遠端快取*)。

 **用戶端快取** 

 透過用戶端快取，每個用戶端 (查詢後端資料儲存的應用程式或服務) 都可以在指定的時間內，在本機儲存其唯一查詢的結果。這可以先檢查本機用戶端快取，來減少網路對資料存放區的請求數量。如果結果不存在，應用程式便可查詢資料存放區，並將這些結果儲存在本機。此模式允許每個用戶端將資料儲存在最接近的位置 (用戶端本身)，從而達到最低的延遲。當後端資料存放區無法使用時，用戶端也可以繼續提供某些查詢，從而提高整體系統的可用性。

 這種方法的一個缺點是，當涉及多個用戶端時，它們可能會在本地存儲相同的快取資料。這會導致這些用戶端之間的重複儲存用量和資料不一致。一個用戶端可能會快取查詢結果，一分鐘後，另一個用戶端可以執行相同查詢並獲得不同結果。

 **遠端快取** 

 為了解決用戶端之間的重複資料問題，可以使用快速外部服務或*遠端緩存*來存儲查詢的資料。每個用戶端都會在查詢後端資料存放區之前檢查遠端快取，而非檢查本機資料存放區。此策略可實現用戶端之間更一致的回應、更好的儲存資料效率以及更高的快取資料量，因為儲存空間會獨立於用戶端進行擴展。

 遠端快取的缺點是整個系統可能會遇到較高延遲，因為需要額外的網路跳轉來檢查遠端快取。用戶端快取可以與遠端快取一起用於多層級快取，以改善延遲。

### 實作步驟
<a name="implementation-steps"></a>
+  識別可受益於快取的資料庫、API 和網路服務。具有大量讀取工作負載、高讀寫比率或擴展成本較高的服務都是快取的候選者。
  +  [資料庫快取](https://aws.amazon.com/caching/database-caching/) 
  +  [啟用 API 快取以提升回應能力](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html) 
+  找出最適合您的存取模式的適當快取策略類型。
  +  [快取策略](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Strategies.html) 
  +  [AWS 快取解決方案](https://aws.amazon.com/caching/aws-caching/) 
+  遵循資料存放區的[快取最佳實務](https://aws.amazon.com/caching/best-practices/)。
+  為所有資料設定快取失效策略，例如存留時間 (TTL)，以平衡資料新鮮度並降低後端資料存放區壓力。
+  在用戶端中啟用自動連線重試、指數退避、用戶端逾時和連線集區等功能 (如果可用)，因為它們可以改善效能和可靠性。
  +  [最佳實務：Redis 用戶端和 Amazon ElastiCache (Redis OSS)](https://aws.amazon.com/blogs/database/best-practices-redis-clients-and-amazon-elasticache-for-redis/) 
+  監控快取命中率，目標為 80% 或更高。較低的值可能表示快取大小不足，或者無法從快取中受益的存取模式。
  +  [應監控哪些指標？](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheMetrics.WhichShouldIMonitor.html) 
  +  [在 Amazon ElastiCache 上監控 Redis 工作負載的最佳實務](https://www.youtube.com/watch?v=c-hTMLN35BY) 
  +  [使用 Amazon CloudWatch 搭配 Amazon ElastiCache (Redis OSS) 進行監控的最佳實務](https://aws.amazon.com/blogs/database/monitoring-best-practices-with-amazon-elasticache-for-redis-using-amazon-cloudwatch/) 
+  實作[資料複寫](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Replication.Redis.Groups.html)，將讀取卸載至多個執行個體，並提高資料讀取效能和可用性。

## 資源
<a name="resources"></a>

 **相關文件：**
+  [使用 Amazon ElastiCache Well-Architected Lens](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/WellArchitechtedLens.html) 
+  [使用 Amazon CloudWatch 搭配 Amazon ElastiCache (Redis OSS) 進行監控的最佳實務](https://aws.amazon.com/blogs/database/monitoring-best-practices-with-amazon-elasticache-for-redis-using-amazon-cloudwatch/) 
+  [應監控哪些指標？](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheMetrics.WhichShouldIMonitor.html) 
+  [《利用 Amazon ElastiCache 大規模提高效能》白皮書](https://docs.aws.amazon.com/whitepapers/latest/scale-performance-elasticache/scale-performance-elasticache.html) 
+  [快取挑戰和策略](https://aws.amazon.com/builders-library/caching-challenges-and-strategies/) 

 **相關影片：**
+  [Amazon ElastiCache 學習路徑](https://pages.awscloud.com/GLB-WBNR-AWS-OTT-2021_LP_0003-DAT_AmazonElastiCache.html) 
+  [使用 Amazon ElastiCache 最佳實務打造邁向成功的設計](https://youtu.be/_4SkEy6r-C4) 
+ [AWS re:Invent 2020 - 使用 Amazon ElastiCache 最佳實務打造邁向成功的設計](https://www.youtube.com/watch?v=_4SkEy6r-C4)
+ [AWS re:Invent 2023 - [發佈] Amazon ElastiCache 無伺服器簡介](https://www.youtube.com/watch?v=YYStP97pbXo)
+ [AWS re:Invent 2022 - 使用 Redis 重塑資料層級的 5 個好方法](https://www.youtube.com/watch?v=CD1kvauvKII)
+ [AWS re:Invent 2021 - 深入了解 Amazon ElastiCache (Redis OSS)](https://www.youtube.com/watch?v=QEKDpToureQ)

 **相關範例：**
+  [使用 Amazon ElastiCache (Redis OSS) 提升 MySQL 資料庫效能](https://aws.amazon.com/getting-started/hands-on/boosting-mysql-database-performance-with-amazon-elasticache-for-redis/) 