ElastiCache - When speed is everything

Using an in-memory cache is the best option to boost your application performance while keeping costs low, says AWS

Advertorial Speed matters. More than 63.1% of world's population access the internet on their smartphones, tablets, or other mobile devices, an increase of 178 million or 3.7%, since 2021 according to statistics compiled in July this year. The UK has one of the highest internet penetration rates in the world at 98%, where 90.2% of UK mobile users depend on fast, consistent Wifi or cellular connections. The prevalence of users using mobile devices has led to a massive proliferation of real-time applications, driving the urgency for databases to meet the demand of ultra-fast content delivery. In-memory data caches can take an application from fast to ultra-fast, giving users the desired instant response time for any application.

Therefore, application speed is a critical consideration, both for users and system administrators. Even search engines like Google include site responsiveness as part of their ranking algorithms as page speed impacts the overall user experience. Some reports suggest that slow loading content is the number one reason visitors abandon a website after viewing just one page, or they may not even wait for the page to load before abandoning. This user behavior can then negatively impact your business' profitability, according to a study by Akamai, which found that a 100-millisecond delay in website load time can hurt conversion rates by 7%, and a two-second delay in web page load time increases bounce rate by 103%.

The biggest drag on content load times is generally caused by data retrieval. Traditional databases typically have content load times of milliseconds or more with solid-state disk (SSD) drives, as opposed to the microsecond latencies available when accessing memory directly with in-memory data stores. The difference in speed is massive – going from microseconds to milliseconds (1 microsecond is 1/1000 of a millisecond).

Speeding up data access with in-memory caching

Caching frequently-read, or 'hot' data in memory is the fastest storage mechanism to help address content load times. In-memory caching adds a high-speed data storage layer to complement the primary database for low latency. A cache is a highly effective way to speed up data access, especially in the cloud where caching nodes can scale quickly to serve applications as compute-intensive workloads and usage grow.

By separating the caching layer from the application, you can scale the cache independently to match the application's needs. Applications can also efficiently share the same data in the cache to reach the high availability needed for critical workloads. A cache also supports hot data beyond database query results and covers API calls, real-time data, frequently accessed content, and frequently used but infrequently changing calculations that crunch through computing cycles.

Using an in-memory cache offers some significant benefits over just scaling your database. "It's typically less expensive to scale out the in-memory caching layer than it is to scale up a database server. Moreover, scaling up a traditional database will most likely still not be able to achieve the same level of in-memory performance," explains Itay Maoz, general manager of in-memory databases at AWS.

Another benefit of in-memory caching is the ability to deal with volatile workloads by helping to handle spikes in application demands. For example, if your online publication site publishes a breaking news story and everyone flocks to read it at once, it can help buffer those requests without laying the burden solely on the primary database. Having a cache will help you to to meet your customers' needs – even in unpredictable cases – without having to forecast.

Amazon Web Services (AWS) offers Amazon ElastiCache, a fully managed, in-memory caching service that is compatible with both Redis and Memcached open source engines. AWS customers often use ElastiCache to boost the performance of existing databases by reducing latency to microseconds and supporting high throughput. Including a cache for applications with microservices architecture increases performance, as it minimizes database hits and decreases network round trips. ElastiCache scales out across hundreds of caching nodes to support large numbers of application queries from many servers to meet the needs of your most demanding, internet-scale applications. ElastiCache is a remote cache, designed to deliver sub-millisecond speed and support for hundreds of millions of operations per second within a cluster.

Because ElastiCache is fully managed, it is easy to deploy, operate, and scale an in-memory data store with significant benefits over self-managed services. You don't have to worry about provisioning server resources or installing software patches. ElastiCache continuously manages memory, detects and responds to failures, and provides detailed monitoring metrics. Using ElastiCache will allow you to focus on more important application development priorities instead. In addition, ElastiCache for Redis offers two key ways to help reduce costs, auto scaling and data tiering. Autoscaling allows you to increase or decrease the size of your ElastiCache clusters automatically by selecting metrics that will trigger scaling. Data tiering is another way to lower costs which will automatically and transparently move less recently used data to locally attached NVMe (nonvolatile memory express) SSDs when there is no available memory capacity.

In 2021, AWS also launched support for ElastiCache in AWS Controllers for Kubernetes (ACK) where customers can define and use ElastiCache resources directly from their Kubernetes cluster. This can help developers take advantage of ElastiCache to support their Kubernetes applications without needing to define ElastiCache resources outside of the cluster or run and manage in-memory caching capabilities within the cluster.

Two engines for different needs

ElastiCache users can choose from two fully managed, open source, in-memory engines: Memcached and Redis, with each engine providing distinct advantages. Both offer high performance with sub-millisecond latency, ease of use, and the benefits of being a managed service, but there are key differences to consider based on your needs.

If you have a use case for simple object caching and need very high throughput, you can use ElastiCache for Memcached, a Memcached-compatible data store. Due to its simplicity, ElastiCache for Memcached is designed to handle high levels of throughput since it can scale up and use multiple processing cores to maintain low latency.

