久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      負(fù)載,性能測試工具-Gatling

      負(fù)載,性能測試工具-Gatling

      負(fù)載,性能測試工具-Gatling

      前言

      Gatling

      Gatling是一款功能強大的負(fù)載測試工具,它為易于使用,高可維護(hù)性和高性能而設(shè)計。

      開箱即用,Gatling由于對HTTP協(xié)議的出色支持,使其成為負(fù)載測試任何HTTP服務(wù)器的首選工具。由于核心引擎實際上是協(xié)議不可知的,因此完全可以實現(xiàn)對其他協(xié)議的支持。例如,Gatling目前還提供JMS支持。

      代碼自定義并且場景資源有效是Gatling的兩個基礎(chǔ)。并且擁有富有表現(xiàn)力的DSL,自我解釋的場景,易于維護(hù),可以保存在版本控制系統(tǒng)中的優(yōu)點。

      只要底層協(xié)議(如HTTP)可以以非阻塞方式實現(xiàn),Gatling的體系結(jié)構(gòu)就是異步的。這種架構(gòu)允許我們將虛擬用戶實現(xiàn)為消息而不是專用線程,這使得硬件要求不需要很苛刻。因此,運行數(shù)千個并發(fā)虛擬用戶不是問題。

      使用理由

      • 避免崩潰:Gatling可以幫助您預(yù)測緩慢的響應(yīng)時間和奔潰。
      • 縮短產(chǎn)品上市時間:Gatling 在開發(fā)周期的早期檢測到性能問題和錯誤
      • 增強用戶體驗:Gatling可以準(zhǔn)確描述您最慢的用戶體驗
      • 提升您的業(yè)務(wù):加特林可以防止您的業(yè)務(wù)成為自身成功的犧牲品

      性能測試

      性能測試是什么意思?

      Web應(yīng)用程序的性能測試包括:

      1. 模擬大量具有復(fù)雜行為的用戶;

      2. 收集和匯總所有請求的響應(yīng)時間;

      3. 創(chuàng)建報告分析數(shù)據(jù);

      負(fù)載,性能測試工具-Gatling

      編寫測試場景,自動化測試

      Gatling的類似代碼的腳本使您可以輕松維護(hù)測試場景,并在持續(xù)交付管道中輕松實現(xiàn)自動化。

      我們開發(fā)了自己的領(lǐng)域特定語言(DSL),以便讓每個人都能輕松閱讀您的場景。

      負(fù)載,性能測試工具-Gatling

      分析并調(diào)查您的應(yīng)用程序的瓶頸

      Gatling是一個功能強大的工具:只需幾臺計算機,您就可以 在Web應(yīng)用程序上模擬每秒數(shù)十萬個請求,并獲得高精度指標(biāo)

      在測試結(jié)束時,Gatling會自動生成詳盡,動態(tài)豐富多彩的報告。

      平均值和平均數(shù)據(jù)是不夠的:使用Gatling,您可以得到適當(dāng)響應(yīng)時間百分位數(shù)。不要讓最慢的用戶落后!

       

      負(fù)載,性能測試工具-Gatling

      安裝

      準(zhǔn)備工作

      Java版本

      Gatling主要針對Oracle提供的JDK8軟件包進(jìn)行測試。Gatling需要JDK8(因此不支持JDK9 atm)。Gatling應(yīng)該適用于任何JDK8更新,但我們建議您使用最新版本。

      IPv4 vs IPv6

      發(fā)現(xiàn)IPv6(默認(rèn)情況下在Java上啟用)有時會導(dǎo)致一些性能問題,因此啟動腳本會使用以下選項禁用它:

        -Djava.net.preferIPv4Stack=true
        -Djava.net.preferIPv6Addresses=false

      如果您確實需要優(yōu)先選擇IPv6,請編輯啟動腳本。

      操作系統(tǒng)調(diào)整

      以下說明摘自偉大的Riak文檔。 有關(guān)更多詳細(xì)信息或OS X的說明,請參閱“ 打開文件限制” 和“ 內(nèi)核和網(wǎng)絡(luò)調(diào)整”部分。

      在正常操作期間,Gatling會消耗大量的打開文件句柄。通常,操作系統(tǒng)會限制此數(shù)量,因此您可能必須在所選操作系統(tǒng)中調(diào)整一些選項,以便可以打開許多新套接字并實現(xiàn)高負(fù)載。

      打開文件限制

      大多數(shù)操作系統(tǒng)都可以使用該命令更改打開文件限制。例:ulimit -n

        $ ulimit -n 65536

      但是,這只會更改當(dāng)前shell會話的限制。在系統(tǒng)范圍內(nèi),永久性地更改限制因系統(tǒng)而異。

      為系統(tǒng)的所有用戶永久設(shè)置軟值和硬值,以允許最多65536個打開文件; 編輯/etc/security/limits.conf并附加以下兩行:

        *       soft    nofile  65535    *       hard    nofile  65535

      保存文件。啟動新會話以使限制生效。您現(xiàn)在可以驗證是否正確設(shè)置了限制。ulimit -a

      對于Debian和Ubuntu,您應(yīng)該啟用PAM用戶限制。為此,請?zhí)砑樱?span>session required pam_limits.so

      • /etc/pam.d/common-session
      • /etc/pam.d/common-session-noninteractive 如果文件存在
      • /etc/pam.d/sshd 如果您通過SSH訪問該計算機

      另外,如果訪問通過SSH的機器,一定要具有在UseLogin yes``/etc/ssh/sshd_config

      要進(jìn)行更多調(diào)整,您可能需要執(zhí)行以下操作:

        # more ports for testing
        sudo sysctl -w net.ipv4.ip_local_port_range=”1025 65535″
        ?
        # increase the maximum number of possible open file descriptors:
        echo 300000 | sudo tee /proc/sys/fs/nr_open
        echo 300000 | sudo tee /proc/sys/fs/file-max

      內(nèi)核和網(wǎng)絡(luò)調(diào)優(yōu)

      考慮調(diào)整內(nèi)核和網(wǎng)絡(luò),并在/etc/sysctl.conf中添加以下這些設(shè)置:

       net.ipv4.tcp_max_syn_backlog = 40000
        net.core.somaxconn = 40000
        net.core.wmem_default = 8388608
        net.core.rmem_default = 8388608
        net.ipv4.tcp_sack = 1
        net.ipv4.tcp_window_scaling = 1
        net.ipv4.tcp_fin_timeout = 15
        net.ipv4.tcp_keepalive_intvl = 30
        net.ipv4.tcp_tw_reuse = 1
        net.ipv4.tcp_moderate_rcvbuf = 1
        net.core.rmem_max = 134217728
        net.core.wmem_max = 134217728
        net.ipv4.tcp_mem  = 134217728 134217728 134217728
        net.ipv4.tcp_rmem = 4096 277750 134217728
        net.ipv4.tcp_wmem = 4096 277750 134217728
        net.core.netdev_max_backlog = 300000

      離線下載

      您可以離線下載Gatling。然后,您只需要一個文本編輯器(Scala語法高亮)來編輯模擬,您就可以從命令行啟動Gatling。

      查看我們的下載頁面以獲取下載鏈接。

      將下載的包解壓縮到您選擇的文件夾中。使用bin目錄中的腳本啟動Gatling和Recorder。

      Windows用戶:我們建議您不要將Gatling放在“ Programs”文件夾中,因為可能存在權(quán)限和路徑問題。

      要運行Gatling,您需要安裝JDK。加特林至少需要JDK8。然后,我們建議您使用最新版本。

      • Gatling啟動腳本和Gatling maven插件會在JAVA_HOMEenv var中設(shè)置它。

        與OSX一樣,操作系統(tǒng)有自己的棘手方法來發(fā)現(xiàn)要運行的Java版本,因此最終可能會運行與您告訴您的版本不同的版本。如果您遇到奇怪的錯誤,并且您希望運行JDK8,則可能需要明確設(shè)置JAVA_HOMEjava -version``Unsupported major.minor version 51.0

      使用構(gòu)建工具

      Maven

      Gatling提供了一個名為gatling-maven-plugin的官方maven 插件。這個插件允許您編譯Scala代碼并啟動Gatling模擬。

      有了這個插件,Gatling可以在構(gòu)建項目時啟動,例如使用您最喜歡的CI解決方案。

      Versions

      查看Maven Central上的可用版本。

      請注意,OSS用戶未記錄里程碑(M版本),僅針對專業(yè)版客戶發(fā)布。

      Setup

      在你的pom.xml,添加:

        <dependencies>
          <dependency>
            <groupId>io.gatling.highcharts</groupId>
            <artifactId>gatling-charts-highcharts</artifactId>
            <version>MANUALLY_REPLACE_WITH_LATEST_VERSION</version>
            <scope>test</scope>
          </dependency>
        </dependencies>
        ?
        <plugin>
          <groupId>io.gatling</groupId>
          <artifactId>gatling-maven-plugin</artifactId>
          <version>MANUALLY_REPLACE_WITH_LATEST_VERSION</version>
        </plugin>

      演示樣本

      您可以在Gatling的Github組織中找到gatling-sbt-plugin-demo示例項目。

      您還可以使用gatling-highcharts-maven-archetype來引導(dǎo)項目。

      Usage

      您可以直接啟動gatling-maven-plugin,其test目標(biāo)是:

        mvn gatling:test

      它默認(rèn)綁定到integration-test階段。

       

      Configuration

      下面的例子顯示了默認(rèn)值(所以不要指定你沒有覆蓋的選項!!!):

      <configuration>
          <simulationClass>foo.Bar</simulationClass>                              <!– the name of the single Simulation class to run –>
          <runMultipleSimulations>false</runMultipleSimulations>                  <!– if the plugin should run multiple simulations sequentially –>
          <includes>                                                              <!– include filters, see dedicated section below –>
            <include></include>
          </includes>
          <excludes>                                                              <!– exclude filters, see dedicated section below –>
            <exclude></exclude>
          </excludes>
          <noReports>false</noReports>                                            <!– to disable generating HTML reports –>
          <reportsOnly></reportsOnly>                                              <!– to only trigger generating HTML reports from the log file contained in folder parameter –>
          <runDescription>This-is-the-run-description</runDescription>            <!– short text that will be displayed in the HTML reports –>
          <skip>false</skip>                                                      <!– skip executing this plugin –>
          <failOnError>true</failOnError>                                          <!– report failure in case of assertion failure, typically to fail CI pipeline –>
          <continueOnAssertionFailure>false</continueOnAssertionFailure>          <!– keep on executing multiple simulations even if one fails –>
          <useOldJenkinsJUnitSupport>false</useOldJenkinsJUnitSupport>            <!– report results to Jenkins JUnit support (workaround until we manage to get Gatling support into Jenkins) –>
          <jvmArgs>
            <jvmArg>-DmyExtraParam=foo</jvmArg>                                    <!– pass extra parameters to the Gatling JVM –>
          </jvmArgs>
          <overrideJvmArgs>false</overrideJvmArgs>                                <!– if above option should override the defaults instead of replacing them –>
          <propagateSystemProperties>true</propagateSystemProperties>              <!– if System properties from the maven JVM should be propagated to the Gatling forked one –>
          <compilerJvmArgs>
            <compilerJvmArg>-DmyExtraParam=foo</compilerJvmArg>                    <!– pass extra parameters to the Compiler JVM –>
          </compilerJvmArgs>
          <overrideCompilerJvmArgs>false</overrideCompilerJvmArgs>                <!– if above option should override the defaults instead of replacing them –>
          <extraScalacOptions>                                                    <!– extra options to be passed to scalac –>
            <extraScalacOption></extraScalacOption>
          </extraScalacOptions>
          <disableCompiler>false</disableCompiler>                                <!– if compiler should be disabled, typically because another plugin has already compiled sources –>
          <simulationsFolder>${project.basedir}/src/test/scala</simulationsFolder> <!– where the simulations to be compiled are located –>
          <resourcesFolder>${project.basedir}/src/test/resources</resourcesFolder> <!– where the test resources are located –>
          <resultsFolder>${project.basedir}/target/gatling</resultsFolder>        <!– where the simulation log and the HTML reports will be generated –>
        </configuration>

      包含/排除過濾器

      運行多個模擬時,您可以使用includesexcludes過濾器控制哪些模擬將被觸發(fā)。那些使用ant模式語法并與類名匹配。另請注意,這些過濾器僅適用于從設(shè)置插件的項目中的源編譯的類。

      <configuration>
          <!–  …  –>
          <runMultipleSimulations>true</runMultipleSimulations>
          <includes>
            <include>my.package.*</include>
          </includes>
          <excludes>
            <exclude>my.package.IgnoredSimulation</exclude>
          </excludes>
        </configuration>

      注意:過濾器的順序?qū)?zhí)行順序沒有影響,模擬將按字母順序按類名排序。

      禁用編譯器

      默認(rèn)情況下,gatling-maven-plugin負(fù)責(zé)編譯Scala代碼,因此您可以直接運行。mvn gatling:execute

      然后,由于某種原因,你可能想要另一個插件,如scala-maven-pluginscalor-maven-plugin,負(fù)責(zé)編譯。然后,您可以禁用Gatling編譯器,這樣就不會編譯兩次:

        <configuration>      <disableCompiler>true</disableCompiler>    </configuration>

      覆蓋logback.xml文件

      您可以logback-test.xml擁有優(yōu)先于嵌入logback.xml文件的優(yōu)先級,也可以添加JVM選項-Dlogback.configurationFile=myFilePath。

       

      使用IDE

      您可以使用任何Scala語法高亮的文本編輯器編輯Simulation類。但如果您是開發(fā)人員,您很可能希望將自己喜歡的IDE與Gatling一起使用。

      Gatling正式支持IntelliJ IDEA和eclipse。

       

      IntelliJ IDEA

      您需要安裝社區(qū)版中提供的Scala插件。然后,您就可以使用Scala源直接導(dǎo)入常規(guī)maven或sbt項目。

       

      Eclipse

      您必須安裝ScalaIDE,最好是最新版本,甚至是里程碑。

      遺憾的是,截至今天,ScalaIDE僅適用于Eclipse 4.7(Oxygen),并且與更現(xiàn)代的版本不兼容。

      請注意,Eclipse 4.7不支持Java 9+,因此如果您的計算機上安裝了多個Java,則可能必須強制使用JVM eclipse.ini,例如:

        -vm    /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/bin/java

      SBT

      如果你正在使用sbt,你可以使用sbteclipse來生成eclipse項目配置。

      Maven

      如果您正在使用maven,則可以將scala-maven-pluginm2eclipse-scala結(jié)合使用。前者將編譯Scala代碼,后者將執(zhí)行ScalaIDE和m2e(maven的eclipse插件)之間的集成。

      您必須在pom.xml中添加以下部分:

        <build>
                <sourceDirectory>src/main/scala</sourceDirectory>
                <testSourceDirectory>src/test/scala</testSourceDirectory>
                <plugins>
                        <plugin>
                                <groupId>net.alchim31.maven</groupId>
                                <artifactId>scala-maven-plugin</artifactId>
                                <version>MANUALLY_REPLACE_WITH_LATEST_VERSION</version>
        <configuration>
          <args>
            <arg>-target:jvm-1.8</arg>
            <arg>-deprecation</arg>
            <arg>-feature</arg>
            <arg>-unchecked</arg>
            <arg>-language:implicitConversions</arg>
            <arg>-language:postfixOps</arg>
          </args>
        </configuration>
                                <executions>
                                        <execution>
                                                <goals>
                                                        <goal>compile</goal>
                                                        <goal>testCompile</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>

      您也可以使用scalor-maven-plugin。

      您必須在pom.xml中添加以下部分:

       <build>
          <plugins>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.8.0</version>
              <configuration>
                <skip>true</skip>
                <skipMain>true</skipMain>
              </configuration>
            </plugin>
            <plugin>
              <groupId>com.carrotgarden.maven</groupId>
              <artifactId>scalor-maven-plugin_2.12</artifactId>
              <version>MANUALLY_REPLACE_WITH_LATEST_VERSION</version>
              <configuration>
                                              <zincOptionsScala>
                                                      -target:jvm-1.8
                                                      -deprecation
                                                      -feature
                                                      -unchecked
                                                      -language:implicitConversions
                                                      -language:postfixOps
                                              </zincOptionsScala>
                                      </configuration>
              <executions>
                <execution>
                  <goals>
                    <goal>eclipse-config</goal>
                    <goal>eclipse-format</goal>
                    <goal>eclipse-restart</goal>
                    <goal>eclipse-prescomp</goal>
                    <!– <goal>register-main</goal> –> <!– uncomment if you have some Scala code to compile in src/main/scala –>
                    <goal>register-test</goal>
                    <!– <goal>compile-main</goal> –>  <!– uncomment if you have some Scala code to compile in src/main/scala –>
                    <goal>compile-test</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </build>

      從IDE啟動加特林

      gatling-highcharts-maven-archetype生成,您可以使用從您的IDE手動啟動加特林和記錄一些輔助類。可以完美復(fù)制這3個類Engine,RecorderIDEPathHelper在自己的項目)。

       

      以上參考官網(wǎng)介紹:

      https://gatling.io/

       

      初次接觸Gatling

      文件目錄介紹

        Gatling_Home
          ├── bin 執(zhí)行程序
            ├── gatling.bat — 啟動入口(windows)
            ├── gatling.sh — 啟動入口(linux)
            ├── recorder.bat — UI記錄入口(windows)
            ├── recorder.sh — UI記錄入口(linux)
          ├── conf 配置信息
            ├── gatling.conf — 加特林配置文件
            ├── gatling-akka.conf — 加特林akka配置文件
            ├── logback.xml — 日志配置文件
            ├── recorder.conf — recorder配置文件
          ├── lib 加特林依賴jar包
          ├── results 測試報告
          ├── target 編譯類
          ├── user-files 用戶文件
          ├── LICENSE 許可證

      How to run it

      進(jìn)入bin目錄可以看到下面兩個文件(.bat屬于windows下面的可執(zhí)行腳本)

      gatling.sh 啟動入口 依次輸入以下三個參數(shù)

      • 執(zhí)行的腳本序號
      • 本次測試Id,用作測試報告命名前綴,不能包含空格,特殊字符,中文等
      • 本次測試描述(非必須),會顯示在報告頭部

      record.sh

      UI操作,它主要用于將瀏覽器配置代理后記錄用戶操作然后生成測試腳本,更多的用于用戶行為模擬測試。

      測試運行

      首先肯定是要下載它

      http://gatling.io/#/download

      解壓并進(jìn)入到bin目錄下運行sh gatling.sh(linux環(huán)境下)負(fù)載,性能測試工具-Gatling

       

      負(fù)載,性能測試工具-Gatling

      上面列出的就是官方自帶的測試腳本樣例,我們試著跑下。

      輸入0.就能看到窗口開始跳動字節(jié)了!

      負(fù)載,性能測試工具-Gatling

      顯示上面的信息表示測試程序已經(jīng)運行完成,最后一行顯示的是本次的測試報告,可以打開瞅瞅,風(fēng)騷的報告自己體會吧,首次介紹就先到這里了。

      部分報告截圖如下所示:

      負(fù)載,性能測試工具-Gatling

      其他

      關(guān)于負(fù)載,性能測試工具-Gatling詳解到這里就結(jié)束了。

      原創(chuàng)不易,如果感覺不錯,希望給個推薦!您的支持是我寫作的最大動力!

      版權(quán)聲明:

      作者:穆書偉

      博客園出處:https://www.cnblogs.com/sanshengshui

      github出處:https://github.com/sanshengshui    

      個人博客出處:https://sanshengshui.github.io/

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號