Using ProxySQL to Replace Deprecated MySQL 8.0 Query Cache
Optimising Amazon Aurora/RDS MySQL 8.0 performance by using ProxySQL to replace deprecated Query Cache
This Blog was co-authored together with Pengfei Zhang, Senior Solutions Architect, AWS.
- Query Optimization: Enhance SQL queries and indexes to minimize execution time and resource usage.
- External Caching Solutions: Utilize Amazon Elasticache or Redis as an in-memory data structure store. Serving as both a cache and message broker, these tools can significantly reduce database load by offloading frequently accessed data, thereby improving access speeds and overall application performance.
- Database Performance Tuning: Changing certain MySQL database parameters to make the database more performant. Parameter tuning differs depending on the workloads that the database faces.
- Client Applications connecting to ProxySQL Servers via the Internal Network Load Balancer (NLB).
- Internal NLB that routes traffic to a HA deployment of ProxySQL Servers
- ProxySQL Servers redirect traffic to Aurora Reader/Writer Endpoints via ProxySQL Read/Write Split.
- Aurora Reader Endpoint forwards requests to the Aurora Reader Instances, while the Aurora Writer Endpoint will forward requests to the Aurora Writer Instance

- ProxySQL in HA: 2 x r7g.large = 156.4 USD
- NLB (10TB Data, 1000 TCP Conn / s, 60s/TCP Connection) = 79.84 USD
- We deployed the setup in our Github Repo and used the Sysbench Instance to conduct the benchmark
- We ensure that NLB sticky session were turned on to ensure maximum cache hits on 1 ProxySQL cache.


- If you test ProxySQL and find that ProxySQL daemon CPU Utilisation is >200%, try increasing the threads to match how many threads your instance can support.
- Set ProxySQL cache size to a safe memory amount and tune it according to your workload. You can start with about 50%-75% of the EC2 instance and decrease/increase depending on how much memory other processes consume on your EC2 instance. You are strongly advised to leave some extra memory room on the CPU instance to be safe.
- ProxySQL is best used for workloads with the following use cases:
- No requirement of strong consistency between cache and database
- High number of similar queries
- For maximum availability, but increased cost, you can run multiple ProxySQL instances in an autoscaling group, set to scale out horizontally.
- Ensure that you test ProxySQL in a non-production environment with equivalent production workload and simulated failure injections to ensure HA capabilities are set up correctly.
- ProxySQL can only invalidate caches with TTL.
- Prepared Statements are not cached.
- In this solution, NLB Sticky Sessions are used to use only 1 ProxySQL Server for maximum cache hit ratio. The tradeoff is that in the event of a server failure, all the traffic will be routed over to the other server. For most workload, if the instance is right-sized, this will not cause much issue because of ProxySQL multiplexing. Slightly higher latency will be observed initially after failover due to the cold cache becoming populated with query data.
Pengfei Zhang is a Senior Solutions Architect in Singapore Startups, providing architectural consultations to diverse early and scale-up AWS customers. He has recently guided priority customers through successful migrations to MySQL 8.0, specifically addressing and mitigating performance issues related to the absence of the Query Cache feature. He is specialized in Serverless and AIML technology domains.
Quinn is an Associate Solutions Architect specialising in Databases. He works with APJ customers on Database related subjects such as Query Optimisation and Database Migrations, while helping them fine-tune their Data Strategy on AWS. He works mainly on RDS and Aurora Postgres related challenges.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.