I am building an architecture on AWS with several EC2 instances as webservers and a central MySQL database (RDS). The EC2 instances have Redis installed for caching single db rows. When a row changes in MySQL, I want every instance to update the corresponding cache entries too.
What is the best way to do this in the AWS enviroment?
If you are using a queue server (amazon SQS, redis pubsub, etc) you could put an entry onto a queue for each record you want expired, and have a worker listening to the queue and when it gets a message to tell it which record to invalidate it will connect to cache and expire that record.
This works if you have one cache server or many, you just need one worker for each cache server that you have, or one worker that can connect to each cache server. Many workers is more scalable.