RDS Multi-AZ DB Instance Failover Test with node.js app with select IP Address from MySQL.

0

hello, I'm a student who want to test RDS Failover, I need to know if the Ip changes or how much time it needs to reboot RDS. My teacher said that RDS have no downtime (disaster recovery feature) then they want me to check IP + Timestamp when RDS is rebooting.

I Connect my node.js program to RDS DB with endpoint. here is the code :

const db = await mysql.createConnection({ host: 'database1.cvueeoioqbqq.us-east-1.rds.amazonaws.com', user: 'admin', password: 'admin123', database: 'ta_valen' });

and this code to get the IP from MySQL that connected to RDS DB const [rows] = await db.query(SELECT host FROM information_schema.processlist WHERE ID = CONNECTION_ID()); const ipAddress = rows[0].host.split(':')[0]; // Take IP address, Without port

Enter image description here

The IP address still same, only the port changing and some timeout.

is there any solution to test RDS failover from node.js program ? Please let me know, Thank You. Sorry for bad grammar, not My first language :) .

So, whether the IP address changes on RDS during a reboot depends on the RDS itself? Does that mean there's a possibility that when I test by rebooting the RDS, I might connect to the same instance again, which is why the IP address doesn't change ? If u have spare time can u answer my new question on here / comment ? thankyou :).

2 Answers
0
Accepted Answer

To test RDS Multi-AZ failover with your Node.js app:

  • Monitor DNS: The RDS endpoint DNS remains the same during failover, but the underlying IP address changes. Use the DNS name to connect, not the IP.

  • Failover Impact: During failover, the RDS instance switches to the standby, and you may experience a brief downtime (usually under a minute).

  • Check IP After Failover: After failover, check the new IP using your existing code. The IP address should change, while the port might also vary.

Failover will cause minimal downtime, but ensure you reconnect after failover to see the updated IP.

profile picture
EXPERT
answered 8 months ago
0

Hello.

This is not an answer to failover testing with Node.js, but it will answer things like downtime during failover.

When a failover occurs in RDS, the IP address of RDS should change as it switches to the standby instance.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html#USER_VPC.Subnets

When Amazon RDS creates a DB instance in a VPC, it assigns a network interface to your DB instance by using an IP address from your DB subnet group. However, we strongly recommend that you use the Domain Name System (DNS) name to connect to your DB instance. We recommend this because the underlying IP address changes during failover.

Additionally, there will be downtime during failover.
Normally, failover will be completed within a minute and you will be able to connect.
Therefore, if the IP address does not seem to have changed when connecting from Node.js, I think it is because you are connecting to the instance that was originally running as the primary instance during failover.
https://repost.aws/knowledge-center/rds-mysql-downtime-impact

profile picture
EXPERT
answered 8 months ago
profile picture
EXPERT
reviewed 8 months ago
  • So, whether the IP address changes on RDS during a reboot depends on the RDS itself? Does that mean there's a possibility that when I test by rebooting the RDS, I might connect to the same instance again, which is why the IP address doesn't change ? Thanks for the answer.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions