{"id":15349785,"url":"https://github.com/asifdxtreme/chassis-apollo-example","last_synced_at":"2026-05-10T08:40:46.279Z","repository":{"id":57568442,"uuid":"139998134","full_name":"asifdxtreme/chassis-apollo-example","owner":"asifdxtreme","description":null,"archived":false,"fork":false,"pushed_at":"2018-07-09T10:23:25.000Z","size":364,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T13:24:08.998Z","etag":null,"topics":["apollo","configuration-management","demo","go-chassis","microservice"],"latest_commit_sha":null,"homepage":null,"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/asifdxtreme.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-07-06T14:57:57.000Z","updated_at":"2020-08-11T11:27:06.000Z","dependencies_parsed_at":"2022-08-28T07:42:27.136Z","dependency_job_id":null,"html_url":"https://github.com/asifdxtreme/chassis-apollo-example","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/asifdxtreme%2Fchassis-apollo-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifdxtreme%2Fchassis-apollo-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifdxtreme%2Fchassis-apollo-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asifdxtreme%2Fchassis-apollo-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asifdxtreme","download_url":"https://codeload.github.com/asifdxtreme/chassis-apollo-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241596276,"owners_count":19988044,"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":["apollo","configuration-management","demo","go-chassis","microservice"],"created_at":"2024-10-01T11:55:43.837Z","updated_at":"2026-05-10T08:40:46.224Z","avatar_url":"https://github.com/asifdxtreme.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chassis-Apollo Example\n\nThis is a example illustrates the integration of go-chassis with Ctrip Apollo Configuration Center.\n\n### Objective\nThis examples showcases the following things:\n1. Start Ctrip Apollo and make Projects, NameSpace and Configurations.\n2. Configure chassis.yaml to use Apollo Configuration Server.\n3. Use Apollo to dynamically change configurations of chassis.\n4. Configure the QPS limit for microservices by using Apollo.\n\n\n#### Quick start Apollo\n\nEasiest way to bring up Apollo configuration is using docker compose.\n\n```go\ngit clone https://github.com/ctripcorp/apollo $GOPATH/src/github.com/ctripcorp/apollo\n\ncd $GOPATH/src/github.com/ctripcorp/apollo/scripts/docker-quick-start\n\ndocker-compose up\n```\nThis brings up the Apollo, follow the below steps to configure the project and namespace.\n\n- Login to Apollo \n![Apollo Login](images/Login-Apollo.png)  \nBy default the credentials is user is apollo/admin  \n- Create a new Project  \n![](images/NewProject.png)  \nCreate a new project called ***apollo-integration*** which we will use through out this example.  \n![](images/Apollo-Integration.png)  \n- Note all the details regarding Project Name, AppID, NameSpace, ClusterName.  \n![](images/Project-Page.png)  \n- Add a new Configurations  \n![](images/AddNewConfig.png)  \nOnce config is added you need to release the config so that it will be available to outside components.  \n![](images/ReleaseConfig.png)  \n  \n#### Configure the chassis.yaml\nYou need to configure the chassis.yaml for both the client and server to use Apollo as the configurations server. (By default we have added these configurations to this example in client and server).\n```go\ncse:\n  config:\n    client:\n      serverUri: http://127.0.0.1:8080          # This should be the address of your Apollo Server\n      type: apollo                              # The type should be Apollo\n      refreshMode: 1                            # Refresh Mode should be 1 so that Chassis-pulls the Configuration periodically\n      refreshInterval: 10                       # Chassis retrives the configurations from Apollo at this interval\n      serviceName: apollo-integration           # This the name of the project in Apollo Server\n      env: DEV                                  # This is the name of environment to which configurations belong in Apollo\n      cluster: apollo                           # This is the name of cluster to which your Project belongs in Apollo\n      namespace: application                    # This is the NameSpace to which your configurations belong in the project.\n```\n\n#### Running the Client and Server \nClient and Server in this example can be run on the same machine\n- Start the Service-Center\n```go\ndocker run -d -p 30100:30100 servicecomb/service-center\n```  \n- Get Chassis\n```go\ngo get github.com/ServiceComb/go-chassis\n```\n- Start the Client\n```go\ncd client\ngo build\n./client\n```\n- Start the Server\n```go\ncd server\ngo build\n./server\n```\n- Verify the Communication between client and server\n```go\n$ curl -v http://127.0.0.1:8085/greet/asif\n*   Trying 127.0.0.1...\n* TCP_NODELAY set\n* Connected to 127.0.0.1 (127.0.0.1) port 8085 (#0)\n\u003e GET /greet/asif HTTP/1.1\n\u003e Host: 127.0.0.1:8085\n\u003e User-Agent: curl/7.58.0\n\u003e Accept: */*\n\u003e \n\u003c HTTP/1.1 200 OK\n\u003c Date: Sun, 08 Jul 2018 15:45:41 GMT\n\u003c Content-Length: 30\n\u003c Content-Type: text/plain; charset=utf-8\n\u003c \n* Connection #0 to host 127.0.0.1 left intact\nuser user asif from 95 from 62\n```\n\n#### Change the Configurations of Chassis dynamically using Apollo\n\n##### QPS Limit\n- Test the QPS using AB tool without setting any QPS limit(don't judge this data for the performance of any component)  \n```go\n$ ab -n 1000 -c 1 http://127.0.0.1:8085/greet/asif\nThis is ApacheBench, Version 2.3 \u003c$Revision: 1807734 $\u003e\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\nLicensed to The Apache Software Foundation, http://www.apache.org/\n\nBenchmarking 127.0.0.1 (be patient)\nCompleted 100 requests\nCompleted 200 requests\nCompleted 300 requests\nCompleted 400 requests\nCompleted 500 requests\nCompleted 600 requests\nCompleted 700 requests\nCompleted 800 requests\nCompleted 900 requests\nCompleted 1000 requests\nFinished 1000 requests\n\n\nServer Software:        \nServer Hostname:        127.0.0.1\nServer Port:            8085\n\nDocument Path:          /greet/asif\nDocument Length:        30 bytes\n\nConcurrency Level:      1\nTime taken for tests:   1.187 seconds\nComplete requests:      1000\nFailed requests:        0\nTotal transferred:      147000 bytes\nHTML transferred:       30000 bytes\nRequests per second:    842.60 [#/sec] (mean)\nTime per request:       1.187 [ms] (mean)\nTime per request:       1.187 [ms] (mean, across all concurrent requests)\nTransfer rate:          120.96 [Kbytes/sec] received\n```  \nThe current QPS is 842.  \n- Now let's set the QPS to 100 dynamically using Apollo.\n\nGo to ***apollo-integration*** project and add a new configuration in ***application*** namespace.  \n![](images/AddQPSLimit.png)  \nRelease this configuration.  \nNow using the same ab tool to benchmark the api.\n```go\n$ ab -n 1000 -c 1 http://127.0.0.1:8085/greet/asif\nThis is ApacheBench, Version 2.3 \u003c$Revision: 1807734 $\u003e\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\nLicensed to The Apache Software Foundation, http://www.apache.org/\n\nBenchmarking 127.0.0.1 (be patient)\nCompleted 100 requests\nCompleted 200 requests\nCompleted 300 requests\nCompleted 400 requests\nCompleted 500 requests\nCompleted 600 requests\nCompleted 700 requests\nCompleted 800 requests\nCompleted 900 requests\nCompleted 1000 requests\nFinished 1000 requests\n\n\nServer Software:        \nServer Hostname:        127.0.0.1\nServer Port:            8085\n\nDocument Path:          /greet/asif\nDocument Length:        30 bytes\n\nConcurrency Level:      1\nTime taken for tests:   9.891 seconds\nComplete requests:      1000\nFailed requests:        0\nTotal transferred:      147000 bytes\nHTML transferred:       30000 bytes\nRequests per second:    101.10 [#/sec] (mean)\nTime per request:       9.891 [ms] (mean)\nTime per request:       9.891 [ms] (mean, across all concurrent requests)\nTransfer rate:          14.51 [Kbytes/sec] received\n\n```  \nNow you can see the QPS is 101, so here we were able to change the configuration of your microservices dynamically without restarting or changing anything in your microservice. ***Awesome***\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasifdxtreme%2Fchassis-apollo-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasifdxtreme%2Fchassis-apollo-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasifdxtreme%2Fchassis-apollo-example/lists"}