I'm working with a single endpoint in my EC2 application that decides actions based on the XML structure of incoming requests. When the root element is ``, it reads data, and when it's ``, it writes data. I must keep this setup as it is. Currently, I read from a Redis cache while writing to RDS MariaDB, and then regenerate the Redis cache. I'm considering moving the reading part to a Lambda function using Node.js while keeping the writing on EC2. One of my colleagues insists this is impossible and says we need to rewrite everything to Lambda, which seems like a huge hassle and would take about six months. I believe adding a caching layer could be done in a matter of weeks. Can anyone confirm whether my approach is feasible?
2 Answers
Absolutely, you can achieve this without a full rewrite! Honestly, I'm not sure why your colleague thinks it's impossible. If you design the routing correctly, you can split the responsibilities between Lambda and EC2 without any issues. You've got options, like using Lambda@Edge or API Gateway to manage those read/write decisions effectively. It sounds like a solid plan to me.
It sounds like you want to keep your existing endpoint structure, which is definitely doable! You can introduce a new routing Lambda function that will inspect the incoming requests. If the request is a read (``), it can forward that to a second Lambda function for reading. If it's a write (``), it can direct it to the EC2 instance. Using something like API Gateway can help you set this up to match your current architecture. Also, as mentioned, using CloudFront might be an alternative way to manage the routing, which could simplify the process and minimize the need to change client behaviors.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String