<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 分布式負載測試 該教程描述如何在[Kubernetes](http://kubernetes.io)中進行分布式負載均衡測試,包括一個web應用、docker鏡像和Kubernetes controllers/services。關于分布式負載測試的更多資料請查看[Distributed Load Testing Using Kubernetes](http://cloud.google.com/solutions/distributed-load-testing-using-kubernetes) 。 ## 準備 **不需要GCE及其他組件,你只需要有一個kubernetes集群即可。** 如果你還沒有kubernetes集群,可以參考[kubernetes-handbook](https://www.gitbook.com/book/rootsongjc/kubernetes-handbook)部署一個。 ## 部署Web應用 本文中使用的鏡像、kubernetes應用的yaml配置來自我的另一個項目,請參考:https://github.com/rootsongjc/distributed-load-testing-using-kubernetes `sample-webapp` 目錄下包含一個簡單的web測試應用。我們將其構建為docker鏡像,在kubernetes中運行。你可以自己構建,也可以直接用這個我構建好的鏡像`index.tenxcloud.com/jimmy/k8s-sample-webapp:latest`。 在kubernetes上部署sample-webapp。 ```bash $ git clone https://github.com/rootsongjc/distributed-load-testing-using-kubernetes.git $ cd kubernetes-config $ kubectl create -f sample-webapp-controller.yaml $ kubectl create -f sample-webapp-service.yaml ``` ## 部署Locust的Controller和Service `locust-master`和`locust-work`使用同樣的docker鏡像,修改cotnroller中`spec.template.spec.containers.env`字段中的value為你`sample-webapp` service的名字。 - name: TARGET_HOST value: http://sample-webapp:8000 ### 創建Controller Docker鏡像(可選) `locust-master`和`locust-work` controller使用的都是`locust-tasks` docker鏡像。你可以直接下載`gcr.io/cloud-solutions-images/locust-tasks`,也可以自己編譯。自己編譯大概要花幾分鐘時間,鏡像大小為820M。 $ docker build -t index.tenxcloud.com/jimmy/locust-tasks:latest . $ docker push index.tenxcloud.com/jimmy/locust-tasks:latest **注意**:我使用的是時速云的鏡像倉庫。 每個controller的yaml的`spec.template.spec.containers.image` 字段指定的是我的鏡像: image: index.tenxcloud.com/jimmy/locust-tasks:latest ### 部署locust-master ```bash $ kubectl create -f locust-master-controller.yaml $ kubectl create -f locust-master-service.yaml ``` ### 部署locust-worker Now deploy `locust-worker-controller`: ```bash $ kubectl create -f locust-worker-controller.yaml ``` 你可以很輕易的給work擴容,通過命令行方式: ```bash $ kubectl scale --replicas=20 replicationcontrollers locust-worker ``` 當然你也可以通過WebUI:Dashboard - Workloads - Replication Controllers - **ServiceName** - Scale來擴容。 ![使用dashboard來擴容](https://box.kancloud.cn/80d3b485b6a5af857d266dd78227a5e3_3268x1896.jpg) ### 配置Traefik 參考[kubernetes的traefik ingress安裝](https://jimmysong.io/posts/traefik-ingress-installation/),在`ingress.yaml`中加入如下配置: ```yaml - host: traefik.locust.io http: paths: - path: / backend: serviceName: locust-master servicePort: 8089 ``` 然后執行`kubectl replace -f ingress.yaml`即可更新traefik。 通過Traefik的dashboard就可以看到剛增加的`traefik.locust.io`節點。 ![Traefik的UI](https://box.kancloud.cn/c1216e4abd9d1d043542ba2cd851dbc4_2300x1898.jpg) ## 執行測試 打開`http://traefik.locust.io`頁面,點擊`Edit`輸入偽造的用戶數和用戶每秒發送的請求個數,點擊`Start Swarming`就可以開始測試了。 ![Locust啟動界面](https://box.kancloud.cn/a1e23cb19ddc466106554000069e5191_2050x1166.jpg) 在測試過程中調整`sample-webapp`的pod個數(默認設置了1個pod),觀察pod的負載變化情況。 ![Dashboard查看頁面](https://box.kancloud.cn/38fabd1ffde5f1dca6655d5ac653f684_3252x1906.jpg) 從一段時間的觀察中可以看到負載被平均分配給了3個pod。 在locust的頁面中可以實時觀察也可以下載測試結果。 ![Locust測試結果頁面](https://box.kancloud.cn/acd4c66eb02b1c3aa6a172446b6d697f_2086x784.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看