Skip to content

How to connect Sequelize to Amazon RDS correctly #6932

Closed

Description

@manuelfink

I'm using an Amazon RDS hosted MySQL with Multi-AZ Support. Just could not find any information on how to connect to Amazon RDS probably so that Sequelize is handling fail-overs accordingly?

I'm just using the following config, but do not now if this is enough?

sequelizeConfig = {
  logging: false,
  pool: { maxConnections: 5, maxIdleTime: 30},
  sequelizeConfig[dialectOptions] = {
    ssl: 'Amazon RDS'
  }
}

Can anyone confirm, this is working and maybe add docs on how to connect probably?

Using Amazon RDS two things are important:

  1. Try reconnect if connections is missing
  2. Don't cache mysql server IP-Adress too long (Amazon suggests less than 1 min)

Similar Questions

Simular questions only discuss about connection problems, but not how to connect probably

Activity

  1. anonmily commented on Dec 1, 2016

    @anonmily

    @manuelfink Whenever possible, you should avoid hard-coding IP addresses into your configuration since that can make it fragile when your server IP address changes. Instead, using a DNS/domain name can make it a bit more resilient (e.g. db1.domain.com instead of 123.456.7890).

    Managing failovers also isn't something that should be handled by Sequelize or in your code. If you're using AWS RDS, you can use automatic failovers, which can change the DNS record of the DB instance to point to the standby DB instance if it goes down. Alternatively, you could probably handle this yourself with a new EC2 instance with a load balancer (e.g. Nginx/HaProxy) and use service discovery (e.g. Consul) to manage a dynamic inventory of your healthy hosts. I haven't done this with Amazon RDS, but it should work.

    Resources:
    http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.html
    http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToInstance.html
    https://www.consul.io/intro/index.html

  2. stale commented on Jun 29, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions