Skip to content

Commit

Permalink
2139 analytics read replica (#518)
Browse files Browse the repository at this point in the history
* feat[api]: remove field provider_clone in CeramicCache

* feat[infra]: adding read replica for analytics
  • Loading branch information
nutrina authored Feb 7, 2024
1 parent 92a69aa commit 7095e22
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
38 changes: 38 additions & 0 deletions infra/prod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,41 @@ const readreplica0 = new aws.rds.Instance(
{ protect: true }
);

const analyticsDbParameterGroup = new aws.rds.ParameterGroup('analytics-parameter-group', {

family: 'postgres13', // The family should match the DB engine version
parameters: [ // A list of DB parameters you want to set
{
name: 'max_standby_archive_delay',
value: '900',
},
{
name: 'max_standby_streaming_delay',
value: '900',
},
],
});

const readreplica1 = new aws.rds.Instance(
"scorer-db-read-analytics",
{
allocatedStorage: 130,
maxAllocatedStorage: 500,
instanceClass: "db.t3.xlarge",
skipFinalSnapshot: true,
vpcSecurityGroupIds: [db_secgrp.id],
deletionProtection: true,
// backupRetentionPeriod: 5, - this is not supported for read replicas running PostgreSQL versions lower than 14
replicateSourceDb: postgresql.id,
performanceInsightsEnabled: true,
tags: {
name: "scorer-db-read-analytics",
},
parameterGroupName: analyticsDbParameterGroup.name,
},
{ protect: true }
);

//////////////////////////////////////////////////////////////
// Setup RDS PROXY
//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -292,6 +327,9 @@ export const rdsConnectionUrl = pulumi.secret(
export const readreplica0ConnectionUrl = pulumi.secret(
pulumi.interpolate`psql://${dbUsername}:${dbPassword}@${readreplica0.endpoint}/${dbName}`
);
export const readreplica1ConnectionUrl = pulumi.secret(
pulumi.interpolate`psql://${dbUsername}:${dbPassword}@${readreplica1.endpoint}/${dbName}`
);

export const rdsId = postgresql.id;

Expand Down
40 changes: 40 additions & 0 deletions infra/staging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,45 @@ const postgresql = new aws.rds.Instance(
{ protect: true }
);

const analyticsDbParameterGroup = new aws.rds.ParameterGroup(
"analytics-parameter-group",
{
family: "postgres13", // The family should match the DB engine version
parameters: [
// A list of DB parameters you want to set
{
name: "max_standby_archive_delay",
value: "900",
},
{
name: "max_standby_streaming_delay",
value: "900",
},
],
}
);

const readreplica1 = new aws.rds.Instance(
"scorer-db-read-analytics",
{
allocatedStorage: 130,
maxAllocatedStorage: 500,
engine: "postgres",
instanceClass: "db.t3.micro",
skipFinalSnapshot: true,
vpcSecurityGroupIds: [db_secgrp.id],
deletionProtection: true,
// backupRetentionPeriod: 5, - this is not supported for read replicas running PostgreSQL versions lower than 14
replicateSourceDb: postgresql.id,
performanceInsightsEnabled: true,
tags: {
name: "scorer-db-read-analytics",
},
parameterGroupName: analyticsDbParameterGroup.name,
},
{ protect: false }
);

//////////////////////////////////////////////////////////////
// Setup RDS PROXY
//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -255,6 +294,7 @@ const scorerDefaultProxyTarget = new aws.rds.ProxyTarget(

export const scorerDbProxyEndpoint = scorerDbProxy.endpoint;
export const rdsEndpoint = postgresql.endpoint;
export const rdsAnalyticsEndpoint = postgresql.endpoint;
export const rdsArn = postgresql.arn;
export const rdsConnectionUrl = pulumi.secret(
pulumi.interpolate`psql://${dbUsername}:${dbPassword}@${scorerDbProxyEndpoint}/${dbName}`
Expand Down

0 comments on commit 7095e22

Please sign in to comment.