How to do load testing for websockets [closed] - websocket

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
We are building a group chat feature, which is using websockets. We want to test how many connections our current infrastucture can support.
Basically it boils down to how to simulate a websocket.

I can give you a suggestion from my recent experience. You can connect webkit based Phantom virtual clients to your chat server and measure the resource usage (i.e CPU, memory, may be using a shell script or another utility or you can profile your service )
var system = require('system');
var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };
page.open("<URL to chat server service>", function (status) {
// Check for page load success
if (status !== "success") {
console.log("Unable to connect");
phantom.exit();
} else {
console.log("Client connected ");
//after connecting you may extract further information, taking screenshots etc. refer the phantom.js API for further details
}
});
Do you use any framework like socket IO for websocket communication ?

Several years have passed, there is another new tool to do load testing for Websockets:
https://github.com/observing/thor

How about using Jmeter for this purpose. Although it doesn't yet support WebSocket directly you can use TCP sampler to get the job done.
Alternatively you could get a plug-in which would add WebSocket support to JMeter: http://github.com/maciejzaleski/JMeter
Needless to say both JMeter and WebSocket plug-in is open-source and free to use.

You can use a load-testing tool for that.
I have used WebLOAD in a similar project. It records the web traffic when using the browser - it records regular HTTP requests and also the web-sockets traffic - you can then play the script back with many users and measure the server's behavior.

I would do it with Node.js so you can use the same websocket client library which you also use in the actual client.
Node.js: https://nodejs.org/
Websocket client e.g. socket.io-client: http://socket.io/get-started/chat/

I had a nice experience with tsung http://tsung.erlang-projects.org/

Related

How to communicate between two Go Programs? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Program which I am trying to make like this
There are three GO Porgram, they are Go program 1, Go Program 2 , Go Program 3
Go Program 1
Which get data from serial port and sent to Go Program 2
GO Program 2
Recv. the data from Go program 1 and sent it to MQTT
GO Program 3
It should be web framework as I need Web UI to control and manage these GO program 1 & Go Program 2
The Go Program 3 task are:
To start stop the GO Program 1 & 2
To change or set the COM port of Go Program 1 and publish topics
To change the broker address ,username & Password of Go Program 2
How to make communicate or Pipes between all the the three GO Programs.
Looking at the discussion in comments I think you make an assumption that Go has some special way for IPC that Python doesn't; that's not exactly true. Channels are useful for communication within a single process. If you want these programs to be truly separate (processes) you'll need all the usual IPC - you can use pipes, or sockets, or shared memory, or what have you.
Personally I'd recommend using sockets, because Go is really well suited for network programming and writing socket servers and clients. Also, once your application uses sockets it's much easier to port these different processes to run on multiple machines, across the internet, etc. In addition you can then leverage higher-level protocol levels and use things like RPCs.
To create a socket server, use net.Listen, and call Accept in a loop on the returned object. Each connection returned by Accept is a remote client you can communicate with - I'd recommend a goroutine here if you want concurrency between multiple clients.
For a first cut in a project like yours, however, I'd go for the net/rpc package which is very simple to use and gives a much higher level API to sending remote commands to other processes.

How to handle SignalR application with longpolling mechanism for load testing using Jmeter

