

# 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 儲存技術及其重要特性的一些範例包含：


<table>
<thead>
  <tr><th> <b>類型</b> </th><th> <b>AWS 服務</b> </th><th> <b>重要特性</b> </th></tr>
</thead>
<tbody>
  <tr><td>物件儲存</td><td> <a href="https://aws.amazon.com/s3/">Amazon S3</a> </td><td> 具有不受限的可擴展性、高可用性，以及多個可存取性選項。對 Amazon S3 輸入和存取物件時，可以使用 <a href="https://aws.amazon.com/s3/transfer-acceleration/">Transfer Acceleration</a> 或 <a href="https://aws.amazon.com/s3/features/access-points/">Access Points</a> 之類的服務來支援您的位置、安全需求和存取模式。</td></tr>
  <tr><td>封存儲存</td><td> <a href="https://aws.amazon.com/s3/storage-classes/glacier/">Amazon Glacier</a> </td><td> 專為資料封存而打造。</td></tr>
  <tr><td>串流儲存空間</td><td> <a href="https://aws.amazon.com/kinesis/">Amazon Kinesis</a> <br /><a href="https://aws.amazon.com/msk/">Amazon Managed Streaming for Apache Kafka (Amazon MSK)</a></td><td> 快速地擷取和儲存串流資料。</td></tr>
  <tr><td>共用檔案系統</td><td><a href="https://aws.amazon.com/efs/">Amazon Elastic File System (Amazon EFS)</a></td><td> 可供多種類型的運算解決方案存取的可掛載檔案系統。</td></tr>
  <tr><td>共用檔案系統</td><td> <a href="https://aws.amazon.com/fsx/">Amazon FSx</a> </td><td> 建置於最新的 AWS 運算解決方案之上，用以支援四個常用的檔案系統：NetApp ONTAP、OpenZFS、Windows File Server 和 Lustre。Amazon FSx 的<a href="https://aws.amazon.com/fsx/when-to-choose-fsx/">延遲、輸送量和 IOPS</a> 會隨著檔案系統而不同，當您為工作負載需求選取適當的檔案系統時，應予以考量。</td></tr>
  <tr><td>區塊儲存</td><td> <a href="https://aws.amazon.com/ebs/">Amazon Elastic Block Store (Amazon EBS)</a> </td><td> 專為 Amazon Elastic Compute Cloud (Amazon EC2) 設計的可擴展、高效能區塊儲存服務。Amazon EBS 包含支援 SSD 的儲存，適用於交易型、IOPS 密集型工作負載，以及適用於輸送量密集型工作負載的支援 HDD 的儲存。</td></tr>
  <tr><td>關聯式資料庫</td><td> <a href="https://aws.amazon.com/rds/aurora">Amazon Aurora</a>、<a href="https://aws.amazon.com/rds">Amazon RDS</a>、<a href="https://aws.amazon.com/redshift">Amazon Redshift</a>。</td><td> 旨在支援 ACID (單元性、一致性、隔離行為、持續性) 交易，並維護參考完整性和強大的資料一致性。許多傳統應用程式、企業資源規劃 (ERP)、客戶關係管理 (CRM) 和電子商務都使用關聯式資料庫來儲存資料。</td></tr>
  <tr><td>鍵值資料庫</td><td> <a href="https://aws.amazon.com/dynamodb/">Amazon DynamoDB</a> </td><td> 已針對常見的存取模式進行最佳化，通常用於儲存和擷取大量資料。高流量 Web 應用程式、電子商務系統和遊戲應用程式是鍵值資料庫的典型使用案例。</td></tr>
  <tr><td>文件資料庫</td><td> <a href="https://aws.amazon.com/documentdb/">Amazon DocumentDB</a> </td><td> 旨在將半結構化資料儲存為 JSON 類文件。這些資料庫可協助開發人員快速建置和更新應用程式，例如內容管理、目錄和使用者設定檔。  </td></tr>
  <tr><td>記憶體資料庫</td><td> <a href="https://aws.amazon.com/elasticache/">Amazon ElastiCache</a>、<a href="https://aws.amazon.com/memorydb/">Amazon MemoryDB for Redis</a> </td><td> 適用於需要即時存取資料、最低延遲和最高輸送量的應用程式。您可以將記憶體資料庫用於應用程式快取、工作階段管理、遊戲排行榜、低延遲 ML 特徵存放區、微型服務簡訊系統，以及高輸送量串流機制 </td></tr>
  <tr><td>圖形資料庫</td><td> <a href="https://aws.amazon.com/neptune/">Amazon Neptune</a> </td><td> 適用於此類應用程式：必須在高度連線圖形資料集之間，大規模導覽和查詢數百萬個關係，並且在過程中僅有毫秒延遲。許多公司使用圖形資料庫進行詐騙偵測、社交聯網和推薦引擎。</td></tr>
  <tr><td>時間序列資料庫</td><td> <a href="https://aws.amazon.com/timestream/">Amazon Timestream</a> </td><td> 可快速地從隨時間變化的資料收集、合成和衍生洞見。IoT 應用程式、DevOps 和工業遙測可以利用時間序列資料庫。</td></tr>
  <tr><td> 寬欄 </td><td> <a href="https://aws.amazon.com/mcs/">Amazon Keyspaces (適用於 Apache Cassandra)</a> </td><td> 可使用表格、列和欄，但與關聯式資料庫不同，在同一個表格中，欄的名稱和格式會因列而異。您通常會在大規模工業應用程式中看到寬欄存放區，用於設備維護、叢集管理和路由優化。  </td></tr>
  <tr><td> 總帳 </td><td> <a href="https://aws.amazon.com/qldb/">Amazon Quantum Ledger Database (Amazon QLDB)</a> </td><td> 可提供集中化且受信任的機構，為每個應用程式維護可擴展、不可變且以密碼編譯方式驗證的交易記錄。我們會看到用於記錄、供應鏈、註冊甚至銀行交易系統的總帳資料庫。   </td></tr>
