Pressure test of WebSocket with JMeter

Source: Internet
Author: User

In the previous period, I wrote a chat room based on Nodejs and Socket.io for the purpose of practicing Angularjs+requirejs, GitHub address: https://github.com/towersxu/ Node-socketio-angular-require-chatroom. At that time did not consider the performance of the problem, in line with the purpose of functional implementation is good. I'm just about ready to test the performance of this chat room recently.

The test tool I am using is jmeter, version 2.11. This is a green version of my colleague's copy to me. Run as long as you have a Java environment (: apache-jmeter-2.11). Click on the jmeter.bat in the bin directory to run it. This version of me does not support websocket test, so I need to download a plug-in called Jmeterwebsocketsampler-1.0.2-snapshot.jar, this plugin needs to download 6 dependent packages, as shown in:

After the plug-in is installed, you can use JMeter to simulate socket.io communication. First open the Chrome console and view the network. When we enter a page containing Socket.io, we can see a few links as shown.

We just need to implement these links with JMeter, and we can simulate the communication between the browser and the server. First we simulate the top two requests. Click on the request we can see the details of this request, from the header we can find the fact that the two requests or HTTP requests, but with different parameters. The second request takes one more parameter than the first request, which is called the SID, and his value is the first one that corresponds to the request. These two requests can be seen as the 1 handshake process in TCP (I do not understand the three handshake of TCP, I feel this should be similar to it) or it is a authentication, this SID is the unique identity of the communication. I'm going to use JMeter to simulate these two requests. Select the HTTP request within the sampler of the thread group. As shown in the following:

First request (note that the above picture path should be/socket.io/?) Eio=3&transport=polling missing a question mark ==!)

The second request note that the above picture path should be/socket.io/? Eio=3&transport=polling missing a question mark ==!

Note ${sid} in the second request, this is obtained in the first request, and all need to add a post processor--and regular expression extractor to the first request.

Now I go to Chrome to see the details of the 3rd request, and we can see that the URL of the third request becomes WS, and the parameter transport becomes websocket. And one more frames column. Frames as shown:

Now we create a new WebSocket sampler to simulate the socket link. and send 2probe to the server:

Add an observation tree, run to see the results of the request, the corresponding data is 3probe

Later we continue to simulate the Socket.io follow-up link, which is the green part of Frams, and the white part is the response of the server. Note that the last to use the loop controller interval to send 2 to the server remains connected. My entire process is as follows (Room-chat-test-010.jxm in the example folder of the JMeter downloaded above):

Pressure test of WebSocket with JMeter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.