We need to load test an web application using SignalR in few components with transport mode as long polling. My script gets hang in connect step. Connect step is GET- /signalr/connect?transport=foreverFrame&clientProtocol=1.5&connectionToken=ZW6cj17pImmCjGGBQSQNy%2Bdiy7DKDUy4i4R1AE78c%2FTitzS6QgiPoX6fM3zBOrDK11hyx0QNEc92JM6bsLY19MCt5JjaYFgdTDVsbxfnRbkqKp6dpsl64BV1zI8Vu1X%2F&connectionData=%5B%7B%22name%22%3A%22mypreviewhub%22%7D%5D&tid=10&frameId=1
I have correlated following 2 parameters- 1) captured connection token from negotiate step and used in subsequent requests
2) used ${__time()} for timestamp as found in link- How to capture signalR connection string in Jmeter
Apart from these, I can see 2 more parameters being send in connect step- tid and frameid. Do we need to correlate these 2 parameters as well, although these are not used anywhere else apart from connect step?
Or what is that my script lacking?
In various posts, I have seen suggestions to use websocket sampler plugins but I believe that can be helpful, if your SignalR use websocket mechanism, not long polling.
Please help me resolve this issue. Your help is appreciated. Thanks
As per How does long-polling work? answer:
Case: The server does not have any information available for the client when the request (poll) is received.
Behavior: Instead of sending an empty response, the server holds the request open and waits for response information to become available. Once it does, the server immediately sends an HTTP/S response to the client, completing the open HTTP/S request.
So your "hanging" might indicate that there is no data coming from the server.
You might want to check out 5 Ways to Load Test Popular Chat Plugins with JMeter article which assumes using Parallel Controller for implementing Long Polling scenario test, it even has an example test plan
In any case your test needs to replicate what real browser is doing so I'd recommend capturing requests which are being sent by JMeter and the real browser using a sniffer tool like Wireshark and if there are differences - amend JMeter configuration so the requests would be 100% matching the ones, originating from the real browser
This solution is for Load runner Users.
1.The tid does nor the frame id dosn't have to be parameterize. java script is randomly generated for TID FROM 1 to 11
Your time stamp is 12 digit random number
THE REASON FOR THE HANGING is that forever frame is an Asynchronous function of Signalr you must youse this statement to register a PUSH. If PUSH Doesnt work then do a POLL. lIKE SO
web_reg_async_attributes("ID=Push_0",
"Pattern=Push",
"URL=https://YOURurl.COM/signalr/connect?transport=foreverFrame&clientProtocol=1.5&connectionToken={CONNECTIONTOKEN}&connectionData=%5B%7B%22name%22%3A%22interactionhub%22%7D%5Dtid={TID}&frameId=1",
"RequestCB=Push_0_RequestCB",
"ResponseHeadersCB=Push_0_ResponseHeadersCB",
"ResponseBodyBufferCB=Push_0_ResponseBodyBufferCB",
"ResponseCB=Push_0_ResponseCB",
LAST);
Then modify your callback.c function
int Push_0_ResponseBodyBufferCB(
const char * aLastBufferStr,
int aLastBufferLen,
const char * aAccumulatedStr,
int aAccumulatedLen,
int aHttpStatusCode)
{
//Enter your implementation for ResponseBodyBufferCB() here.
lr_vuser_status_message("This is accumulated String %s", aAccumulatedStr);
lr_vuser_status_message("This is response body %s", aLastBufferStr);
Use Asyn option enabled next time in your recordings and you will see this stuff, but you must close the browser window at the end of your recording else the Async stuff won't be released and created in your script !! I found this out using Fiddler.

Should a Go app panic if it doesn't find external dependencies/services [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
How should a Golang app handle missing external dependencies ?
When a app starts and it doesn't find the database it is supposed to persist the data on, knowing the app is useless in that state, should I panic the app ?
I can otherwise log infinitely something, print to stderr, or use another method to notify, but I'm not sure when to choose each method.
An application that has no access to the external network service should not panic. This should be expected as networks tend to fail. I would wrap the error and pass it further.
Consider the following scenario. You have multiple application servers connected to two database servers. You are upgrading the database servers one at a time. When one is turned off half of your application servers panicked and crashed. You upgrade the second database server and every application server is gone now. Instead, when the database is not available just report an error for instance by sending HTTP status 500. If you have a load balancer it will pass the request to the working applications servers. When the database server is back, the application servers reconnect and continue to work.
Another scenario, you are running an interactive application that processes a database to create a report. The connection is not available. The application panicked and crashed. From the user perspective, it looks like a bug. I would expect a message that connection cannot be established.
In the standard library it is accepted to panic when an internal resource is not available. See template.Must. This means something is wrong with the application itself.
Here's an example from the Go standard library.
Package crypto
import "crypto"
func (Hash) New
func (h Hash) New() hash.Hash
New returns a new hash.Hash calculating the given hash function. New
panics if the hash function is not linked into the binary.

Performance improvement for web services

We have a webservice, which will be called to provide the delivery date of the product, while purchasing in eComm website.
We are using IBM Sterling Order Management in the backend, and its OOB webservice and its OOB service.
This webservice (WSDL) is taking more time, more than 40 seconds, which create timeoutexception in other integrated systems (Middleware).
So we want to improve the performance of this webservice. Could you please help me to provide the way to improve the performance ? Will it be improved if the Server's spec has been upgraded ? As it the OOB service, we can't customize it.
First of all you need to figure out the performance bottleneck. To start with you could put a verbose trace on the OOB Webservice. Use the logs and see if you can zero-in on any particular component or sql taking consuming majority of the time. If it's sql, you can tune/baseline the OOB query/tables using indexes.
If you have any user exits implemented (for the OOB API), ensure that they are lean and aren't making any expensive API calls like changeOrder API.
One of the questions to be asked here would be if the webservice needs to respond with the actual processing results or if it could move the actual processing to the background eg: separate integration server and just respond with a simple acknowledgement of the webservice request. If the service only needs to respond with an acknowledgement you could possibly move the actual processing to a separate async service.
First try to find out where the actual problem is and hence here the few pointers,
1) Check in OMS how much time the service is taking with the same input which you are using ti invoke the webservice.
2) If from OMS end response time is fine then check the network latency/bandwidth.
3) CPU usage while hitting the webservice.

Can httptest be used to test HTTP/2?

I'm wondering if this (httptest) package can be used to test HTTP/2 specific features.
Can anyone point me to some examples maybe?
I'm aware of the tool h2i, but it's an interactive tool.
I'm looking for something which is programmable.
EDIT:
What I'm really looking for is a tool, where for example I can initiate a server push and test it on the client side.
So, using this package, how do I have access to the underlying HTTP/2 stuff it uses by default?
EDIT 2:
Found some examples in the nghttp2 source:
https://github.com/tatsuhiro-t/nghttp2/tree/master/integration-tests
EDIT 3:
For me it looks like that the package net/http2 isn't meant to be used directly by anyone. I'll experiment with this one.
General testing tip (to avoid frustration)!
Don't use Fiddler to test it, it gets in between your browser and the server and breaks the HTTP2 connection.
No HTTP2 - no push.
https://github.com/summerwind/h2spec is a go program that tests whether a server implementation conforms to RFC 7540. It allows to craft individual HTTP/2 frames such as:
settings := http2.Setting{http2.SettingInitialWindowSize, 0}
http2Conn.fr.WriteSettings(settings)
or
var hp http2.HeadersFrameParam
hp.StreamID = 1
hp.EndStream = false
hp.EndHeaders = true
hp.BlockFragment = http2Conn.EncodeHeader(hdrs)
http2Conn.fr.WriteHeaders(hp)

Resources