1. 程式人生 > >Automating SQL Caching for Amazon ElastiCache and Amazon RDS

Automating SQL Caching for Amazon ElastiCache and Amazon RDS

Our guest bloggers are from Heimdall Data, an AWS partner that offers “DBA assistant” tools (you can find them in the AWS Marketplace). These tools include automated caching that combines Amazon ElastiCache for Redis with relational databases, including MySQL, MariaDB, PostgreSQL, Oracle, and Microsoft SQL Server. Let them step you through how to use their tools to automate the creation and management of a Redis query cache using

ElastiCache and Amazon RDS (or Amazon Aurora).

Slow-performing applications reduce user engagement and customer satisfaction, and eventually lower revenue. Application-database inefficiency (for example, network latency or slow queries) is a primary cause of performance bottlenecks. This post shows how Heimdall Data’s auto-caching solution with ElastiCache improves performance with no code changes, while preventing stale cache data.

Background
Various database systems provide different features and performance. Systems such as Amazon Aurora provide dynamic scaling and performance. Another AWS Database Blog post covers horizontal (more servers) and vertical (larger servers) scaling and the trade-offs. Database scaling can be costly, especially for commercially licensed databases.

Others have used Amazon ElastiCache to improve responsiveness. Despite the simplicity of ElastiCache, developers are still challenged to know what to cache and what to invalidate, and to ensure that all data is up to date. This requires manual application code changes and database modifications.

We can now automate caching and invalidation in ElastiCache with the Heimdall Data SQL caching solution.

Architecture
The Heimdall Data Access Platform (HDAP) has two components: the Heimdall Central Manager (HCM), and the Heimdall Data Access Layer (HDAL). The Heimdall system is an intelligent query routing and caching data access layer that is installed in a distributed way on each Amazon EC2 instance.

Heimdall Data software packaging includes the following:

  • Database Proxy for Amazon RDS: Aurora, MySQL, SQL Server 2008+, PostgreSQL
  • JDBC Driver: Gives access to Oracle and any other JDBC-compliant database

For deployment, the only application-level change is to modify the host and port or JDBC URL to route through the Heimdall proxy/driver. The following is a sample architecture diagram for the MySQL proxy configuration:

In proxy mode (the focus of this article), there are two modes of deployment:

  • Distributed mode: A proxy resides on each Amazon EC2 application instance, for optimal performance (shown in the preceding diagram).
  • Centralized mode: One Amazon EC2 instance proxy services many application servers.

The proxy provides two levels of caching: 1) locally on the application server, and 2) on ElastiCache (akin to an L1/L2 cache). As SQL is sent from the application to the database, the proxy responds from the cache and routes requests to different servers (for use in load-balancing and read/write split). All this functionality is provided by Heimdall Data, requiring zero code changes.

Prerequisites
This post covers how the Heimdall system with Amazon ElastiCache and Amazon RDS can be deployed with an existing application. You can find a demo instance on the Heimdall Data website.

If you’re testing with your own infrastructure, the following is required:

Script installation of the Heimdall system
If you’re installing Heimdall via the one-line installation process, it downloads and installs the newest Heimdall Central Manager and Proxy. The default user ID is admin. If an Amazon instance is successfully detected, the password is the instance ID. Otherwise, the default password is heimdall.

Example overview
The example uses an Aurora database that supports a WordPress application. To explore a live site without setting up your own infrastructure, see the Heimdall Live Demo page. Role-based security prevents modifications to the site, but you can explore all features that are provided with the sample application setup. Testing in your own environment requires configuring an instance as detailed earlier.

Getting started
Once the Heimdall Central Manager (HCM) is running on an instance, the web-based configuration interface is accessible with the server URL and port 8087 (see the live demo). For an already configured server, the default tab is the Status tab, which displays current server and system status. For a new installation, go to the Wizard tab.

Using the wizard to configure data sources
Heimdall has a configuration wizard designed for Amazon Web Services. On the Wizard tab, choose AWS Detect. Otherwise, choose Manual Configuration. The goal is to configure information on the database system and caching infrastructure.

