Jmeter scene setting and starting method

Table of contents

Thread group settings

name和comments

Action to be taken after a sampler error

Thread Properties thread property settings

Scenario run

Remote run configuration

Command Line


The performance test scene is a work unit used to simulate real user operations, so the scene design must be in line with the user's operation logic. Jmeter mainly completes the scene setting through the thread group and other components.

Thread group settings

The Jmeter thread group is actually a thread pool, and then completes the initialization of the thread pool according to the user's settings, and performs various logic processing at runtime

The above figure is a configuration interface of a thread group. Let's explain the specific parameters below.

name和comments

It is the configuration of the name and comments. Here you can set it according to the scene you want to test. It is best to see the name and know the meaning

Action to be taken after a sampler error

The operation to be performed after the sampler fails, that is to say, the exception handling method after a certain request fails, there are 5 ways

  • Continue, continue, after the request of the sampler simulation fails, continue to run

    When a large number of users request concurrently, the server may respond with an error, which is a normal phenomenon. At this time, the error should be recorded and the subsequent request should be continued

  • start next Thread Loop If an error occurs, the remaining requests in the unified script will not be executed and will be restarted directly. For example, there is a scene where you need to log in first before posting. If the login fails at this time, the posting will not be successful, so There is no need to continue execution, just start the next round of testing directly, and you can set this error handling method at this time.

  • stop thread Stop the thread. If a request simulated by the sampler fails, stop the current thread and no longer execute it. For example, if 40 threads are configured and a thread’s request fails, the current thread will be stopped, and the remaining threads will continue to execute. , if there are more failures, more threads will be stopped, and fewer and fewer threads will be running, then the load on the server will be insufficient, and the test results will not be informative, so this is generally not set.

  • stop test Stop the test. If a request of a certain thread fails, all threads will be stopped, that is to say, the test will be stopped, but each thread will still execute the current scene. For example, the current scene is to log in and send a message. There is a thread If the login fails, other threads also execute the login. After the error occurs, other threads will continue to execute the posting operation.

  • stop test Now Stop the test immediately. If any thread request fails, stop all threads immediately and do not continue to execute

Thread Properties thread property settings
  • Number of Threads (users)

    Set the number of running threads, one thread corresponds to one user

  • Ramp-up period (seconds) The time interval for threads to start running, in seconds, how long does it take for all threads to start running

    For example, if 50 threads are set and the Ramp-up period is set to 10 seconds, then 5 threads will be started per second. If it is set to 0 seconds, then 50 threads will be started immediately.

  • Loop count The number of repetitions of the request. If you choose infinite, the request will continue to execute unless it stops or crashes. If you choose to fill in the specific number of times, you can control the number of times in sequence.

  • sam user on each iteration uses the same user for each iteration. This configuration is newly added after version 5.2. The previous version does not have this option, so there will be a problem. The simulated users are not as independent as the real scene. , he defaults to multiplexing users in each thread, and recommends an article for everyone https://www.cnblogs.com/nmb123/p/12266697.html

  • Delay Thread creation until needed

    All JMeter threads are created at the beginning, but they will be incremented according to the above rules when they are incremented. If this option is selected, not all threads will be created initially, only when needed.

    If not selected, when starting the scene, JMeter will use more CPU to create threads, which will affect the response time of some previous requests, because the CPU of the press is doing other things. If it is selected, it will be recreated when it is used, and the CPU consumption will be average, but there will be another hidden danger at this time, that is, it will slightly affect the running thread

  • Specify Thread lifetime Thread running time, this configuration will only take effect if the number of repetitions of the Loop count request is configured to be infinite, otherwise the Loop count will control the execution of the thread

    • Duration (seconds) Set how long the thread group runs, in seconds
    • StartUp delay (seconds) sets the thread startup delay time, in seconds

Scenario run

There are two ways to run Jmeter, one is GUI visual interface operation, and the other is command line operation, both of which support localized operation, that is, single operation and remote operation. Here we mainly introduce remote execution and jmeter command line operation.

Remote run configuration
  • remote configuration

    Remotely run node port configuration:

    server_port=1099
    server.rmi.localport=1099
    

    run:

    ./jmeter-server -Djava.rmi.server.hostname=本机ip
    
  • local configuration

    remote_hosts configuration

    remote_hosts=ip:port,ip:prot,... ip和port都是远程执行机的ip和server的运行端口
    

    run:

    java -jar ApacheJMeter.jar -n -t Thread\ Group.jmx -r -l result.jtl -R ip
    

    -R specifies which machine to run the test script on

Command Line

Executing ./jmeter -? on the command line can output command line parameter options. Here are some more commonly used ones. For more usage, see the official document

  • -l Record the test results to a file, specify the file address and name, you can make a relative path or an absolute path
  • -d specifies the jmeter home path
  • -R Open the remote load machine, specify the ip of the load machine
  • -n specifies non-GUI mode to run
  • -t specifies the jmeter script file path
  • -L specifies the log level

 

Guess you like

Origin blog.csdn.net/MXB_1220/article/details/131690126