AWS
DevOps
  • knowledge
    • glossary
    • network knowledge
      • CIDR Block
      • OSI
      • List of Ports
      • Network model
    • AWS best practices
      • Least privilege principle
      • Support Plan
      • Well-architected framework
        • Well-architected framework
        • Cost optimization
        • Operational Excellence
        • Performance efficiency
        • Reliability
        • Security
    • Exams
      • DOP-C02
        • DOP-C02 topics
        • DOP-C02 Labs
      • DVA-C02
      • SOA-C02
  • services
    • access management
      • Directory Service
      • IAM
        • PassRole
      • IAM Identity Center (SSO)
      • Organizations
        • Organizational Unit
        • Control Tower
      • AD Domain Service
    • analytics
      • data analytic
        • Athena
        • QuickSight
        • Redshift
      • data collection
        • Data Lake
        • Lake Formation
      • data processing
        • EMR
        • Kinesis
        • Glue
          • Glue Data Catalog
      • OpenSearch
    • compute
      • Batch
      • EC2
        • Auto Scaling
        • AMI
        • ELB
          • Global accelerator
        • Security Group
        • EBS
        • EC2 Instance Store
        • Spot Fleet
      • Elastic Beanstalk
      • Lambda
        • Layer
        • Lambda API
      • Outposts
      • Wavelength
      • SAM
      • VMWare Cloud
    • container
      • Copilot
      • ECR
      • ECS
        • ECS Anywhere
      • EKS
        • EKS Anywhere
        • EKS Distro
      • Fargate
    • cost management
      • Budgets
      • Cost Explorer
      • Saving Plans
      • Compute Optimizer
    • database
      • Data Engineer
      • Document DB
      • DynamoDB
        • DynamoDB API
        • Scan
      • ElastiCache
      • Keyspaces
      • MemoryDB for Redis
      • Neptune
      • Quantum Ledger Database
      • RDS
        • Aurora
          • Aurora Global Database
          • Aurora Serverless
      • Timestream
    • devTools
      • CICD
        • CodeArtifact
        • CodeCommit
        • CodeBuild
        • CodeDeploy
        • CodePipeline
      • CloudFormation
      • CodeGuru
      • CodeStar
      • CodeWhisperer
      • X-Ray
      • Deployment strategies
    • finance
      • Cost explorer
    • integration
      • AppFlow
      • AppSync
      • EventBridge
      • MQ
      • SNS
      • SQS
      • Step Functions
      • SWF
    • management
      • AppConfig
      • AWS Backup
      • AWS CDK
      • Config
      • Grafana
      • Health Dashboard
      • Proton
      • Service Catalog
      • System Manager
      • SSM
      • Resource Group
      • OpsWorks (discontinued)
    • media
      • Elemental MediaConvert
      • Transcoder
    • messaging
      • SES
    • migration
      • Application Migration Service
      • DataSync
      • DMS
      • Migration Evaluator
      • Migration Hub
      • Server Migration Service
      • Snow Family
      • Transfer Family
    • ML
      • Comprehend
      • Forecast
      • Kendra
      • Lex
      • Rekognition
      • SageMaker
        • SageMaker Data Wrangler
        • SageMaker ML Lineage Tracking
    • monitoring
      • CloudTrail
      • CloudWatch
      • TrustedAdvisor
    • networking
      • CloudFront
      • Customer gateway
      • Edge Location
      • hybrid networking
        • Direct Connect
          • Direct Connect Gateway
        • Site-to-site VPN
      • PrivateLink
      • Region
        • AZ
      • Route 53
      • Transit Gateway
      • VPC
        • VPC Lattice
        • Subnet
          • NACL
        • Internet Gateway
        • Network Firewall
        • VPN
        • NAT Gateway
      • Virtual Private Gateway
    • security
      • Artifact
      • ACM
      • CloudHSM
      • Cognito
      • Detective
      • Firewall Manager
      • GuardDuty
      • Inspector
      • KMS
      • Macie
      • Network Firewall
      • Resource Access Manager
      • Security Hub
      • Secret Manager
      • Secret Hub
      • Shield
      • STS
      • Trusted Advisor
      • WAF
    • storage
      • Backup
      • EBS
      • EFS
      • FSx
      • S3
        • S3 Glacier
        • S3 Snippet
        • S3 Mountpoint
      • Snow family
      • Storage gateway
      • WorkDocs
    • web & mobile
      • Amplify
      • API Gateway
      • Device Farm
      • Pinpoint
Powered by GitBook
On this page
  • Overview
  • Caching
  • Redis vs Memcached
  • Write data
  • Read data
  • Session store
  • Metrics
  • Trivia
  • Concepts
  1. services
  2. database

ElastiCache

PreviousScanNextKeyspaces

Last updated 1 year ago

| | |

Overview

  • Caches are in-memory databases with really high performance, low latency.

  • Support 2 open-source engines: Redis & Memcached

  • Benefit

    • reduce read workload of your databases

    • make your app stateless

    • fully managed by AWS (patching, optimizations, setup, configuration, monitoring, failure recovery and backups)

  • Use case:

    • User session

    • Improve performance of various of data stores, including relational DB, NoSQL DB, API by caching frequently accessed data.


Caching

Redis vs Memcached

Memcached is designed for simplicity while Redis offers a rich set of features that make it effective for a wide range of use cases. About HA, Memcached < Redis.

  • Redis featured encryption, PCI-DSS Compliance.

    • Use cases:

      • Real-time transaction

      • Chat

      • Gaming leaderboard

      • BI & analytics

  • MemCache support AutoDiscovery. Auto Discovery allows applications to automatically identify all of the nodes in a Memcached cluster, simplifying the management of Memcached nodes and allowing your application to scale in and out without manual intervention.

    • You can choose Memcached over Redis if you have the following requirements:

      • You need the simplest model possible.

      • You need to run large nodes with multiple cores or threads.

      • You need the ability to scale out and in, adding and removing nodes as demand on your system increases and decreases.

      • You need to cache objects, such as a database.

      • Multithreaded architecture

Write data

Write-through

  • write both cache & DB

  • An ElastiCache cluster with a write-through strategy will allow for the read requests to be redirected to ElastiCache efficiently -> increase the retrieval speed for the intensive read requests.

  • Pros: data consistency, up-to-date data, reduce the risk of data loss

  • Cons:

    • high latency in write operation

    • the old cache must be invalidated programmatically.

Write-around

  • write DB first

  • Pros: reduce cache pollution

  • Cons: cached not updated -> increase read latency

Write-back

  • write cache first -> async -> DB later

  • Pros: lower write latency

  • Cons: risk data loss

Read data

Lazy loading (Cache Aside)

  • The application must manage both cache and storage, complicating the code.

  • Ensuring data consistency is challenging due to the lack of atomic operations on cache and storage.

Read through

  • Pros: application always read from cache -> easy to implement.

Session store

  • store temp session data in a cache (using [TTL])

  • fully managed Redis & Memcached in-memory DB

  • data-intensive apps, or improve performance of your existing apps.

    • caching

    • game leaderboard

    • session management


Metrics


Trivia

  • Why Lazy loading is called "Lazy"?: a record does not load until the record is needed.

Concepts

  • Cache hit: the data is found in the cache.

  • Cache miss: the data is not found in the cache.

ByteByteGo
Top caching strategies
Memcached vs Redis
CPUUtilization
SwapUsage
Evictions
CurrConnections
Session store
Comparing Memcached and Redis self-designed caches - Amazon ElastiCacheAmazon ElastiCache
Memcached vs Redis
Logo
Write through
Write around
Write back
Read strategies
Read-through strategy