Back-end development skills-use Jmeter to test your interface performance

1. JmeterIntroduction

Apache JMeterIt is a stress testing tool Apachedeveloped by the organization Java. Used for stress testing of software, it was originally designed for Webapplication testing, but later expanded to other testing areas. We can test for interface concurrency issues.

2. Environmental installation

  • 1. First make sure jdkthe environment has been installed on your computer

    # 查看版本
    java -version
    
  • 2. Download from the official websiteJMETER , pay attention to jdkthe version

    If you are a windowsystem computer, download zipthe package in the following format, macand download the package circled in the figure below

    Insert picture description here

  • 3. Unzip the file and run the command

    • macAfter the computer is decompressed bin, run the command in the directorysh jmeter
      Insert picture description here

    • windowThe system computer can directly click on bin/jmeter.batthe file to start

  • 4. Configure Chinese interface
    Insert picture description here

Three, simulate and test an interface

  • 1. Create a thread group
    Insert picture description here

  • 2. Basic configuration of thread group
    Insert picture description here

  • 3. Create a httprequest (similar postmanto initiate a request in)
    Insert picture description here

  • 4. Configuration request information
    Insert picture description here

  • 5. Create a listener (similar to httprespond after initiating a request)
    Insert picture description here

Fourth, configure the request header

  • 1. jsonThe method used to extract the login interfacetoken
    Insert picture description here
    Insert picture description here

  • 2. httpSet the request header in another interface and pass the token
    Insert picture description here
    Insert picture description here

Five, directly execute sqlstatements to obtain data and test concurrency

  • 1. The downloaded mysqlpackage Insert picture description here

  • 2. Unzip the downloaded file and jarcopy the package inside to the jmeter/bindirectory (easy to find and not accidentally deleted)

  • 3. jemeterCreate a thread group in (the same as above)

  • 4. Configure the jdbcconnection
    Insert picture description here

  • 5. Configuration information

    • url:jdbc:mysql://host:port/{dbname}?allowMultiQueries=true&serverTimezone=UTC
    • DriverName:com.mysql.jdbc.Driver
      Insert picture description here
  • 6. Create oneJDBC Request
    Insert picture description here
    Insert picture description here

  • 7. Configure the login interface

    • Configure the global default request
      Insert picture description here
      Insert picture description here

    • Configure login request interface
      Insert picture description here

    • Configure the counter ( variables sqlare used in the statement above ${offset})
      Insert picture description here
      Insert picture description here

Guess you like

Origin blog.csdn.net/kuangshp128/article/details/110491417