Archive · GCP

GCP Services: Cloud SQL, Pub/Sub and Cloud Monitoring

A managed database, a message bus and alerts, with the gcloud commands to start.

1 min read

  • Cloud SQL
  • Pub/Sub
  • Cloud Monitoring
  • Cloud Logging

Cloud SQL runs MySQL, PostgreSQL and SQL Server with backups and high availability.

gcloud sql instances create shop-db --database-version=POSTGRES_16 \
  --region=asia-south1 --tier=db-custom-2-7680 --availability-type=REGIONAL \
  --backup-start-time=21:00 --enable-point-in-time-recovery --no-assign-ip \
  --network=app-vpc

Use the Cloud SQL Auth Proxy or private IP from applications, never an open public address.

Pub/Sub is Google’s pub/sub messaging (similar to SNS plus SQS):

gcloud pubsub topics create orders
gcloud pubsub subscriptions create orders-worker --topic=orders --ack-deadline=60 \
  --dead-letter-topic=orders-dlq --max-delivery-attempts=5
gcloud pubsub topics publish orders --message='{"id":1}'

Cloud Monitoring and Logging collect metrics and logs from Google services automatically. Install the Ops Agent on VMs for memory, disk and file logs:

curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh
sudo bash add-google-cloud-ops-agent-repo.sh --also-install

Create alerting policies (for example CPU above 80 percent for 10 minutes, or Cloud Run 5xx rate) with a notification channel for email or Slack, and a log-based metric for application errors.