{"id":15354728,"url":"https://github.com/thedodd/tscale-challenge","last_synced_at":"2025-06-13T14:04:46.273Z","repository":{"id":73855285,"uuid":"174207980","full_name":"thedodd/tscale-challenge","owner":"thedodd","description":null,"archived":false,"fork":false,"pushed_at":"2019-03-11T20:43:39.000Z","size":2137,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T17:31:21.822Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thedodd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-06T19:33:18.000Z","updated_at":"2022-10-06T17:51:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"68299bc9-9c4f-447b-90dd-53424f7aa5f7","html_url":"https://github.com/thedodd/tscale-challenge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Ftscale-challenge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Ftscale-challenge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Ftscale-challenge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Ftscale-challenge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thedodd","download_url":"https://codeload.github.com/thedodd/tscale-challenge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128753,"owners_count":20888235,"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":[],"created_at":"2024-10-01T12:20:43.452Z","updated_at":"2025-04-04T06:14:41.407Z","avatar_url":"https://github.com/thedodd.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"timescale challenge\n===================\nA CLI tool for the Timescale code challenge.\n\nThe main objective of this tool is to \"measure the processing time of each query and output benchmark stats once all queries have been run. In particular, we are looking for the # of queries run, the total processing time across all queries, the minimum query time (for a single query), the median query time, the average query time, and the maximum query time.\n\n**Benchmark output needs to include:**\n- num of queries run.\n- the total processing time across all queries.\n- the minimum query time (for a single query).\n- the median query time.\n- the average query time.\n- the maximum query time (for a single query).\n\n**Queries have the following constraints:**\n- Each query must return \"the max cpu usage and min cpu usage of the given hostname for every minute in the time range specified by the start time and end time\".\n- Each query should be executed by a concurrent worker.\n- Queries for the same hostname must be executed by the same worker each time (though, a single worker may execute for multiple hosts).\n\n**The architecture of this CLI is as follows:**\n- A central controller is used to parse each query param record.\n- Controller dispatches the query param to the appropriate worker for the host based on a simple map. It uses channels to send the query param to the worker.\n- A new worker is spun up per hostname.\n- Workers report their work results to a collector which will calculate the benchmark output.\n\n### setup\nThis project uses [Go modules](https://github.com/golang/go/wiki/Modules).\n\nData used for this challenge is [located here](https://www.dropbox.com/s/17mr38w21yhgjjl/TimescaleDB_coding_assignment-RD_eng_setup.tar.gz?dl=1). The data has been committed to this repo for ease of access under the `challenge-data` directory.\n\nWe are using Docker Compose for easily managing the lifecycle of the TimeScaleDB instance.\n\n#### run timescaledb\nIf you don't already have `docker` or `docker compose` setup on your system, please follow the installation instructions outlined on [Docker's website](https://docs.docker.com/install/#supported-platforms).\n\nOnce you have docker ready to go, simply issue the following command from this repo's root directory to start the database:\n\n```bash\n# Boot the database.\ndocker-compose up -d\n```\n\nAll of the databases data will be held in a volume called `timescaledb`. If you need to clear the data and start with a fresh volume: `docker-compose down -v`. Then simply boot the database back up again, and you should have a fresh disk to work with.\n\n##### psql access\nYou can log into the timescaledb instance any time by using the following command:\n\n```bash\n# Get shell access to postgres.\ndocker-compose exec timescaledb psql -U postgres\n```\n\n#### setup challenge data\n- First, ensure that your timescaledb instance is running as described above.\n- Execute `docker-compose exec timescaledb psql -U postgres -f /etc/challenge-data/cpu_usage.sql` from the root of this repo. When docker-compose booted our timescaledb instance, it mounted the `challenge-data` to the container under `/etc`. This command will simply run the sql script.\n- Lastly, execute `docker-compose exec timescaledb psql -U postgres -d homework -c \"\\COPY cpu_usage FROM /etc/challenge-data/cpu_usage.csv CSV HEADER\"` from the root of this repo. This will populate our `cpu_usage` hypertable with the challenge data.\n\n#### execute the cli\n```bash\n# This will build \u0026 run the program.\ngo run main.go -f challenge-data/query_params.csv\n\n# You can also specify `-w` to specify the number of workers to spawn.\ngo run main.go -f challenge-data/query_params.csv -w 5\n\n# For more help on running the program, use --help.\ngo run main.go --help\n```\n\n**PLEASE NOTE:** if you are having compiler issues with your dependencies, you probably need to ensure that Go modules are enabled. Check out the basic [troubleshooting info here](https://github.com/golang/go/wiki/Modules#what-are-some-general-things-i-can-spot-check-if-i-am-seeing-a-problem).\n\nHere is an example of what the output will look like after running the program:\n\n```bash\n$ go run main.go -f challenge-data/query_params.csv -w 2\n\n### Main Benchmarks\nTotal processing time:      751.64178ms\nNumber of queries executed: 200\nMin Query Time:             2.345231ms\nMax Query Time:             7.853057ms\nMedian Query Time:          3.079777ms\nAverage Query Time:         3.758208ms\n\nDone.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedodd%2Ftscale-challenge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedodd%2Ftscale-challenge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedodd%2Ftscale-challenge/lists"}