Member-only story

Real-Time Trading App: Golang, Kafka, Websockets — Setting up Consumer & Websockets(PART-3)

Kamalesh D
6 min readJan 4, 2024

Step-by-step guide on configuring a Kafka consumer in Golang for real-time data processing.

golang
PART-3

Creating Consumer Service & Websockets

In this ongoing series, we’ve delved into the introductory aspects of our tech stack and explored the high-level architecture. Our journey began with the implementation of a producer service using Kafka and Golang. Having accomplished this initial phase, the focus now shifts to the creation of a consumer service. We will delve into the process of actively listening for Kafka events and seamlessly transmitting real-time ticker data to the frontend using websockets.

Why did we choose to employ websockets instead of directly integrating Kafka on the frontend?

  • In the initial post, it was highlighted that Kafka lacks substantial support for web browsers due to various reasons. Notably, Kafka primarily utilizes TCP, and browsers tend to keep TCP connections open for very brief durations. Additionally, Kafka’s distribution policy, where messages are spread across consumers, poses a challenge when each browser tab is treated as a separate consumer. This distribution not only affects tabs but also extends to other devices consuming the data.

--

--

Kamalesh D
Kamalesh D

Written by Kamalesh D

DevOps and Cloud Enthusiast | Cyber Security | DevSecOps Engineer@FordMotors | https://dev.to/kamaleshseervi

Responses (2)

Write a response