# RDS(Relational DB Service)

There is Amazon RDS for installing specific DB

The only thing you need to do its managing schema and managing the data. Amazon doesn't touch data

You do need to provision scale

Use an EBS Volume as Storage

See Aurora for AWS managed

Can host multiple databases and such on one instance

## Connection

Need host, port, and username and password to connect with some dbtool like tableplus and pgadmin

* For postgres
  * Host: diced-digital.cy7uscwdupos.us-east-2.rds.amazonaws.com
  * Port: default
  * username and password in configuration tab, with password able to be reset
  * Need to update security group(its in EC2) and set it to all inbound rules on 0.0.0.0/0(default isn't enough)

Code connects also need database name

Also need to modify RDS security in the RDS settings to allow external access, then select the RDS security group, change the security group inbound rules to allow all traffic from all sources PostgresSQL.

## Creation

Set admin user and password. Set in

1. Select Engine(aurora, mysql, postgres)
2. use case: high availbility or cheaper
3. DB Details: size , initial settings about username and password
4. Advanced: VPC, Security, Encryption, backup, monitoring, logs

Read Replicas node

Secondary Host would handle load in case of failure}

* No charge for backups up to 100%
* Encryption at rest free, done at volume level with RDS connecting with KMS so app changes

#### Multi-AZ(Avaliability Zones)

* allow great availiability during maintence and fails
* fallover takes about 1-2 minutes
* Writes go to both and twice the cost
* Backups improved

#### Read Replicas

* part of instance and only handle read queries to offload traffic from main
* "eventually consistent" so writes on primary, then asyncronously updates the replica, so query could get stale data
* Check replication lag in the replication tab of the master
* Create from the options of any database instance, promote to a standalone instance from the options of the replica thing(irreversible)

#### Automated Backups

EBS has a snapshot stored everyday, incremental snapshots only store difference, brief I/o suspension to uptown few minutes

Transaction Logs are then stored every 5 minutes so you can then get your db to any pt in time :0

**Restoring Snapshot**

Must create a new instance

Snapshots can be sent to new region

### Scaling

Vertical scale by modifying db to add storage or instance type(downtime), multi-az has minimal downtime

* t2.small to medium took about 5 minutes, multi a-z had about a minute of downtime as fallover kicked in

Horizontal scale by adding read replicas


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openai.gitbook.io/code-cheatsheets/deployment/aws/storage/rds.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
