#CloudGuruChallenge: Improve application performance using Amazon ElastiCache
Gain the AWS and Python skills needed to implement a database cache using Redis (and get swag/a LinkedIn endorsement) with this month's #CloudGuruChallenge.
Jun 08, 2023 • 4 Minute Read
What’s the #CloudGuruChallenge? Get some more info over here.
Challenge Topic | Improve application performance using Amazon ElastiCache |
Challenge Creator | David Thomas |
Challenge Goal | Implement a Redis cluster using Amazon ElastiCache to cache database queries in a simple Python application. |
Challenge Outcome | Gain AWS and Python skills needed to implement a database cache using Redis. |
Challenge Deadline | July 31, 2021 |
Prerequisites
AWS Free Tier account
- https://aws.amazon.com/free
- If you are already an ACG member, you can utilize the Cloud Playground.
Python
- Python version 3.6 or higher
- https://www.python.org/downloads/
- Should be installable via OS packaging on most distributions.
Github (Optional)
- https://github.com/
- The application code will be stored on GitHub, but no account is required for read-only access.
The Challenge Steps
Database
- Deploy an RDS PostgreSQL database instance. The free tier db.t2.micro instance should be plenty.
- You should also create a database and database user account. You will need these when configuring the application.
- Bonus points if you deploy the Amazon RDS instance using a CloudFormation or Terraform template.
Application
- Deploy an EC2 instance. Again, the free tier should be sufficient,
- Install python3 along with the psycopg2, flask, configparser and Redis modules.
- Download application code from GitHub here: https://github.com/ACloudGuru/elastic-cache-challenge
- Configure the application to connect to your database instance as instructed in the README.md and give it a test run.
- Access the page a few times and make note of the page load times.
- Please note, the stored procedure called by the application has been artificially slowed to represent an under-provisioned database server. The goal of this challenge is to add a cache in front of the database, not to optimize the stored procedure.
Cache
- Deploy ElastiCache Redis cluster. This can be done manually or automated using your choice of tools and templates.
- Ensure that the Redis cluster is only accessible from the application EC2 instance.
- Alter the application, check the Redis cache before querying the database. If a cache miss occurs, query the database and update the cache with the results.
- Give the patched application a test run. Make sure to access the page multiple times making note of the runtime.
Blog Post
- Write a short blog post explaining your learnings and your approach to the challenge. Be sure to include why you took the challenge, what your biggest takeaways are, and the pre- and post-cache page load times.
When You’re Done
You can complete the project requirements by yourself or in collaboration with others. Feel free to ask questions in the ACG Discord server (there’s a specific channel for this challenge) or on social media using the #CloudGuruChallenge hashtag!
When you finish all the steps of the project, post a link to your blog post in the designated Discord channel. I will then be able to endorse you on LinkedIn for the skills you demonstrated in this project: Amazon ElastiCache, Python. You’ll also be entered to win some cool swag and get a special shoutout from the A Cloud Guru LinkedIn account after the challenge!
Most importantly, the #CloudGuruChallenge is FREE and available to everyone!
Resources
Be prepared to do some Googling, but if you are an ACG member, here are some resources that can help you get more comfortable with Python and AWS:
If you aren’t already an ACG member, we encourage you to sign up for a free account (no credit card required) to get started and explore a selection of free courses that are rotated each month.
Extra-Challenging Steps
You don't need to perform these additional steps to “declare victory” on the challenge, but they will help your project stand out and provide awesome additional learning.
- Create a PR on github
- Create a Pull Request on GitHub with the changes you made.
- RDS instance as code
- Deploy the RDS instance using a CloudFormation or Terraform template to define the instance as code.
Final Takeaways
While the application used for this challenge was intentionally made slow, the skills learned completing this challenge are also useful for real-world applications.
It's not always possible to tune the database for optimum performance — for instance, when using a third-party application that doesn't allow access to the database. In these cases, being able to externally cache database results can greatly increase performance and allow you to scale to meet increasing workloads.
Being able to demonstrate hands-on knowledge of these technologies will be a real asset when it comes interview time as you're trying to get a cloud job.
Get the skills needed for a better career.
Master modern tech skills, get certified, and level up your career. Whether you’re starting out or a seasoned pro, you can learn by doing and advance your career in cloud with ACG.