当前位置:网站首页>Record a pressure measurement experience summary
Record a pressure measurement experience summary
2022-07-07 05:19:00 【banana-man】
1. jemeter page
2. Thread group
Right click the test plan –> add to –> Threads –> Thread group
Thread group properties
Number of threads :x Total enabled x Threads
Ramp-Up:y y Within seconds x All threads start
cycles :z x Thread loop requests z Time
Be careful : Number of cycles “ forever ” Don't tick , This option works with the scheduler , When you check forever , The duration filled in by the scheduler is m, Express x Threads keep making requests , Until the requested time is reached m Then stop . When testing concurrency , It is easy to cause the pressure measuring machine to get stuck .
setUP The thread group is testing the task ThreadGroup Run before run . Usually used before running a test task , Do initialization work . For example, establishing database connection and initial differentiation work
tearDown The thread group is run after the test task thread group runs . It is usually used to clean up dirty data in testing 、 Log out 、 Close resources and other work . For example, close database connection
My application scenario here is setup Thread group add login request ,tearDown Thread group add logout request , Release sessionId The cache of .
3. Sampler –http request
Right click thread group –> add to –> Sampler –>HTTP request
4. Sampler —TCP request
TCP Request here I use to send the instruction text to the gateway , Realize the online operation of the device .
Add step : Right click thread group –> add to –> Sampler –>TCP Sampler
TCPClient classname:TCP Message format class name , Default prefix org.apache.jmeter.protocol.tcp.sampler.
① TCPClientImpl: Plain text , Default transfer format . Generally used to send json strand ;
② BinaryTCPClientImpl: Hexadecimal message , Specify package terminator ;
③LengthPrefixedBinaryTCPClientImpl: Inherit BinaryTCPClientImpl class , And in BinaryTCPClientlmpl Add two bytes of data length in front . Can be found in jmeter.properties In profile tcp.binarylength.prefix.length Set up ;
Server name or IP: Server host name or server ip Address
Port number : Server port number
Connect : Timeout of connection with server socket application ( Unit millisecond ,0 Indicates disable timeout )
Respond to : Timeout of server response ( Unit millisecond ,0 Indicates disable timeout ), The setting of this value follows the end of the line (EOL) Byte value is related , If the end of the line (EOL) The value in the byte value is set incorrectly , It can lead to JMeter I've been waiting for it to end , But if you specify Response Timeout At this value , Close the connection when this value is reached .
Re-use connection: If it's checked , It means in a thread group , Reuse a connection , At request TCP This is required for long connections .
Close the connection : If it's checked , Only one sampler can be used TCP Connect , That is, after sending the message , Just shut it down TCP Connect
Set no delay : Reference resources java.net.Socket.setTcpNoDelay(), If checked, , It will disable Nagle’s Algorithm ( Take advantage of caching ), conversely
SO_LINGER: This configuration item is used to control whether to wait for the data in the buffer to be sent before closing the connection . If SO_LINGER Option specifies a value , After receiving the request to close the connection, it will wait for the specified number of seconds to complete the sending of data in the buffer , At the designated SO_LINGER After seconds , Close the connection . therefore , If this option is set to 0, Then all connections will be closed as soon as they are received , Avoid many situations TIME_WAIT state ( Wait state ) Socket , The unit is in seconds .
At the end of the line (EOL) Byte value : Judge the end of the line byte value , If the setting value is -128 To 127 Outside will skip EOL testing . Can be in jmeter.properties Add attributes to the file eolByte Set it up , If in TCP Sampler Config(TCP Sampler configuration ) This property is also set in , that TCP Sampler Config The setting in will work . For example, the string returned by the server end with carriage return , Then you can set this option to 10. For example, the last byte of my response is hexadecimal 44, Converting to decimal is 68.
Text to send : Data to send
5.http Request attention :
jemeter The default file types are :application/x-www-form-urlencoded( The parameters can be in Parameters or Body Data Internal input )、multipart/form-data
but application/json Not the default file type , So we need to tell the server what format the request information we sent is , When the interface contentType by application/json when , Need to add a http Header Manager .
6. Monitor
Listeners often use result trees 、 Aggregation report 、BeanShell Monitor . Add step : Right click http request / Thread group –> add to –> Monitor
Scope of action : Take the result tree as an example , The scope of the result tree depends on whether it is added under the sampler or the thread group .
Fruit trees : View the request content and response results of each request .
polymerization / Summary report : Statistics of request response time , Including the maximum response time 、 Minimum response time 、 The median 、 Average value, etc. .
BeanShell: Sub preprocessor 、 Post Processors 、 Assertion .
7.BeanShell Assertion
coordination json The extractor uses , After calling the login interface , take sessionId Set to global variable
Add step : add to –> Post Processors –>Json Extractor
Used to extract the request response text sessionId value , And assign to variable sessionId
BeanShell Is used to json Obtained by extractor sessionId Set to global variable .
Add step : Right click http request –> add to –> Assertion –>BeanShell Assertion ( Add assertions or beanShell Post processor is ok )
Will respond to sessionId Set to global variable , Script KaTeX parse error: Expected group after '_' at position 2: {_̲_setProperty(se…{sessionId},)}
//${__setProperty( Variable name , value } Global variable assignment , Cross thread calls , It can be called anywhere , But you can't follow import xxx Back
${__property(sessionId)} The function returns Jmeter The attribute value .
8. Assertion
In addition to the above mentioned beanShell Beyond assertion , There are other assertions .
Take response assertion as an example . Add a response assertion , Determine whether the response text contains “ The request is successful ”, If the returned result does not contain the request success , Then the assertion fails .
Take the assertion duration as an example . Judge whether the response time is lower than 200ms, If the response time is higher than 200ms, Then the assertion fails .
9. Counter
In a real application scenario , When adding data, some fields must not be repeated , At this time, the application of counters can avoid tedious operations of changing parameter values .
The name of the reference is set here , References in parameters can be made through ${upNum} Reference this value . Set the start and increment , The maximum value can be set as needed . When the value increases to the upper limit , Stop self increasing , Return to the initial value and continue to increase .
10. summary
For piezometry , Finding the bottleneck can pressurize the interface by adding the number of threads and the number of cycles of the thread group , Check whether the throughput of the aggregate report continues to increase , If you increase the number of cycles a lot , There is still room to improve throughput , Then you can add the number of lines , The number of threads is generally added to 20 It's already high , Until the throughput is no longer increased or the increase is small, the bottleneck can be determined ,
Refer to the post :https://blog.csdn.net/weixin_39607473/article/details/111108192
边栏推荐
猜你喜欢
随机推荐
Analysis -- MySQL statement execution process & MySQL architecture
AOSP ~Binder 通信原理 (一) - 概要
高数中值定理总结
模拟线程通信
QT simple layout box model with spring
Knapsack problem (01 knapsack, complete knapsack, dynamic programming)
ASP. Net MVC - resource cannot be found error - asp Net MVC – Resource Cannot be found error
Addressable 预下载
《四》表单
线程池的创建与使用
[question] Compilation Principle
高手勿进!写给初中级程序员以及还在大学修炼的“准程序员”的成长秘籍
想要选择一些部门优先使用 OKR, 应该如何选择试点部门?
实现网页内容可编辑
腾讯云数据库公有云市场稳居TOP 2!
Array initialization of local variables
最长不下降子序列(LIS)(动态规划)
漏电继电器JOLX-GS62零序孔径Φ100
10 distributed databases that take you to the galaxy
第一篇论文的写作流程