processone/tsung

Memory issues with `match` on HTTP responses of SSE endpoints

pavelsolomin opened this issue · 1 comments

Hello!

I use Tsung HTTP sessions to load test SSE endpoints of my Web application. At the moment, there seems to be no support for SSE sessions in Tsung, so, I do a "normal" HTTP GET to an SSE endpoint, and keep Tsung users stuck with open connections. So far, it was sufficient for my current needs, but I started getting Tsung memory issues with matchers.

Tsung version

$ $HOME/.asdf/bin/tsung -v
Tsung version 1.7.1_dev

Issue

When doing an HTTP GET to an endpoint with endless response like this:

                    <request subst="true">
                        <http url="%%_stream_url%%" method="GET" version="1.1">
                            <http_header name="Connection" value="keep-alive"/>
                            <http_header name="Content-Type" value="text/event-stream"/>
                        </http>
                    </request>

Tsung memory is stable

Screen Shot 2020-02-05 at 10 09 46 PM

But things change as soon as I add a matcher

                    <request subst="true">
                        <match do='restart' when='nomatch' name='03_get_stream_nomatch_200'>200</match>
                        <http url="%%_stream_url%%" method="GET" version="1.1">
                            <http_header name="Connection" value="keep-alive"/>
                            <http_header name="Content-Type" value="text/event-stream"/>
                        </http>
                    </request>

Tsung memory is always growing

Screen Shot 2020-02-05 at 10 11 29 PM

Expected behavior

When I do this:

<match do='restart' when='nomatch' name='03_get_stream_nomatch_200'>200</match>

I expect, given that status code arrives before the endless payload, that this matcher does not look for anything else besides the first line of an HTTP response.

I also expected Tsung to have some buffering of HTTP responses, such that it might deliver response data in chunks to the matcher, and not to keep loading the entire response forever. For example, curl http://localhost:4001/stream (example server code is attached) does not show such behavior of growing memory.

How to reproduce

I attached an archive with example SSE server and two Tsung scripts for reproducing this locally.

sse-example-server.tar.gz

I would also appreciate general suggestions regarding the approaches of using Tsung for my use case. I admit that using HTTP session is not ideal, there might be better ways to test SSE endpoints.

Thank you in advance.

I am also wondering a bit how to deal with SSE, as that is the main data transport channel for our SPA. If you ever publish more about your approach it would be great if you could add a pingback here (subscribing to this issue for now).