{"id":2952,"date":"2019-06-28T10:54:07","date_gmt":"2019-06-28T08:54:07","guid":{"rendered":"http:\/\/miro.borodziuk.eu\/?p=2952"},"modified":"2019-09-02T12:19:23","modified_gmt":"2019-09-02T10:19:23","slug":"in-memory-chaching-elasticcache-dax","status":"publish","type":"post","link":"http:\/\/miro.borodziuk.eu\/index.php\/2019\/06\/28\/in-memory-chaching-elasticcache-dax\/","title":{"rendered":"In-Memory Chaching (ElastiCache, DAX)"},"content":{"rendered":"<p><span style=\"color: #3366ff;\">ElastiCache<\/span> is a managed in-memory data store supporting the <strong>Redis<\/strong> or <strong>Memcached<\/strong> engines. ElastiCache is used for two common use cases:<\/p>\n<p><!--more--><\/p>\n<ul>\n<li>Offloading database reads by caching responses, improving application speed and reducing costs<\/li>\n<li>Storing user session state, allowing for stateless compute instances (used for fault-tolerant architectures)<\/li>\n<\/ul>\n<p>Generally, ElastiCache is used with key value databases or to store simple session data, but it can be used with SQL database engines.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2953 aligncenter\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/ElasticCache.jpg\" alt=\"\" width=\"579\" height=\"574\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/ElasticCache.jpg 579w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/ElasticCache-150x150.jpg 150w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/ElasticCache-300x297.jpg 300w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/ElasticCache-100x100.jpg 100w\" sizes=\"(max-width: 579px) 100vw, 579px\" \/><\/p>\n<ul>\n<li>Managed in-memory data store and cache<\/li>\n<li><strong>Memcached<\/strong> or <strong>Redis<\/strong> engines<\/li>\n<li>Typically used to offload database reads to improve web application performance<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">Node Type<\/span><\/p>\n<ul>\n<li>Families affect CPU\n<ul>\n<li>General Purpose (T2, M4, M5)<\/li>\n<li>Memory Optimized (R4, R5)<\/li>\n<\/ul>\n<\/li>\n<li>Sizes affect memory and network<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">Monitoring &#8211; CloudWatch metrics<\/span><\/p>\n<ul>\n<li><code>CPU Utilization<\/code>\n<ul>\n<li>When threshold is exceeded\n<ul>\n<li>Increase the node family<\/li>\n<li>Add more read replicas (<em>Redis<\/em>) or nodes (<em>Memcached<\/em>)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><code>Evictions<\/code>\n<ul>\n<li>Older items are removed to free up memory for new items<\/li>\n<li>Frequent evictions will decrease performance ,\n<ul>\n<li>Increase the node size (memory)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><code>CurrConnections<\/code>\n<ul>\n<li>The application may not be releasing connections<\/li>\n<\/ul>\n<\/li>\n<li><code>Swap Usage<\/code>\n<ul>\n<li>Affects performance if increased<\/li>\n<li>Should be close to 0<\/li>\n<li>Increase node size<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #3366ff;\">DynamoDB Accelerator (DAX)<\/span> is an in-memory cache designed specifically for DynamoDB. Results delivered from DAX are available in microseconds rather than in the single-digit milliseconds available from DynamoDB.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2959 aligncenter\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/DAX1.jpg\" alt=\"\" width=\"633\" height=\"225\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/DAX1.jpg 633w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/DAX1-300x107.jpg 300w\" sizes=\"(max-width: 633px) 100vw, 633px\" \/><\/p>\n<p>DAX maintains two distinct caches:<\/p>\n<ul>\n<li>Item cache<\/li>\n<li>Query cache.<\/li>\n<\/ul>\n<p>The<strong> item cache<\/strong> is populated with results from <code>GetItem<\/code> and <code>BatchGetItem<\/code> and has a five-minute default TTL.<\/p>\n<p>The <strong>query cache<\/strong> stores results of <code>Query<\/code> and <code>Scan<\/code> operations and caches based on the parameters specified.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2960 aligncenter\" src=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/DAX2.jpg\" alt=\"\" width=\"621\" height=\"272\" srcset=\"http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/DAX2.jpg 621w, http:\/\/miro.borodziuk.eu\/wp-content\/uploads\/DAX2-300x131.jpg 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ElastiCache is a managed in-memory data store supporting the Redis or Memcached engines. ElastiCache is used for two common use cases:<\/p>\n","protected":false},"author":1,"featured_media":2955,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79],"tags":[],"_links":{"self":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/2952"}],"collection":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/comments?post=2952"}],"version-history":[{"count":10,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/2952\/revisions"}],"predecessor-version":[{"id":2973,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/posts\/2952\/revisions\/2973"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/media\/2955"}],"wp:attachment":[{"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/media?parent=2952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/categories?post=2952"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/miro.borodziuk.eu\/index.php\/wp-json\/wp\/v2\/tags?post=2952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}