Skip to content

TMS Read-replica

Deployment environment Stable Nightly
Project pg-databases-stable pg-databases-nightly
Instance name pg-1-stable-read-replica pg-1-nightly-read-replica
IP address 35.228.188.117 34.88.147.165

The SQL database instance pg-1-nightly houses all databases for all customers, not just Taksi Helsinki. This article only touches upon TMS-related Read-replica information.

Google Cloud SQL Read-replicas have been created for TMS to provide better performance for big queries and especially to help with processing the quantity of queries that is going to increase with Taksi Helsinki's Kela rides.

Management and configuration

The read-replica is managed with Terraform. Any changes should be written by using the Terraform configurations here: https://github.com/Attracs/terraform-gcp-pg-read-replica.

Configuration

In order for the programs to use the new read-replica, it has to be implemented in code. For this purpose, the service-account cloud-sql-proxy@att-nightly.iam has been given the following IAM permissions: * Cloud SQL Instance User * Cloud SQL Client to connect via Google's Cloud SQL Auth Proxy to the database instance. Additionally in the database instance, a new database user has been created called tms_fleet_nightly_replica with the following permissions inside of tms_fleet_nightly database: * psql -U "miro.salo@aholadigital.com" -h 127.0.0.1 -p 55439 -d tms_fleet_nightly

tms_fleet_nightly=*> GRANT USAGE ON SCHEMA public to tms_fleet_nightly_replica; 
tms_fleet_nightly=*> GRANT CONNECT ON tms_fleet_nightly TO tms_fleet_nightly_replica;
tms_fleet_nightly=*> GRANT SELECT ON ALL TABLES IN SCHEMA public TO tms_fleet_nightly_replica;