1 00:00:00,120 --> 00:00:01,350 ‫So we know that ODB 2 00:00:01,350 --> 00:00:04,470 ‫can be used to store data, but it can also 3 00:00:04,470 --> 00:00:07,890 ‫be used to store the session state, as a cache. 4 00:00:07,890 --> 00:00:11,370 ‫And so this is something that your web application can use. 5 00:00:11,370 --> 00:00:13,020 ‫And therefore, they can retrieve 6 00:00:13,020 --> 00:00:15,330 ‫or store the session states on demand. 7 00:00:15,330 --> 00:00:17,520 ‫And share the user login, for example, 8 00:00:17,520 --> 00:00:19,509 ‫across all your backend web applications. 9 00:00:19,509 --> 00:00:23,730 ‫So this is very common use case for DynamoDB. 10 00:00:23,730 --> 00:00:26,167 ‫But, this is something we've seen as well for ElastiCache. 11 00:00:26,167 --> 00:00:29,760 ‫So ElastiCache and DynamoDB achieve the same purpose. 12 00:00:29,760 --> 00:00:31,140 ‫So the question you may ask yourself is 13 00:00:31,140 --> 00:00:33,000 ‫what is the difference of using DynamoDB 14 00:00:33,000 --> 00:00:35,851 ‫or ElastiCache to store the session states? 15 00:00:35,851 --> 00:00:39,120 ‫Well, ElastiCache is going to be fully in memory, 16 00:00:39,120 --> 00:00:41,700 ‫and DynamoDB is going to be serverless. 17 00:00:41,700 --> 00:00:43,803 ‫And both are going to be key/value stores. 18 00:00:43,803 --> 00:00:45,990 ‫So if the exam is saying, okay we need 19 00:00:45,990 --> 00:00:48,120 ‫a session state store, that's going to be 20 00:00:48,120 --> 00:00:50,820 ‫in memory, it probably means ElastiCache. 21 00:00:50,820 --> 00:00:53,940 ‫And if it talks about automatic scaling and so on, 22 00:00:53,940 --> 00:00:55,960 ‫then DynamoDB is probably the right way. 23 00:00:55,960 --> 00:00:59,776 ‫So this is something you have to look for in the exam. 24 00:00:59,776 --> 00:01:02,190 ‫Another way you can store the session states 25 00:01:02,190 --> 00:01:03,420 ‫would be on disk. 26 00:01:03,420 --> 00:01:06,750 ‫And you need to share that disc across many EC2 instances. 27 00:01:06,750 --> 00:01:09,000 ‫So EFS could be a great choice. 28 00:01:09,000 --> 00:01:10,560 ‫So EFS must be attached 29 00:01:10,560 --> 00:01:13,260 ‫to your EC2 instances as a network drive. 30 00:01:13,260 --> 00:01:15,420 ‫And this could work versus DynamoDB. 31 00:01:15,420 --> 00:01:16,800 ‫But so EFS is a file system 32 00:01:16,800 --> 00:01:18,480 ‫and then DynamoDB is a database. 33 00:01:18,480 --> 00:01:19,921 ‫So here is the difference. 34 00:01:19,921 --> 00:01:22,350 ‫So you may say okay, you said EFS was for storage, 35 00:01:22,350 --> 00:01:26,280 ‫so what about my EBS volume and my EC2 instance store? 36 00:01:26,280 --> 00:01:28,770 ‫So yes this is storage, but it can only 37 00:01:28,770 --> 00:01:31,320 ‫be used for local caching, not shared caching. 38 00:01:31,320 --> 00:01:33,750 ‫Because your EBS drives and your instance store 39 00:01:33,750 --> 00:01:36,390 ‫are attached to only one EC2 instance. 40 00:01:36,390 --> 00:01:37,740 ‫So very important, this can be used 41 00:01:37,740 --> 00:01:39,540 ‫for caching a local dataset, 42 00:01:39,540 --> 00:01:42,540 ‫but not for sharing it across many instances. 43 00:01:42,540 --> 00:01:44,520 ‫And then finally, what about S3? 44 00:01:44,520 --> 00:01:46,945 ‫S3 could be used for session states, 45 00:01:46,945 --> 00:01:49,230 ‫yes, but it has a higher latency. 46 00:01:49,230 --> 00:01:52,440 ‫It's meant for big files, not for small objects. 47 00:01:52,440 --> 00:01:57,440 ‫So S3 as a station state cache is not a great tool. 48 00:01:57,510 --> 00:01:59,910 ‫So really, the best two are going to be 49 00:01:59,910 --> 00:02:02,430 ‫or best three is DynamoDB, ElastiCache, and EFS. 50 00:02:02,430 --> 00:02:04,890 ‫But preferably DynamoDB and ElastiCache. 51 00:02:04,890 --> 00:02:06,090 ‫And it's all about to figure out 52 00:02:06,090 --> 00:02:07,620 ‫if you want something in memory 53 00:02:07,620 --> 00:02:09,690 ‫or something that's going to be more serverless 54 00:02:09,690 --> 00:02:11,348 ‫and with automatic scaling. 55 00:02:11,348 --> 00:02:12,570 ‫Okay, that's it. 56 00:02:12,570 --> 00:02:14,320 ‫I will see you in the next lecture.