{"id":20491186,"url":"https://github.com/bgadrian/pseudoservice","last_synced_at":"2025-04-13T16:40:41.778Z","repository":{"id":50712614,"uuid":"155417604","full_name":"bgadrian/pseudoservice","owner":"bgadrian","description":"A (micro) service that generates large amounts of fake data (users, json, yaml, ecommerce ...)","archived":false,"fork":false,"pushed_at":"2018-12-06T11:21:17.000Z","size":3708,"stargazers_count":17,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T15:53:36.118Z","etag":null,"topics":["fake","faker","go","golang","json","microservice","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bgadrian.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}},"created_at":"2018-10-30T16:16:14.000Z","updated_at":"2024-05-15T12:07:26.000Z","dependencies_parsed_at":"2022-09-18T08:51:09.897Z","dependency_job_id":null,"html_url":"https://github.com/bgadrian/pseudoservice","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fpseudoservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fpseudoservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fpseudoservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgadrian%2Fpseudoservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bgadrian","download_url":"https://codeload.github.com/bgadrian/pseudoservice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248746761,"owners_count":21155325,"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":["fake","faker","go","golang","json","microservice","yaml"],"created_at":"2024-11-15T17:20:21.604Z","updated_at":"2025-04-13T16:40:41.752Z","avatar_url":"https://github.com/bgadrian.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pseudo service ![travis-mater](https://travis-ci.com/bgadrian/pseudoservice.svg?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/bgadrian/pseudoservice)](https://goreportcard.com/report/github.com/bgadrian/pseudoservice)  [![contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/bgadrian/pseudoservice/issues)\n\nPseudo random (deterministic) data generator as a (micro) service.\nIt is a wrapper for the [FastFaker Go package](https://github.com/bgadrian/fastfaker).\n\n#### The problem\nThe need to generate random (user or other type) data, to mockup, test or stress  your own systems. \n\n#### The solution\nI've built this project to be used as an internal service, to generate large amounts of fake data.\n\n### Performance \nTo run your own benchmarks see [call_benchmark.sh](./call_benchmark.sh). For the best performance I recommend the following:\n* Count (batch) value: **100**\n* concurrent requests: CPUCores * 1.5\n\n#### Benchmarks\nTests done on Pseudoservice 2.0.0 using ApacheBench 2.3 `ab -n 8000 -c 6 -kdq -m GET  http://localhost:8080/users/100?token=SECRET42`. The tests ignore any network latency, does not unmarshall the response, reuses HTTP connections (keep-alive) and were made from the local machine (where pseudoservice was running), meaning you will have **at least a 20% lower performance** in a real-world scenario.\n\n* **t2.micro** (~1 CPU), AWS Linux\n```bash\n  Time taken for tests:   7.649 seconds\n  Complete requests:      8000\n  Requests per second:    1045.86 [#/sec] (mean)\n  Time per request:       5.737 [ms] (mean)\n  Time per request:       0.956 [ms] (mean, across all concurrent requests)\n  Transfer rate:          45236.55 [Kbytes/sec] received\n  Translation: 45Mb/s fake data = 104500 fake users/s\n```\n* **t2.xlarge** (~4 CPU), AWS Linux\n```bash\n    Time taken for tests:   2.825 seconds\n    Requests per second:    2832.02 [#/sec] (mean)\n    Time per request:       2.119 [ms] (mean)\n    Time per request:       0.353 [ms] (mean, across all concurrent requests)\n    Transfer rate:          122314.75 [Kbytes/sec] received\n    Translation: 122Mb/s fake data =  283200 users/s\n```\n* **c5.2xlarge**\t(~8 CPU), AWS Linux\n```bash\n    Time taken for tests:   2.035 seconds\n    Total transferred:      353697150 bytes\n    HTML transferred:       352137150 bytes\n    Requests per second:    3931.71 [#/sec] (mean)\n    Time per request:       1.526 [ms] (mean)\n    Time per request:       0.254 [ms] (mean, across all concurrent requests)\n    Transfer rate:          169755.12 [Kbytes/sec] received\n    Translation: 170Mb/s fake data = 393100 users/s\n```\n\n### How it works\n\nYou run it as a simple HTTP server, in a private network, and the clients can make requests to get random data, based on their custom templates/needs.\n\nGlobal optional parameters:\n* `?seed=42` - if given, the result will be deterministic, as in for all calls the same data will be returned.\n* `token=SECRET42` - the APIKEY\n* `{count}` - how many results should be generated, integer [1,500]\n\n### Endpoints (data types)\n\n##### /docs \nContains the OpenID/swagger documentation for this API.\n\n##### /health\nReturns `200` if the service is available.\n\n##### /custom/{count}?template=\"Hello \u0026#126;name\u0026#126;!\"\nGenerate random data based on a given template. Supports any string, including JSON schema.\n\nThe template can contains variables like `~name~` or `~email~`. For a full list see the [FastFaker variables](https://github.com/bgadrian/fastfaker/blob/master/TEMPLATE_VARIABLES.md), but instead of `{}` you must use the `~` delimiter (it is more URL friendly).\n\n```bash\n#the template is URL encoded: Hello ~name~!\ncurl -X GET \"http://localhost:8080/custom/3?token=SECRET42\u0026seed=42\u0026template=Hello%20~name~%21\"\n{\"results\":[\n    \"Hello Jeromy Schmeler!\",\n    \"Hello Kim Steuber!\",\n    \"Hello Jacky Borer!\"\n],\"seed\":42}\n\n#template: {name:\"~name~\",age:~digit~~digit~}\ncurl -X GET \"http://localhost:8080/custom/3?token=SECRET42\u0026seed=42\u0026template=%22%7Bname%3A%22~name~%22%2Cage%3A~digit~%7D%22\"\n{\"results\":[\n    \"\\\"{name:\\\"Jeromy Schmeler\\\",age:53}\\\"\",\n    \"\\\"{name:\\\"Dustin Jones\\\",age:62}\\\"\",\n    \"\\\"{name:\\\"Keely Hartmann\\\",age:12}\\\"\"\n],\"seed\":42}\n\n#template: ~country~\ncurl -X GET \"http://localhost:8080/custom/6?token=SECRET42\u0026seed=42\u0026template=~country~\"\n{\"results\":[\n    \"Tajikistan\",\n    \"Cameroon\",\n    \"Cote Divoire\",\n    \"Turkmenistan\",\n    \"Ethiopia\",\n    \"Afghanistan\"\n],\"seed\":42}\n``` \n\nFor more examples see the FastFaker [examples](https://github.com/bgadrian/fastfaker/tree/master/example) and [GoDoc](https://godoc.org/github.com/bgadrian/fastfaker/faker#pkg-examples).\n\n##### /users/{count}\nGenerate random users based on a preconfigured set of properties, with a friend relationship between them.\n\nThis endpoint was created to simulate a Social network and test a Graph database: [davidescus/10minFor300Gb](https://github.com/davidescus/10minFor300Gb).\n\n```bash\n#fast and random user\ncurl \"http://localhost:8080/api/v1/users/1?token=SECRET42\"\n{\"seed\":6124420007038740542,\"nextseed\":0,\"users\":[\n    {\n        \"id\":\"a4419f4f-f7f9-4c99-a746-5799b281a5d6\",\"\n        age\":209,\n        \"name\":\"Jonas Borer\",\n        \"company\":\"core frictionless Inc\",\n        \"position\":\"Senior Paradigm Associate\",\n        \"email\":\"JonasBorer@leadsolutions.org\",\n        \"country\":\"Yemen\"\n    }\n]}\n\n#slower but deterministic call (seed=42)\ncurl \"http://localhost:8080/api/v1/users/1?token=SECRET42\u0026seed=42\"\n\n{\"seed\":42,\"nextseed\":43,\"users\":[\n    {\"\n        id\":\"538c7f96-b164-4f1b-97bb-9f4bb472e89f\",\n        \"age\":62,\n        \"name\":\"Jacky Borer\",\n        \"company\":\"Ameliorated mindshare Inc\",\n        \"position\":\"International Assurance Orchestrator\",\n        \"email\":\"JackyBorer@leadsolutions.org\",\n        \"country\":\"Greece\"\n    }\n]}\n```\n\n### How to install\n\na). Download the [binaries from a Release](https://github.com/bgadrian/pseudoservice/releases)\n```bash\nwget https://github.com/bgadrian/pseudoservice/releases/download/v2.0.0/pseudoservice.tar.gz\ntar -xzf pseudoservice.tar.gz\n./pseudoservice/linux/pseudoservice --api-key=SECRET42 --read-timeout=1s --write-timeout=1s --keep-alive=15s --listen-limit=1024 --max-header-size=3KiB --host=0.0.0.0 --port=8080\n```\n\nOR b). Get the [docker image from bgadrian/pseudoservice/](https://hub.docker.com/r/bgadrian/pseudoservice/)\n```bash\ndocker run --name pseudoservice -p 8080:8080 -d -e APIKEY=MYSECRET bgadrian/pseudoservice\ncurl \"http://localhost:8080/api/v1/users/1?token=MYSECRET\u0026seed=42\"\n\n```\n\nOR c). Hard way, requires Go 1.11, make and git\n```bash\ngit clone git@github.com:bgadrian/pseudoservice.git\ncd pseudoservice\n\nmake run\n#OR\nmake build\nenv PORT=8080 ./build/pseudoservice\n```\n\n### How to use\n\nThe binary has the following env variables:\n* `PORT` - http listening port (8080)\n* `APIKEY` - secret string to be served at `?token=SECRET42` \n* for more see `pseudoservice --help`\n\nThe server accepts `gzip` and it was generated using swagger (open API), to see a full documentation of the service access the [127.0.0.1:8080/docs](http://127.0.0.1:8080/docs) endpoint.\n\n### TODO\nAll the [issues](https://github.com/bgadrian/pseudoservice/issues)\n\n### Copyright\nBledea Georgescu Adrian https://coder.today\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgadrian%2Fpseudoservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbgadrian%2Fpseudoservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgadrian%2Fpseudoservice/lists"}