title: Spring Boot and AWS RDS Read Replica
body: <p>Here I am trying to achieve the below in AWS RDS. I have a MySQL database instance running. I am thinking of creating a read replica so that I will have some extra load sharing capabilities.</p>
  
  <p>I have a Spring Boot application running on EC2. Currently the way I connect to the database is by adding the below properties in the application.yml:</p>
  
  <pre><code>datasource:
      type: com.zaxxer.hikari.HikariDataSource
      url: jdbc:mysql://DB_HOSTNAME:3306/DB_DATABASE?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC
      username: DB_USERNAME
      password: DB_PASSWORD
  </code></pre>
  
  <p>My question is: </p>
  
  <ul>
  <li>If I create a read replica, do I need to write some special code to connect to it?</li>
  <li>Do I need multiple connection pools one for each instance of the database?</li>
  <li>How is this scalable from code perspective, if I have 5 read replicas, how do I manage this in code?</li>
  <li>How do I direct my database calls to different replicas? What is the basis of this decision?</li>
  </ul>
  
  <p>If there is any link/video/documentation you can point me to. Spring boot is not a necessity, I need to understand what is a good way to utilize my read replicas from a Java application. </p>
  
  <p>Thanks</p>