How the John Lewis Partnership is Predicting the Future of Retail

Leading high-end retailer, John Lewis believes in just that. The partnership chain has 50 stores, 38,100 employees, 243 million euros in annual income, and a legacy reputation (153 years) to uphold…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Low Latency Event Streaming using Kafka and Websocket on GKE

This experiment benchmarks the latency associated with an event that is propagated through Kafka and through a WebSocket on Google Kubernetes Engine (GKE). Applications used as event emitter and event receiver are Java based applications using Spring Framework.

Here is an overview of the experiment setup.

Experiment setup with Kafka and Java applications on a Kubernetes cluster

4 nodes GKE Cluster (each node is the default configuration with 1 vCPU & 3.75 Go memory). Event receiver application is exposed through an https load balancer and serves a web page bootstrapping the WebSocket connexion.

An event is created by the event emitter application. This application pushes a message on a Kafka topic. The second java application, listening to this same topic, receives the message and gets the event. Once the event is received by the receiver, the event is sent through the WebSocket maintained by the receiver and dispatched to the browser.

Here is the latency distribution from the message creation to the message consumption. It includes the time required to:
- commit the message to the topic by the emitter application
- save the message on persistent volume by the Kafka instance
- receive the message by the receiver application

99.9% of the events sent by the emitter app were received less than 10ms later. As expressed by the chart, typical time was 2ms. The last 0.1% was spread beetween 11ms and 52ms. The experiment has been performed on a 10-hour window with more than 30k messages.

Event transit times through Kafka

Below is the latency distribution from the Java event receiver application to the browser through the WebSocket. As this handling is going out of Kubernetes and through the Internet, this timing is highly dependent on where the browser is located. It is given only as comparison to illustrate that typical delay introduced here is an order of magnitude larger than the delay introduced by intra-cluster communication.

99% of the events sent by the emitter app to the browser via a websocket were received less than 163ms later. As expressed by the chart, typical time was around 25ms and 50ms. The last 1% were spread between 163ms and 267ms. Of course, those results are highly dependent on the browser connexion latency and are only relevant as a point of comparison.

Event transit times through WebSocket

This experiment shows that Kafka is a good choice as an event bus. The latency introduced by Kafka is small compared to the time required to propagate the events to the external browser. The advantage of having the message persisted on disk by Kafka comes with minimal performance impact.

Even if the last mile latency is largely longer than the intra-cluster event propagation time, it is still very good in absolute. Receiving an event that is only 50 ms old on an external browser is quite respectable!

Add a comment

Related posts:

Epson L3110 Resetter With Keygen

Assalamu Alaikum friends. How are you all? I hope you all are okay. But I will definitely tell in the comments. Friends, all of you spoke to me. Sir, we need Resetter of Epson L3110 and also with…

Stepping Forward Into the Past

The experience was eye-opening — not just for Afinoguénova’s students, who moved in and around a 3D version of Dalí’s surrealist depiction of the Virgin Mary, but also for Afinoguénova, who left the…

Keep moving forward

Sometimes I find myself after a long day’s work doing things which are not overly exciting, feeling quite exhausted, not “tired” but rather “empty”. I want to do more productive things but I just…