.. _install_sandboxes_load_reporting_service: Load reporting service (LRS) ============================ .. sidebar:: Requirements .. include:: _include/docker-env-setup-link.rst This simple example demonstrates Envoy's :ref:`Load reporting service (LRS) ` capability and how to use it. Lets say Cluster A (downstream) talks to Cluster B (Upstream) and Cluster C (Upstream). When enabling Load Report for Cluster A, the LRS server should be sending ``LoadStatsResponse`` to Cluster A with ``LoadStatsResponse.Clusters`` to be B and C. The LRS server will then receive ``LoadStatsRequests`` (with total requests, successful requests etc) from Cluster A to Cluster B and from Cluster A to Cluster C. In this example, all incoming requests are routed via Envoy to a simple Golang web server named ``http_server``. We scale up two containers and randomly send requests to each. Envoy is configured to initiate the connection with the LRS Server. The LRS Server enables stats by sending ``LoadStatsResponse``. Sending requests to ``http_server`` are counted towards successful requests and will be visible in the LRS Server logs. Step 1: Build the sandbox ************************* Change to the ``load-reporting-service`` directory. Terminal 1 :: $ pwd examples/load-reporting-service $ docker compose pull $ docker compose up --scale http_service=2 Terminal 2 :: $ pwd examples/load_reporting_service $ docker compose ps Name Command State Ports ----------------------------------------------------------------------------------------------------------------- load-reporting-service_http_service_1 /docker-entrypoint.sh /usr ... Up 10000/tcp, 0.0.0.0:81->80/tcp load-reporting-service_http_service_2 python3 /code/service.py ... Up (healthy) load-reporting-service_lrs_server_1 go run main.go Up Step 2: Start sending stream of HTTP requests ********************************************* Terminal 2 :: $ pwd examples/load_reporting_service $ bash send_requests.sh The script above (:download:`send_requests.sh <_include/load-reporting-service/send_requests.sh>`) sends requests randomly to each Envoy, which in turn forwards the requests to the backend service. Step 3: See Envoy Stats *********************** You should see Terminal 1 :: ............................ lrs_server_1 | 2020/02/12 17:08:20 LRS Server is up and running on :18000 lrs_server_1 | 2020/02/12 17:08:23 Adding new cluster to cache `http_service` with node `0022a319e1e2` lrs_server_1 | 2020/02/12 17:08:24 Adding new node `2417806c9d9a` to existing cluster `http_service` lrs_server_1 | 2020/02/12 17:08:25 Creating LRS response for cluster http_service, node 2417806c9d9a with frequency 2 secs lrs_server_1 | 2020/02/12 17:08:25 Creating LRS response for cluster http_service, node 0022a319e1e2 with frequency 2 secs http_service_2 | 127.0.0.1 - - [12/Feb/2020 17:09:06] "GET /service HTTP/1.1" 200 - http_service_1 | 127.0.0.1 - - [12/Feb/2020 17:09:06] "GET /service HTTP/1.1" 200 - ............................ lrs_server_1 | 2020/02/12 17:09:07 Got stats from cluster `http_service` node `0022a319e1e2` - cluster_name:"local_service" upstream_locality_stats: total_successful_requests:21 total_issued_requests:21 > load_report_interval: lrs_server_1 | 2020/02/12 17:09:07 Got stats from cluster `http_service` node `2417806c9d9a` - cluster_name:"local_service" upstream_locality_stats: total_successful_requests:17 total_issued_requests:17 > load_report_interval: http_service_2 | 127.0.0.1 - - [12/Feb/2020 17:09:07] "GET /service HTTP/1.1" 200 - http_service_1 | 127.0.0.1 - - [12/Feb/2020 17:09:07] "GET /service HTTP/1.1" 200 - ............................ lrs_server_1 | 2020/02/12 17:09:09 Got stats from cluster `http_service` node `0022a319e1e2` - cluster_name:"local_service" upstream_locality_stats: total_successful_requests:3 total_issued_requests:3 > load_report_interval: lrs_server_1 | 2020/02/12 17:09:09 Got stats from cluster `http_service` node `2417806c9d9a` - cluster_name:"local_service" upstream_locality_stats: total_successful_requests:9 total_issued_requests:9 > load_report_interval: .. seealso:: :ref:`Load reporting service ` Overview of Envoy's Load reporting service. :ref:`Load reporting service API(V3) ` The Load reporting service API.