If you see a screen requesting AWS IAM credentials, you can add these credentials in this window or add the credentials to the instance as an IAM instance role through the AWS interface. Then, choose AWS Detect again.

Step 1. The Amazon RDS cluster and ElastiCache for Redis are automatically populated once they are detected. In the drop-down list, choose the appropriate Amazon RDS cluster and ElastiCache cluster. If you don’t have an ElastiCache for Redis instance available, you can leave this blank, and later, choose the local cache option. After completing these steps, choose Next.

Step 2. Specify the database server and connection type. This includes the host name, driver, user name, password, and port:

Step 3. Provide the cache configuration. Amazon ElastiCache for Redis is automatically detected in this example.

Step 4. The next screen provides settings on logging and the use of a proxy and advanced settings. If the database is to be used as a proxy (e.g., MySQL, PostgreSQL), then select Enable Proxy and choose a proxy port.

Step 5. The summary confirmation screen allows you to change any of these settings before creating the configuration.

Choose Next, and the system provides a summary of important items to verify to ensure that the application can use the configuration.

After you choose Submit on this final page (which is customized for your setup), the configuration is updated. On the demo system, guest users receive a warning indicating that they can’t update the server configuration. Browsing the configuration tabs provides information about how the system works.

Step 6. The Virtual Databases tab provides connection information for the application. In this case, the application accesses via MySQL proxy on localhost. If you’re using your own instance, make any changes to this information, and then choose Commit to finalize the configuration.

You can also change cache settings on the Virtual Databases tab:

Step 7. The Data Sources tab provides the database connection information and settings, such as connection pooling, load balancing, high availability, and query routing (read/write split). Make sure that this tab has the information for the Amazon RDS or Aurora instance that you want to cache, and then choose Commit to finalize the database configuration.

Step 8. The Rules tab controls how queries are cached, routed, and transformed when they are received from the application. The default rules configuration is to cache all traffic that is not in transactions, forward selected traffic to a read-only source, and log query traffic. You can change rules dynamically at any time without restarting the application or database. For information about how the rules are configured, choose Help. If you’re using your own instance, make any changes to this information, and then choose Commit to finalize the rule configuration.

Step 9. When you’re configuring the application to use the Heimdall proxy, the only required change to an existing application is to change the database configuration that it uses to access the database to match the Heimdall proxy. In the MySQL demo example, the existing MySQL configuration in WordPress was changed to 127.0.0.1:3306. This change is usually straightforward, but it is specific to your application installation. For details on the URL to use for the Heimdall JDBC Driver, see the JDBC section of the Virtual Database details, or for the proxy, in the Proxy Configuration section.

Step 10. The dashboard provides information about query traffic and server performance. For the sample instance, the WordPress site is being accessed with a generated traffic load. Notice in the performance statistics how the average query time for traffic coming from the cache is about 50 microseconds compared to 1000 microseconds from the database. By deploying caching in this application, there is a data layer performance boost of over 20 times!

Other statistics collected include information about the cache hit rate and the query traffic for each server. With an over 90 percent cache hit rate, the load on the database is reduced significantly, allowing for more users to be supported on the same database infrastructure. There were no changes to the application besides the database URL/host + port change—so no coding or database system changes were required.

Conclusion
Heimdall Data automates caching for Amazon ElastiCache. Configuration is simple with zero disruption to the application or the Amazon RDS or Aurora database. Users experience up to 5x improvement in performance and scale.

Heimdall is available as a free trial on the AWS Marketplace. It can also be downloaded at the Heimdall Data website.

Resources and links

About the Author

Darin Briskman (@briskmad) is a technical evangelist at Amazon Web Services. He works with our customers to provide guidance and technical assistance on database projects, helping them improving the value of their solutions when using AWS.

相關推薦

Automating SQL Caching for Amazon ElastiCache and Amazon RDS

