RDS Postgres Read Replica Source Database Setup

So I’m currently setting up a system in AWS RDS where we are using a postgres database. Rather than connecting to the main database, I was thinking of creating a read replica to use as the source database for cubejs. However it seems that the following things are true:

  • No one can write to a postgres read replica under any circumstances
  • By default, CubeJS wishes to write to the source database (which is currently the read replica)
  • We can turn the readOnly option on, but we are working with large production workloads and the warning states

“Read only pre-aggregations are only suitable for small datasets since they require loading all the data into Cube.js process memory. We do not recommend using readOnly mode for production workloads.”

It seems that the only way is instead of using the RDS read replica is to use AWS DMS to create a full replica of the database and then use that as the source db. Is that correct? Or is there a simpler way that someone has figured out to do this? Would it be better to just hook it up to our main db or would the throughput be more likely to crash everything? Or just turn readOnly on?

Any and all help is appreciated. Thank you!

Hi @PIELIKEI :wave:

It’s a great idea to use Postgres read replica with Cube.js. It would help separate analytical and transactional workloads. We have a user story with Jobber that does the same (please see the schema in the blog post).

Let me check with the team if using readOnly: true with Postgres will indeed affect the performance of pre-aggregation creation. I’ll get back to you later.

I assume that you’re planning to store pre-aggregations in Cube Store which is the recommended way for production. Also, please feel free to sign up for the pre-aggregation workshop by the link above.

1 Like

@PIELIKEI We’ve already implemented the support for efficient pre-aggregation data download from Postgres even if it’s running in read-only mode. So, feel free to use the latest Cube.js and try it yourself. We’ll change the warning soon.