{"_id":"575147c78e9ef90e0083e9a2","project":"56a1f77442dfda0d00046285","version":{"_id":"56a1f77542dfda0d00046288","__v":9,"project":"56a1f77442dfda0d00046285","createdAt":"2016-01-22T09:33:41.397Z","releaseDate":"2016-01-22T09:33:41.397Z","categories":["56a1f77542dfda0d00046289","56a1fdf442dfda0d00046294","56a2079f0067c00d00a2f955","56a20bdf8b2e6f0d0018ea84","56a3e78a94ec0a0d00b39fed","56af19929d32e30d0006d2ce","5721f4e9dcfa860e005bef98","574e870be892bf0e004fde0d","5832fdcdb32d820f0072e12f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":13,"parentDoc":null,"user":"56a1f7423845200d0066d71b","category":{"_id":"56af19929d32e30d0006d2ce","pages":["56af19d9bc304a0d00ace0de"],"project":"56a1f77442dfda0d00046285","version":"56a1f77542dfda0d00046288","__v":1,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-01T08:38:42.993Z","from_sync":false,"order":6,"slug":"abou","title":"About"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-03T09:03:03.652Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"## What is an infrastructure?\n\nA group of services/applications that belong together logically or functionally.\n\nInfrastructure = Product\nInfrastructure != Application\nInfrastructure != Service\n\n### Use cases where services belong together\n\n- services depending on each other *(communicating with each other)*\n- they are the part of a same product *(user service, payment service etc.)*\n- in a microservices architecture\n- in a service oriented architecture (SOA)\n\n### Grouping Recommendations\n\n- create separate infrastructures for your staging and production systems\n- create separate infrastructures for each of your products\n\n### Naming recommendations\n\n- My Product Name Staging\n- My Product Name Production\n\n## What is a service?\n\nA service is a group of processes doing the same thing.\n\nService = Application\nService = Heroku application\nService = Same code running on different instances\nService = Same Docker container running on different machines\n\n## How to handle processes with different purposes (web, worker, clock)?\n\nAt some provides (eg. Heroku) it’s not possible to define different environment variables for different processes created from the same code base - like web, worker, clock .\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/qu5oTooQpg7Zribk83Sg_Screen%20Shot%202016-06-03%20at%2011.16.53.png\",\n        \"Screen Shot 2016-06-03 at 11.16.53.png\",\n        \"493\",\n        \"263\",\n        \"#a5807b\",\n        \"\"\n      ],\n      \"caption\": \"Multiple processes running with same environment variables\"\n    }\n  ]\n}\n[/block]\nIn this case, we recommend to configure Trace by using [environment variables](https://trace-docs.risingstack.com/docs/getting-started#section-4-run-your-app) and applying the following trick for your processes:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// owerwrite TRACE_SERVICE_NAME with environment variable\\nif (process.env.TRACE_SERVICE_NAME_WEB) {\\n\\tprocess.env.TRACE_SERVICE_NAME = process.env.TRACE_SERVICE_NAME_WEB\\n}\\n\\nrequire(':::at:::risingstack/trace')\",\n      \"language\": \"javascript\",\n      \"name\": \"web.js\"\n    },\n    {\n      \"code\": \"// owerwrite TRACE_SERVICE_NAME with environment variable\\nif (process.env.TRACE_SERVICE_NAME_WORKER) {\\n\\tprocess.env.TRACE_SERVICE_NAME = process.env.TRACE_SERVICE_NAME_WORKER\\n}\\n\\nrequire('@risingstack/trace')\",\n      \"language\": \"javascript\",\n      \"name\": \"worker.js\"\n    },\n    {\n      \"code\": \"web: node web.js\\nworker: node worker.js\",\n      \"language\": \"text\",\n      \"name\": \"Procfile\"\n    }\n  ]\n}\n[/block]\nThe idea behind the code snippet is to configure your Trace service name with the `TRACE_SERVICE_NAME` environment variable instead of the `trace.config.js` what is shared between your processes. This way it can be easily overwritten before you load trace.","excerpt":"Follow this guide while naming your infrastructures and services in Trace","slug":"how-to-name-your-infrastructure-and-services","type":"basic","title":"How to name your infrastructure and services"}

How to name your infrastructure and services

Follow this guide while naming your infrastructures and services in Trace

## What is an infrastructure? A group of services/applications that belong together logically or functionally. Infrastructure = Product Infrastructure != Application Infrastructure != Service ### Use cases where services belong together - services depending on each other *(communicating with each other)* - they are the part of a same product *(user service, payment service etc.)* - in a microservices architecture - in a service oriented architecture (SOA) ### Grouping Recommendations - create separate infrastructures for your staging and production systems - create separate infrastructures for each of your products ### Naming recommendations - My Product Name Staging - My Product Name Production ## What is a service? A service is a group of processes doing the same thing. Service = Application Service = Heroku application Service = Same code running on different instances Service = Same Docker container running on different machines ## How to handle processes with different purposes (web, worker, clock)? At some provides (eg. Heroku) it’s not possible to define different environment variables for different processes created from the same code base - like web, worker, clock . [block:image] { "images": [ { "image": [ "https://files.readme.io/qu5oTooQpg7Zribk83Sg_Screen%20Shot%202016-06-03%20at%2011.16.53.png", "Screen Shot 2016-06-03 at 11.16.53.png", "493", "263", "#a5807b", "" ], "caption": "Multiple processes running with same environment variables" } ] } [/block] In this case, we recommend to configure Trace by using [environment variables](https://trace-docs.risingstack.com/docs/getting-started#section-4-run-your-app) and applying the following trick for your processes: [block:code] { "codes": [ { "code": "// owerwrite TRACE_SERVICE_NAME with environment variable\nif (process.env.TRACE_SERVICE_NAME_WEB) {\n\tprocess.env.TRACE_SERVICE_NAME = process.env.TRACE_SERVICE_NAME_WEB\n}\n\nrequire('@risingstack/trace')", "language": "javascript", "name": "web.js" }, { "code": "// owerwrite TRACE_SERVICE_NAME with environment variable\nif (process.env.TRACE_SERVICE_NAME_WORKER) {\n\tprocess.env.TRACE_SERVICE_NAME = process.env.TRACE_SERVICE_NAME_WORKER\n}\n\nrequire('@risingstack/trace')", "language": "javascript", "name": "worker.js" }, { "code": "web: node web.js\nworker: node worker.js", "language": "text", "name": "Procfile" } ] } [/block] The idea behind the code snippet is to configure your Trace service name with the `TRACE_SERVICE_NAME` environment variable instead of the `trace.config.js` what is shared between your processes. This way it can be easily overwritten before you load trace.