However, if your use case needs to use more complex data types, such as strings, hashes, lists, sets, sorted sets, or JavaScript Object Notation (JSON), or you want your cached data to be replicated for high availability across multiple Availability Zones (AZs) or Regions, you should use ElastiCache for Redis, a Redis-compatible, in-memory data store. ElastiCache for Redis supports this wide range of flexible Redis data types, including new native support for partial JSON document updates as well as powerful searching and filtering using the JSONPath query language.

Powering success with ElastiCache

One of the fastest-growing ride-hailing apps in Latin America, Beat reached a phase of hypergrowth in 2019 and worked with AWS to manage this success using ElastiCache for Redis. Beat is a long-time AWS customer using ElastiCache for Redis in combination with Amazon Aurora, a fully managed relational database.

Initially, Beat had been using ElastiCache with cluster mode disabled meaning that it could only scale clusters vertically. As its user base grew, Beat needed to scale horizontally so it switched its existing configuration and enabled cluster mode. With this change, the company was able to balance the traffic load among instances, significantly reducing the burden on its engineering teams. According to Beat, this resulted in a 90% reduction in compute costs and the switch also eliminated 90% of the time that its staff spent on managing the caching layer.

What other use cases are a good match for in-memory caching services like ElastiCache? Any application with a microservices architecture and compute-intensive analytical workload can benefit from a cache to help improve application performance so it is predictable, and reduce the load on the backend. Gaming leaderboards are a common use case as they are often compute-intensive, and involve large numbers of players with scores that change by the millisecond. Since ElastiCache for Redis supports sorted sets, it is able to store the data efficiently to return the top-scoring players, eliminating the need to return and sort the entire set of players in the application.

This type of configuration has been useful for The Pokémon Company International (TPCi), which is responsible for making sure Pokémon fans outside of Asia can track their achievements through full-featured user accounts in the Pokémon Trainer Club. The firm migrated to a fully managed solution on AWS using Amazon Aurora with PostgreSQL compatibility to manage the user authentication requests, and moved user caching to Amazon ElastiCache using both Redis and Memcached. ElastiCache for Redis queues tasks for new users so they can be prompted to complete post-authentication tasks, and ElastiCache for Memcached helps keep tickets live so that existing users' sessions are not interrupted when new users join. Using ElastiCache across both engines gave TPCi the ability to maximize the benefits of each, while not having to worry about doing a burdensome re-factor of its application.

Using ElastiCache in practice

As ElastiCache is a fully managed service, AWS takes care of the setup involved with deploying and managing a distributed cache environment. ElastiCache is a fully managed service meaning customers are free from worrying about the setup involved with deploying and managing a distributed cache environment as this is all managed by AWS. You can quickly provision and setup ElastiCache resources using AWS CloudFormation templates. It is also an API-accessible service that you can set up via the AWS Command Line Interface (AWS CLI), the AWS Management Console, or AWS Software Development Kit (AWS SDK). You can also define and use ElastiCache resources directly from your Kubernetes cluster using the ACK for ElastiCache. Developers can get started by downloading the container image and installing in minutes.

Customers have the ability to use ElastiCache on-demand and pay only for the time they need, down to the hour. For those that anticipate consistent usage, they can opt for reserved nodes on a one or three-year term. This offers a significant discount and reduces costs for customers who commit to these terms upfront.

ElastiCache can cache data from any type of database, relational or non-relational, and any data warehouse such as Amazon Relational Database Service, Amazon Aurora, and Amazon Redshift. Using a cache with a relational database can help deliver the ultra-fast performance of an in-memory cache, paired with the reliability of data replication and the flexibility of relational data access patterns. Non-relational databases such as Amazon DynamoDB can also be used with ElastiCache to help cache read requests for read-heavy or compute-intensive applications to boost performance and save costs. Already recognized for industry-leading scalability, data availability, security, and performance, Amazon Simple Storage Service (Amazon S3) can also benefit from using ElastiCache to further boost performance, while also helping to reduce retrieval and transfer costs.

If you want to simplify your architecture and not have to use both a cache and a database, AWS also offers another fully managed, Redis-compatible service, Amazon MemoryDB. This ultra-fast database keeps all of its data in memory, just like ElastiCache for microsecond read latency and high throughput. The difference is MemoryDB writes data to a distributed transaction log across multiple AWS Availability Zones to provide durability for fast recovery and restart. If you need a durable in-memory database, MemoryDB is the recommended choice; otherwise, use ElastiCache with your existing database for applications requiring sub-millisecond response times.

When speed is everything, using an in-memory cache is the best option to boost your application performance while keeping costs low. Building in the cloud has made this more accessible to everyone, including small businesses and teams who want to stay nimble and support their customers to use their connected devices faster than ever.

Sponsored by AWS.

Similar topics

Similar topics

Similar topics


Send us news