{"id":576,"date":"2019-09-19T13:27:12","date_gmt":"2019-09-19T04:27:12","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/09\/19\/cqrs-dynamodb"},"modified":"2019-09-19T13:27:12","modified_gmt":"2019-09-19T04:27:12","slug":"cqrs-dynamodb","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/09\/19\/cqrs-dynamodb\/","title":{"rendered":"CQRS\u3068DynamoDB\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u8a2d\u8a08"},"content":{"rendered":"
\u5148\u65e5\u3001\u7d50\u5a5a\u3057\u307e\u3057\u305f\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u5185\u5c71\u3067\u3059\u3002
\n\u4eca\u56de\u306f DynamoDB \u306b\u304a\u3051\u308b\u30c7\u30fc\u30bf\u69cb\u9020\u8a2d\u8a08\u306b\u95a2\u3059\u308b\u8003\u5bdf\u3092\u884c\u3044\u307e\u3057\u305f\u3002<\/p>\n
DynamoDB \u306e\u30c7\u30fc\u30bf\u69cb\u9020\u8a2d\u8a08\u3092\u884c\u3046\u969b\u3001RDB \u306e\u8a2d\u8a08\u3068\u306f\u7570\u306a\u308b\u8003\u3048\u65b9\u3092\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/strong> __CQRS \u306f\u300cCommand Query Responsibility Segregation\uff1a\u30b3\u30de\u30f3\u30c9\u30af\u30a8\u30ea\u8cac\u4efb\u5206\u96e2\u300d__\u3068\u3044\u3046\u610f\u5473\u3067\u3001DB\u3078\u306e\u66f8\u304d\u8fbc\u307f( Command )\u3068\u8aad\u307f\u8fbc\u307f( Query )\u3092\u5225\u7269\u3068\u3057\u3066\u6349\u3048\u308b\u8003\u3048\u65b9\u3067\u3059\u3002\u66f8\u304d\u8fbc\u307f\u7528\u3068\u8aad\u307f\u8fbc\u307f\u7528\u306e\u305d\u308c\u305e\u308c\u306e DB \u3092\u5206\u96e2\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u306d\u3002<\/p>\n RDB\u306e\u30ea\u30fc\u30c9\u30ec\u30d7\u30ea\u30ab\u306b\u4f3c\u3066\u3044\u307e\u3059\u3002 DynamoDB \u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7279\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n \u3053\u306e\u7279\u6027\u3092\u8003\u616e\u3059\u308b\u3068\u3001Command \u7528\u30c7\u30fc\u30bf\u69cb\u9020\u3092\u8a2d\u8a08\u3059\u308b\u5834\u5408\u3001 \u307e\u305f DynamoDB \u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7279\u6027\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n \u3053\u308c\u3089\u306e\u5236\u7d04\u3092\u8003\u616e\u3057\u3001\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u30d1\u30bf\u30fc\u30f3\u306b\u5fdc\u3058\u3066\u3001\u6700\u9069\u306a\u30c7\u30fc\u30bf\u69cb\u9020( Query \u7528\u30c7\u30fc\u30bf\u69cb\u9020)\u3092\u4f5c\u3063\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/strong><\/p>\n \u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a2\u30af\u30bb\u30b9\u30d1\u30bf\u30fc\u30f3\u304c\u3042\u308b\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n Query \u7528\u306e DB \u306f DynamoDB \u306b\u9650\u3089\u305a\u3001ElasticSearch\u3092\u7528\u3044\u3066\u3082\u826f\u3044\u5834\u5408\u3082\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n __Command \u30c7\u30fc\u30bf\u304b\u3089 Query \u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002__\u3053\u308c\u306f\u4f8b\u3048\u3070 DynamoDB Stream \u7d4c\u7531\u3067\u3001Lambda \u3092\u5b9f\u884c\u3057\u3066\u884c\u3046\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002\u4f5c\u6210\u5931\u6557\u3057\u305f\u6642\u306f Lambda \u304c\u518d\u8a66\u884c\u3059\u308b\u306e\u3067\u3001\u307b\u307c\u5909\u63db\u306f\u6210\u529f\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n \u3069\u3046\u3057\u3066\u3082\u53b3\u5bc6\u306a\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u51e6\u7406\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001Kinesis \u7d4c\u7531\u3067 RDB \u3092\u7528\u3044\u3066\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3060\u3068\u601d\u3044\u307e\u3059(Command)\u3002 \u3010AWS re:Invent 2017 \u30ec\u30dd\u30fc\u30c8\u3011\u30b5\u30fc\u30d0\u30ec\u30b9\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u30fc\u306e\u6700\u9069\u5316 #SRV301<\/a><\/p>\n
\nDynamoDB \u306f\u3001NoSQL \u3067\u3042\u308a\u3001\u69d8\u3005\u306a\u5236\u7d04\u304c\u3042\u308b\u306e\u3067\u3001\u8272\u3005\u3068\u982d\u3092\u3072\u306d\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001\u56db\u82e6\u516b\u82e6\u3057\u306a\u304c\u3089\u4f55\u3068\u304b\u5f62\u306b\u3057\u3066\u3044\u307e\u3059\u3002
\n\u305d\u3093\u306a\u4e2d\u3001CQRS<\/strong> \u3068\u3044\u3046\u8003\u3048\u65b9\u304c\u3042\u308b\u3053\u3068\u3092\u77e5\u3063\u305f\u306e\u3067\u3001DynamoDB \u306e\u30c7\u30fc\u30bf\u69cb\u9020\u8a2d\u8a08\u3068\u306e\u95a2\u4fc2\u6027\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\nCQRS\u3068\u306f<\/h2>\n
\n\u30ea\u30fc\u30c9\u30ec\u30d7\u30ea\u30ab\u3067\u306f\u3001\u66f8\u304d\u8fbc\u307f\u7528 DB (\u30de\u30b9\u30bf\u30fc)\u3068\u8aad\u307f\u8fbc\u307f\u7528 DB (\u30b9\u30ec\u30fc\u30d6)\u304c\u3042\u308a\u307e\u3059\u3002\u30de\u30b9\u30bf\u30fc\u3068\u30b9\u30ec\u30fc\u30d6\u3067\u306f\u30c7\u30fc\u30bf\u69cb\u9020(\u30b9\u30ad\u30fc\u30de)\u306f\u5b8c\u5168\u306b\u540c\u3058\u3067\u3059\u3002
CQRS \u3067\u306f\u3001\u66f8\u304d\u8fbc\u307f\u7528\u3068\u8aad\u307f\u8fbc\u307f\u7528\u3067\u30c7\u30fc\u30bf\u69cb\u9020\u304c\u7570\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u8a31\u5bb9\u3057\u3066\u3044\u308b\u3068\u8a00\u3048\u307e\u3059\u3002<\/p>\nDynamoDB \u3067\u306e Command \u7528\u30c7\u30fc\u30bf\u69cb\u9020<\/h2>\n
\n
\n
\n\u30a2\u30c8\u30df\u30c3\u30af\u6027\u3092\u4fdd\u6301\u3057\u305f\u3044\u30c7\u30fc\u30bf\u306f\u3001\u9650\u3089\u308c\u305f\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u5185\u306b\u53ce\u3081\u3089\u308c\u308b\u3088\u3046\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u306b\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/strong><\/p>\nDynamoDB \u3067\u306e Query \u7528\u30c7\u30fc\u30bf\u69cb\u9020<\/h2>\n
\n
\n
Command\u30c7\u30fc\u30bf\u304b\u3089Query\u30c7\u30fc\u30bf\u3078\u306e\u5909\u63db\u306b\u3064\u3044\u3066<\/h2>\n
\u305d\u306e\u4ed6\u306e\u8003\u5bdf<\/h2>\n
\n\u66f4\u65b0\u304c\u6210\u529f\u3057\u305f\u3089\u3001DynamoDB \u3084 ElasticSearch \u306b Query \u7528\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\u53c2\u8003<\/h2>\n