Our guest bloggers are from Heimdall Data, an AWS partner that offers “DBA assistant” tools (you can find them in the AWS Marketplace). These tool

Analyze and visualize your VPC network traffic using Amazon Kinesis and Amazon Athena

Network log analysis is a common practice in many organizations.  By capturing and analyzing network logs, you can learn how devices on your netwo

Discovering and indexing podcast episodes using Amazon Transcribe and Amazon Comprehend 

As an avid podcast listener, I had always wished for an easy way to glimpse at the transcript of an episode to decide whether I should add it to m

New – Amazon Connect and Amazon Lex Integration

I’m really excited to share some recent enhancements to two of my favorite services: Amazon Connect and Amazon Lex. Amazon Connect is a self-servi

Amazon ElastiCache for Redis

Duolingo is the free, science-based, language education platform that has organically become the most popular way to learn languages online

Amazon Athena – Interactive SQL Queries for Data in Amazon S3

The amount of data that we all have to deal with grows every day (I still keep a floppy disk or two around in order to remind myself that 1.44 MB

Amazon ElastiCache for Redis FAQs

Q: What is Amazon ElastiCache for Redis? Amazon ElastiCache for Redis is a web service that makes it easy to deploy and run Redis pr

Prepare Environment for Working with AWS CLI and Amazon DynamoDB on Amazon EC2

Amazon Web Services is Hiring. Amazon Web Services (AWS) is a dynamic, growing business unit within Amazon.com. We are currently hiring So

Speeding up WordPress with Amazon ElastiCache for Memcached

WordPress is a popular open-source Content Management System (CMS) that lets developers build sophisticated websites. WordPress makes it easy to

PyTorch 1.0 preview now available in Amazon SageMaker and the AWS Deep Learning AMIs

Amazon SageMaker and the AWS Deep Learning AMIs (DLAMI) now provide an easy way to evaluate the PyTorch 1.0 preview release. PyTorch 1.0 adds seam

Apple and Amazon deny report they were hit by one of the most damaging hacks ever

A new report claims that China managed to spy on large swathes of the world by smuggling tiny computer chips into electronic hardware used to power iPhones

Segmenting brain tissue using Apache MXNet with Amazon SageMaker and AWS Greengrass ML Inference

In Part 1 of this blog post, we demonstrated how to train and deploy neural networks to automatically segment brain tissue from an MRI scan in a s

British security services speak out over claims China planted tiny chips in Apple and Amazon computers

British security services have spoken out about claims that China managed to plant tiny chips in computers that made their way across the US. The bombshell

Freeing up the sales force for selling, listening and automating with AI

Sales strategy and the future of customer engagement is in my DNA. As we all see and know, agility, automation and artificial intelligence is changing the

Facebook Login Using AWS Amplify and Amazon Cognito

Set up auth with Facebook Login in our iOS appWe are now going to cloud-enable our mobile app by adding Facebook metdata to our info.plist, AWS Mobile SDK

Migrate to Apache HBase on Amazon S3 on Amazon EMR: Guidelines and Best Practices

This blog post provides guidance and best practices about how to migrate from Apache HBase on HDFS to Apache HBase on Amazon S3 on Amazon EMR.

In Using AWS Amplify and Amazon Cognito

Integrate the awsconfiguration.json file into your iOS projectWhen using the AWS Amplify CLI to provision backend resources, it produces a file called awsc

Microsoft and Amazon workers protest firms' military AI contract and 'authoritarian surveillance' tech

Employees at Amazon and Microsoft have raised concerns about ethical decisions being made at the highest level of their companies. Both tech firms have dra

How SimilarWeb analyze hundreds of terabytes of data every month with Amazon Athena and Upsolver

This is a guest post by Yossi Wasserman, a data collection & innovation team leader at Similar Web. SimilarWeb, in their own words: Si

time bushfire alerting with Complex Event Processing in Apache Flink on Amazon EMR and IoT sensor network | AWS Big Data Blog

Bushfires are frequent events in the warmer months of the year when the climate is hot and dry. Countries like Australia and the United States are