Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AppSyncを使いこなすためのDynamoDB設計パターン

 AppSyncを使いこなすためのDynamoDB設計パターン

ktsukago

July 17, 2018
Tweet

More Decks by ktsukago

Other Decks in Technology

Transcript

  1. Who am I ? e gd B A @ Mobile

    / DevOps / Serverless / Microservices W SJ ba W J c S=
  2. 78  • SPOF  • .6,!3 AZ#"  

    • +/46*!16-%)205(#" '3&$5/
  3. D : 9?7/;@50>A924 • 3A8>!#Read!Write((#  "0>A 924-:6.3*)& 'BE9?7/;@'C •

    ReadCapacityUnitBRCUC!WriteCapacityUnitBWCUC =1A0)& (%$ ' • #,@<+@ 
  4. DynamoDB1 • (7IUE93.57 • /RUR.',DynamoDB :MQ@UBPT2-$7* % /"HULR9 (7 #!63(

    1HULR9 (7 1#/"68)1:MQ@UBPT - /HULR2 1 +14-( • GSI9(7 •  1?SUKRD=TFQ;TIG>C9 (7&.-O; THULR-ANUJ-$7><Q.2/7><Q90(7 &.#-$3(
  5. Product Database ID Type Price Description Products ID Title Category

    Fiction Producer Director … Videos ID Artist Title Genre … Albums ID Author Title Fiction Category Date … Books { Product ID, Type, Price, Description, Author, Title, Fiction, Category, Date, … } ID AlbumID Title Duration … Tracks ActorID VideoID ActorVideo ID Name Age Gender Bio … Actors { Product ID, Type, Price, Description, Artist, Title, Genre, Tracks: [ { Title1, Duration1 },{ Title2, Duration2, } ] … } { Product ID, Type, Price, Description, Title, Category, Fiction, Producer, Director, Actors: [ { ActorID, Name, Age, Gender, ShortBio }, … ] } Normalization Aggregation DynamoDB
  6. " " !  !""  ""   

    "! "  RDBMS  NoSQL 
  7. %.'+  • GetItem • Partation Key   !%)

    • PutItem • 1 !%) • Update • 1 !%) • Delete • 1 !%) • • a G • • a P Q G • • G BKS Query  Scan "(,.#*-  1 MB &.$ 
  8. &3)1 +!2' DynamoDB API  • (3& #.2"3  (5),%$

    !&-  partition key = value  • 4 Item  • (*/!,0"3  Item  )
  9. (1+/ ,%0) • Scan$"(1+/$*- • Scan$Query / GetItem / BatchGet

    !(1+/" • '&. '&.$Partition Key$ #"!" • Scan • (1+/*-"
  10. ,>6:5?> #!Partition key • DB .>3> *)2?1>4';9?0ID +:? 7-2<>/? 

    ) • 2?1>4ID +0.=#  ) ! 8?5#!%(#&":?7-2<>/?+ +$ Partition Key Attribute1 Attribute2 TransactionID OrderID Order_Date 1111111 Customer1-1 2016-05-17 01.36.45 1111112 Customer1-2 2016-05-18 01.36.30 1111113 Customer2-1 2016-05-18 01.36.30
  11. CQRS • Command Query Responsibility Segregation • Command (write) %

    Query (read) ',* • Why • =C41C4& #7C5<7?(* • 2B0?7C59C4 & CRUD "%* • Command / Query  ,*%$* • Benefit • + +&&# !7C5<7?,* • Read / Write , #41C?$* • 8;-BA36/%.:@C2>B, )+*
  12. AWS Lambda DynamoDB Stream Query service 2 Amazon ES Query

    service 1 Query service 3 Amazon Redshift Amazon DynamoDB Command side Query side Amazon DynamoDB DynamoDBEvent Sourcing
  13. AWS Lambda Amazon DynamoDB Amazon API Gateway Amazon DynamoDB Stream

    AWS Lambda Amazon S3 Amazon ES Amazon Athena Amazon DynamoDB Query side Command side ü DynamoDB Streams  Lambda Event Sourcing ü QueryCommand   Command Query Responsibility Segregation Serverless  CQRS 
  14. AppSync  CQRS &#*) Amazon DynamoDB ElasticSearch   

     Command  DynamoDBPut Query!*(*%' "*$*#
  15. RDBMS    Rows Primary Key Index  

    ID  1 2 3     SA SA SA Columns
  16. DynamoDB  Data  Partition Key Sort Key  SA

    ID ColA 1 1 1    Data   SA ColA    Partition KeySort Key  ID 1 1 1 Attribute
  17.  on S R y M R DS M S

    B yM n R y m n n S M a S