Search code examples
pythonlocust

Load-testing Asp.net Core SignalR using Locust


I would like to load-test a SignalR service using Locust. I found that the following library can send and receive SignalR requests: https://pypi.org/project/signalrcore/

Now, according to the Locust docs, the next step would be to write a custom client for Locust that can send SignalR requests. But there is the following warning:

Any protocol libraries that you use must be gevent-friendly (use the Python socket module or some other standard library function like subprocess), or your calls are likely to block the whole Locust/Python process.

Some C libraries cannot be monkey patched by gevent, but allow for other workarounds. For example, if you want to use psycopg2 to performance test PostgreSQL, you can use psycogreen

I am a beginner in Python so I don't understand exactly what it means. The library "signalrcore" I am using is 100% synchronous. Does it means I can't use it with Locust? I found an a fork of signalrcore that uses asyncio. Should I use that fork instead and just make sure all my signalr calls are non blocking?

Thanks!


Solution

  • SignalRCore seems to use requests and websocket-client under the hood, both of which are gevent-friendly. I cant say for sure, but I’d give it 90% probability that it will work ”out of the box” :)

    If you do use the asyncio one you’d need to do some magic yourself. At least I have never combined that with gevent.