# Design Recommendations ## Assumptions Since `pre_approved` is `true`, the following assumptions govern these design recommendations: - The workload is deployed regionally in a low-carbon region (a region with CFE% >= 75%) to meet sustainability goals. - Cloud SQL for PostgreSQL is configured in a high-availability (multi-zone) topology to meet the 99.9% uptime requirement, avoiding cross-region replication. - Cloud Run handles the compute scaling, scaling down to 0 instances outside of business hours to optimize costs. - The Corporate Identity Provider integrates with Identity-Aware Proxy (IAP) to authenticate users at the load balancer. - All application and operational logs are stored in a centralized Google Cloud Storage bucket locked for 365 days. ## Security, privacy, and compliance To enforce a zero-trust model and meet security, privacy, and compliance requirements, the architecture implements several layers of defense: - **Identity-Aware Proxy (IAP)**: Protects the Cloud Run service by authenticating corporate users at the external load balancer before traffic reaches the application (DR-2). - **Network Security**: The Load Balancer enforces a custom SSL policy restricting traffic to TLS 1.2+ (DR-1). The Cloud Run service itself restricts ingress to `internal-and-cloud-load-balancing` so it cannot be accessed directly via the public internet (DR-3). Outbound traffic from Cloud Run is routed strictly through the VPC using Direct VPC Egress (DR-4). - **Least Privilege and Secrets**: Cloud Run operates using a dedicated, user-managed service account (DR-5) with permissions limited to accessing necessary secrets from Secret Manager (DR-8) and connecting to the database. These secrets are injected dynamically into the runtime environment (DR-9). - **Database Security**: Cloud SQL is isolated from the public internet by disabling public IPv4 and connecting via Private Service Connect/VPC peering (DR-6). It enforces IAM authentication and SSL/TLS connections (DR-7). - **Compliance Logging**: To meet the 365-day immutable audit log requirement, a Cloud Logging sink routes all audit events to a dedicated Cloud Storage bucket configured with a 365-day retention policy (DR-10). ## Reliability High availability and disaster recovery are essential to meeting the 99.9% uptime and RTO/RPO requirements: - **High Availability**: Cloud SQL for PostgreSQL is configured for regional high availability, maintaining a synchronous standby replica in a secondary zone to allow automatic failover during a disruption (DR-11). - **Disaster Recovery**: Automated daily backups are retained for at least 7 days, and Point-in-Time Recovery (PITR) is enabled via Write-Ahead Logging (WAL) to guarantee an RPO of 1 hour or less (DR-12). - **Health Checking**: The load balancer utilizes backend health checks to continuously monitor the health of the Cloud Run instances, routing traffic away from degraded containers (DR-13). ## Operational excellence Operations are streamlined through comprehensive observability and automated alerting: - **Monitoring and Alerting**: Cloud Monitoring captures metrics across all components. Alert policies are specifically configured to trigger when Cloud Run HTTP 5xx error rates exceed 1% over a 5-minute window, and when Cloud SQL CPU or storage utilization exceeds 80% (DR-16). - **Centralized Logs**: All system metrics, application logs, and traces are centralized within Google Cloud's operations suite for rapid incident response. ## Cost optimization The architecture leverages serverless characteristics to align cloud spend with active business usage: - **Scale to Zero**: Cloud Run is configured with a minimum instance count of 0, ensuring that compute resources scale down entirely during off-hours, weekends, and periods of inactivity, drastically reducing idle costs (DR-14). - **Right-sized Database**: While high availability is required, autoscaling storage ensures that database disk space is only paid for when consumed. ## Performance efficiency Sub-second page loads and transactional consistency are maintained through optimized storage and networking: - **Database Performance**: Cloud SQL is provisioned with high-throughput SSD storage and automatic storage expansion to maintain low-latency read/write operations for booking transactions without hitting IOPS ceilings (DR-15). - **Connection Optimization**: By using VPC-native private connections and keeping all traffic within the same region, network latency between Cloud Run and Cloud SQL is minimized. ## Sustainability Environmental impact is mitigated by selecting the right region and eliminating idle resource waste: - **Low-Carbon Region**: All resources are deployed in a region with a Carbon-Free Energy (CFE) score of 75% or higher, directly lowering the gross carbon emissions of the workload (DR-17). - **Dynamic Scaling**: Utilizing Cloud Run's scale-to-zero capabilities (DR-14) ensures that the application does not consume power for idle compute instances outside of business hours.