Using k6 with Event Hub Messaging by Producing and Consuming messages

Hello all,

Does k6 have an official interface to Event Hub or is it something that is being worked upon?

It’s just that I am using k6 to simulate producing messages to an Event Hub instance and then consuming those messages. The ultimate objective is to measure how long it takes to enqueue to Event Hub the messages and then these messages becoming dequeued on the Cosmos DB - the entire time taken from enqueueing to dequeuing the message.

Right now, I have configured a make shift api server for the producer and one api server for the consumer both listening on separate ports. Then I use k6 to send the messages that call the make shift endpoint which calls the producer code and then one that calls the consumer code. Both producer and consumer codes are configured with the Event Hub instance in Azure.

I am running the test over the http protocol and the endpoint is local… both of which can skew the stats due to being http and local connection to the Event Hub. However, i get timeouts for api requests as I am simulating large amounts of data per second… yet all the messages appear to progress through from both producer and consumer - as I can see that in Azure all the messages are correctly being churned.

My question then overall is that is the above the right approach as I now have a local host as well http to make the calls and I can’t get a 200 response most of the time especially from the consumer thus skewing the results? Is there a better way that i can connect to the Event Hub and directly send messages rather than via http call in k6?

Thanks in advance!
Shayan.

Hi @shayansadullah,

Welcome to our community forums! :tada:

Does k6 have an official interface to Event Hub or is it something that is being worked upon?

As far as I know, there’s no official nor community maintained k6 extension to connect to Event Hub. While there’s the AWS JavaScript library (see k6-jslib-aws), which is officially maintained, and xk6-aws, which I personally build on my spare time, I’m not aware of anything like that for Azure services.

My question then overall is that is the above the right approach as I now have a local host as well http to make the calls and I can’t get a 200 response most of the time especially from the consumer thus skewing the results? Is there a better way that i can connect to the Event Hub and directly send messages rather than via http call in k6?

I’m not quite sure your approach is a good one, especially for load tests, cause you’ll local environment (hardware & network) will likely be the bottleneck. Is there any alternative, while still reaching the Event Hub through HTTP but without doing so through a local HTTP server (e.g. reaching Event Hub through an HTTP request but directly from the k6 script), which sounds fine per se?

Regards!

Thanks @joanlopez, Happy New Year and much appreciated for the response.

I believe I need to re-word my requirements.

I am looking for a way to consume already generated messages by EventHub. I am looking at CosmosDb as the consumer consuming say ~5000 messages in one second. And I need to run the k6 test as this consumer and see whether this consumer (or potentially other consumers) are resilient and provide low latency while consuming these messages.

I wonder therefore if there is a k6 library that enables me to do that? Thanks.

Hey @shayansadullah,

I wonder therefore if there is a k6 library that enables me to do that?

I’m sorry, but I strongly suspect there’s none.
However, you can always try to write your own extension.