From 470659ea849097d7a4626e9a2f885f068ab421a1 Mon Sep 17 00:00:00 2001 From: Loong Date: Mon, 12 Aug 2024 09:51:00 +0800 Subject: [PATCH] add dlb examples Signed-off-by: Loong --- dlb/dlb_example_config.yaml | 45 ++++++++++++++++ dlb/example.rst | 105 ++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 dlb/dlb_example_config.yaml create mode 100644 dlb/example.rst diff --git a/dlb/dlb_example_config.yaml b/dlb/dlb_example_config.yaml new file mode 100644 index 00000000..e6961d31 --- /dev/null +++ b/dlb/dlb_example_config.yaml @@ -0,0 +1,45 @@ +static_resources: + listeners: + - address: + socket_address: + address: 0.0.0.0 + port_value: 10000 + connection_balance_config: + extend_balance: + name: envoy.network.connection_balance.dlb + typed_config: + "@type": type.googleapis.com/envoy.extensions.network.connection_balance.dlb.v3alpha.Dlb + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + codec_type: AUTO + stat_prefix: ingress_http + route_config: + name: local_route + virtual_hosts: + - name: backend + domains: + - "*" + routes: + - match: + prefix: "/" + route: + cluster: service1 + http_filters: + - name: envoy.filters.http.router + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router + + clusters: + - name: service1 + load_assignment: + cluster_name: service1 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 12000 diff --git a/dlb/example.rst b/dlb/example.rst new file mode 100644 index 00000000..3bbd311d --- /dev/null +++ b/dlb/example.rst @@ -0,0 +1,105 @@ +.. _install_sandboxes_dlb: + +DLB +=== + +By enabling connection balancer in Envoy you can balance the connections across the threads and improve performance. + +This sandbox provides an example about how to enable DLB connection balanace. + +.. note:: + Please run below command to check your CPU supports DLB: + + .. code-block:: console + + $ lspci -d :2710 + + You should get output like below: + + .. code-block:: text + + 5a:00.0 Co-processor: Intel Corporation Device 2710 + 6b:00.0 Co-processor: Intel Corporation Device 2710 + 7c:00.0 Co-processor: Intel Corporation Device 2710 + 8d:00.0 Co-processor: Intel Corporation Device 2710 + + The output that is not empty means CPU supports DLB. The number and PCIE address of DLB devices vary from CPU to CPU. + + The minimum support kernel version is 5.15. + +Step 1: Install DLB Driver +************************** + +You can download the DLB driver release tarball from the `DLB website `_. + +To install it refer to `the getting started guide `_. + +Step 2: Run Envoy with DLB connection balanace enabled +****************************************************** + +With the example configuration Envoy listens on port 10000 and proxies to an upstream server listening on port 12000. + +.. literalinclude:: _include/dlb/dlb_example_config.yaml + :language: yaml + :lines: 7-11 + :lineno-start: 7 + :linenos: + :caption: :download:`dlb_example_config.yaml <_include/dlb/dlb_example_config.yaml>` + +.. code-block:: console + + $ ./envoy --concurrency 2 -c dlb_example_config.yaml --log-level debug &> envoy-dlb.log + +After Envoy starts, you should see logs similar to: + +.. code-block:: console + + $ grep dlb envoy-dlb.log + +.. code-block:: text + + [2024-07-08 10:05:00.113][3596312][info][main] [source/server/server.cc:434] envoy.network.connection_balance: envoy.network.connection_balance.dlb + [2024-07-08 10:05:00.241][3596312][debug][config] [contrib/dlb/source/connection_balancer_impl.cc:92] dlb available resources: domains: 32, LDB queues: 32, LDB ports: 64, ES entries: 2048, Contig ES entries: 2048, LDB credits: 8192, Config LDB credits: 8192, LDB credit pools: 64 + +Step 3: Run the upstream service +******************************** + +.. code-block:: console + + $ docker run -d -p 12000:80 nginx + +Step 3: Test +************ + +Visit the upstream service by Envoy endpoint: + +.. code-block:: console + + $ curl localhost:10000 | grep Welcome + +You should get output from Nginx: + +.. code-block:: text + + Welcome to nginx! + +Check the log, you should see the latest contents similar to: + +.. code-block:: text + + [2024-07-08 10:10:48.099][3598062][debug][connection] [contrib/dlb/source/connection_balancer_impl.cc:283] worker_1 dlb send fd 49 + [2024-07-08 10:10:48.099][3598066][debug][connection] [contrib/dlb/source/connection_balancer_impl.cc:300] worker_3 get dlb event 1 + [2024-07-08 10:10:48.099][3598066][debug][connection] [contrib/dlb/source/connection_balancer_impl.cc:317] worker_3 dlb recv 49 + [2024-07-08 10:10:48.099][3598066][debug][connection] [contrib/dlb/source/connection_balancer_impl.cc:297] worker_3 dlb receive none, skip + +Above logs show that DLB balanaces a connection from worker 1 to worker 3. + +.. seealso:: + :ref:`DLB connection balanace API ` + API and configuration reference for Envoy's DLB connection balanace. + + :ref:`Connection balance configuration ` + Configuration referenc for Envoy's connection balanace. + + `DLB `_ + The Intel DLB website.