{"id":18941421,"url":"https://github.com/mchmarny/distributed-echo","last_synced_at":"2026-03-23T19:30:17.704Z","repository":{"id":40291207,"uuid":"223290557","full_name":"mchmarny/distributed-echo","owner":"mchmarny","description":"Simple Broadcast/Echo service for Cloud Run designed to demonstrate authenticated inter-service connectivity and measure latency between the different regions where this service is deployed.","archived":false,"fork":false,"pushed_at":"2023-05-05T02:23:17.000Z","size":24834,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T22:42:50.295Z","etag":null,"topics":["cloudrun","golang","metrics","region","spanner","stackdriver"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mchmarny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-22T00:27:32.000Z","updated_at":"2020-01-24T23:13:37.000Z","dependencies_parsed_at":"2024-06-21T15:38:04.395Z","dependency_job_id":"5996554b-a3e3-4ac5-92b4-e29488fdc9bb","html_url":"https://github.com/mchmarny/distributed-echo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"mchmarny/grpcme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fdistributed-echo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fdistributed-echo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fdistributed-echo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Fdistributed-echo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mchmarny","download_url":"https://codeload.github.com/mchmarny/distributed-echo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239940462,"owners_count":19722023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudrun","golang","metrics","region","spanner","stackdriver"],"created_at":"2024-11-08T12:28:01.387Z","updated_at":"2026-03-23T19:30:17.660Z","avatar_url":"https://github.com/mchmarny.png","language":"Go","readme":"# distributed-echo\n\nSimple Broadcast/Echo service for Cloud Run designed to demonstrate authenticated inter-service connectivity and measure latency between the different regions where this service is deployed.\n\n![](img/diagram.png)\n\n\u003e The inter-region service invocation latency measurements do not account for the implicit \"cold starts\" of each service. You can minimize it though by creating more frequent Cloud Scheduler invocations\n\n## Pre-requirements\n\nIf you don't have one already, start by creating new project and configuring your [Google Cloud SDK](https://cloud.google.com/sdk/docs/). Also, if you have not done so already, you will have [set up Cloud Run](https://cloud.google.com/run/docs/setup).\n\n### Config\n\nAll the variables used in this service are defined in the [bin/config](bin/config) file. You can edit these to your preferred values.\n\n* `SERVICE_NAME` (default: `distributed-echo`) is the name of the service deployed into Cloud Run. Combination of this name is also used for database, schedule, and user name.\n* `SERVICE_IMAGE_VERSION` (default: `0.5.6`) is the version of the image that will be build to use in Cloud Run deployment\n* `SERVICE_REGIONS` (default: `us-central1`, `us-east1`, `europe-west1`, `asia-northeast1`) is all the regions where this service should be deployed to Cloud Run\n* `DB_REGION` (default: `regional-us-central1`) is the Spanner instance configuration value which will dictate the deployment regions (alt: `nam3`, `nam-eur-asia1`)\n* `DB_NODES` (default: `3`) is the number of Spanner nodes in created in the above defied region (see: https://cloud.google.com/spanner/docs/instances)\n\n\n## Deployment\n\n\u003e Note, to keep this readme short, I will be asking you to execute scripts rather than listing here complete commands. You should review each one of these scripts for content. This will also help you understand the individual commands so you can use them in the future.\n\nFirst, start by creating IAM user and granting that user all the necessary roles.\n\n```shell\nbin/setup\n```\n\nNext, setup the Spanner instance and a DB\n\n```shell\nbin/db\n```\n\nWith IAM account created and Spanner DB configured, the only thing that we are missing is the container image. You can build that image using the [bin/image](bin/image) script:\n\n```shell\nbin/image\n```\n\nWith the image built, you can now deploy the Cloud Run service to all the regions defined in the [bin/config](bin/config) using using [bin/deploy](bin/deploy) script:\n\n```shell\nbin/deploy\n```\n\nFinally, use the [bin/schedule](bin/schedule) script to crate one Cloud Schedule \"cron\" per each service\n\n```shell\nbin/schedule\n```\n\n## Metrics\n\nYou can monitor the metrics created by this service in one of two ways:\n\n### SQL Query Spanner Database\n\nThe schema of the Spanner DB holding the metrics from this service is defined in the [bin/db](bin/db):\n\n```sql\nCREATE TABLE pings (\n    id STRING(MAX) NOT NULL,\n    target STRING(MAX) NOT NULL,\n    source STRING(MAX) NOT NULL,\n    sent TIMESTAMP NOT NULL,\n    completed TIMESTAMP NOT NULL,\n    duration INT64 NOT NULL\n) PRIMARY KEY (id)\n```\n\nYou can query it using SQL\n\n![](img/db.png)\n\n### Stackdriver Time Series\n\nThis service also records each \"echo\" ping in Stackdriver as a custom time series metric (`custom.googleapis.com/metric/echo-latency`)\n\n![](img/metric.png)\n\nYou can group that series by the `source` and `target` labels to get a detail chart of the latency in between regions\n\n![](img/chart.png)\n\n## Cleanup\n\nTo cleanup all resources created by this sample execute\n\n```shell\nbin/cleanup\n```\n\n## Disclaimer\n\nThis is my personal project and it does not represent my employer. I take no responsibility for issues caused by this code. I do my best to ensure that everything works, but if something goes wrong, my apologies is all you will get.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmchmarny%2Fdistributed-echo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmchmarny%2Fdistributed-echo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmchmarny%2Fdistributed-echo/lists"}