</tbody>
</table>

+  如果您要建置資料平台，請利用 AWS 上的[現代資料架構](https://aws.amazon.com/big-data/datalakes-and-analytics/modern-data-architecture/)來整合資料湖、資料倉儲和專用資料存放區。
+  為工作負載選擇資料存放區時，需要考慮的關鍵問題如下：


<table>
<thead>
  <tr><th> 問題 </th><th> 重要考慮事項 </th></tr>
</thead>
<tbody>
  <tr><td> 如何建構資料？ </td><td> <ul><li>  <a href="https://aws.amazon.com/documentdb/">如果資料是非結構化的，請考慮諸如 <a href="https://aws.amazon.com/products/storage/data-lake-storage/">Amazon S3</a> 等物件存放區，或諸如 Amazon DocumentDB</a> 等 NoSQL 資料庫  </li><li>  對於索引鍵值資料，請考慮使用 <a href="https://aws.amazon.com/documentdb/">DynamoDB</a>、<a href="https://aws.amazon.com/elasticache/redis/">Amazon ElastiCache (Redis OSS)</a> 或 <a href="https://aws.amazon.com/memorydb/">Amazon MemoryDB</a>  </li></ul> </td></tr>
  <tr><td> 需要哪種層級的參考完整性？ </td><td> <ul><li>  對於外部索引鍵限制，<a href="https://aws.amazon.com/rds/">Amazon RDS</a> 和 <a href="https://aws.amazon.com/rds/aurora/">Aurora</a> 等關聯式資料庫可以提供此等級的完整性。 </li><li>  通常情況下，在 NoSQL 資料模型中，您會將資料去正規化到單一文件或文件集合中，以在單個請求中擷取，而不是跨文件或資料表聯結。   </li></ul> </td></tr>
  <tr><td> ACID (單元性、一致性、隔離行為、持續性) 是否需要合規？ </td><td> <ul><li>  如果需要與關聯式資料庫相關聯的 ACID 屬性，請考慮關聯式資料庫，例如 <a href="https://aws.amazon.com/rds/">Amazon RDS</a> 和 <a href="https://aws.amazon.com/rds/aurora/">Aurora</a>。 </li><li>  如果 <a href="https://aws.amazon.com/nosql/">NoSQL 資料庫</a>需要強大的一致性，您可以搭配使用高度一致性讀取與 <a href="https://aws.amazon.com/documentdb/">DynamoDB</a>。 </li></ul> </td></tr>
  <tr><td> 儲存要求如何隨時間變更？ 這如何影響可擴展性？ </td><td> <ul><li>  <a href="https://aws.amazon.com/documentdb/">DynamoDB</a> 和 <a href="https://aws.amazon.com/qldb/">Amazon Quantum Ledger Database (Amazon QLDB)</a> 等無伺服器資料庫將動態擴展。 </li><li>  關聯式資料庫在佈建的儲存體上有上限，而且一旦達到這些限制，通常必須使用碎片等機制進行水平分割。 </li></ul> </td></tr>
  <tr><td> 讀取查詢與寫入查詢的比例是多少？ 快取可能改善效能嗎？ </td><td> <ul><li>  如果資料庫為 DynamoDB，則讀取量繁重的工作負載可以受益於快取層，例如 <a href="https://aws.amazon.com/elasticache/">ElastiCache</a> 或 <a href="https://aws.amazon.com/dynamodb/dax/">DAX</a>。 </li><li>  讀取也可以卸載至具有關聯式資料庫的讀取複本，例如 <a href="https://aws.amazon.com/rds/">Amazon RDS</a>。 </li></ul> </td></tr>
  <tr><td> 儲存和修改 (OLTP - 線上交易處理) 或擷取和報告 (OLAP - 線上分析處理) 是否具有更高的優先順序？ </td><td> <ul><li>  對於高輸送量的按原樣讀取交易處理，請考慮使用 NoSQL 資料庫，例如 DynamoDB。 </li><li>  對於具有一致性的高輸送量和複雜讀取模式 (例如聯結)，請使用 Amazon RDS。 </li><li>  對於分析查詢，請考慮使用 <a href="https://aws.amazon.com/redshift/">Amazon Redshift</a> 之類的單欄式資料庫，或將資料匯出到 Amazon S3，然後使用 <a href="https://aws.amazon.com/athena/">Athena</a> 或 <a href="https://aws.amazon.com/quicksight/">Amazon Quick</a> 執行分析。 </li></ul> </td></tr>
  <tr><td> 資料需要哪種層級的耐久性？ </td><td> <ul><li>  Aurora 會自動跨區域內的三個可用區域複寫資料，這表示資料高度耐用且資料遺失的機會較低。 </li><li>  DynamoDB 會自動跨多個可用區域複寫，具有高可用性和資料耐久性。 </li><li>  Amazon S3 提供 11 個九的耐用性。許多資料庫服務 (例如 Amazon RDS 和 DynamoDB) 支援將資料匯出至 Amazon S3，進行長期保留和封存。 </li></ul> </td></tr>
  <tr><td> 是否希望擺脫商務資料庫引擎、或授權成本？ </td><td> <ul><li>  考慮開放原始碼引擎，例如 Amazon RDS 或 Aurora 上的 PostgreSQL 和 MySQL。 </li><li>  利用 <a href="https://aws.amazon.com/dms/">AWS Database Migration Service</a> 和 <a href="https://aws.amazon.com/dms/schema-conversion-tool/">AWS Schema Conversion Tool</a>，從商務資料庫引擎遷移至開放原始碼  </li></ul> </td></tr>
  <tr><td> 對資料庫的操作期望是什麼？ 移至受管服務是否為主要問題？ </td><td> <ul><li>  利用 Amazon RDS 而非 Amazon EC2，以及利用 DynamoDB 或 Amazon DocumentDB 而非自行託管 NoSQL 資料庫，可以減少營運開銷。 </li></ul> </td></tr>
  <tr><td> 目前如何存取資料庫？ 它是否只是應用程式存取，或是否有商業智能 (BI) 使用者和其他連網的現成應用程式？ </td><td> <ul><li>  如果您依賴於外部工具，則可能必須保持與其所支援之資料庫的相容性。Amazon RDS 與它支援的差異引擎版本完全相容，包括 Microsoft SQL Server、Oracle、MySQL 和 PostgreSQL。 </li></ul> </td></tr>
</tbody>
</table>

+  在非生產環境中執行實驗和基準測試，以確定哪個資料存放區最能滿足您的工作負載需求。

## 資源
<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) 