


Is it possible to create a service in Go that both consumes a message stream (from Kafka) and reads REST API requests?
Question content
I recently read an article "Sharing data between large-scale microservices"
This picture is about asynchronous connections.
If I remember correctly, the Order page in this picture The service appears to be able to read the message stream from Kafka, and also read REST API requests from the front-end application.
So, I'm wondering if it's possible to write a service that can do both tasks at the same time:
- Read the message stream from Kafka
- Read REST API request
Only in 1 service, such as in Go.
Is this a good idea?
Workaround
Yes, you can definitely write a Go service that consumes from Kafka and exposes a REST endpoint. However, this is not an ideal design decision.
The Kafka-based streaming system allows asynchronous communication between producers and consumers. However, REST API-based systems communicate synchronously between the caller and the callee.
The availability guarantees are different between synchronous and synchronous mode communication. A system based on Kafka Streams will have different availability guarantees than a REST API. In a streaming system, we focus on message processing throughput, while in end-to-end synchronous communication, latency is the main concern (you don't want the caller to wait for a long time to get the result).
If we put these two types of systems in one service, it will be difficult to understand the availability of the service. Additionally, an asynchronous part or a synchronous part of a service may play into a noisy neighbor on the other side, making the service unavailable.
Therefore, in general, it is recommended to treat REST-based APIs and Kafka streams as two independent services.
The above is the detailed content of Is it possible to create a service in Go that both consumes a message stream (from Kafka) and reads REST API requests?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The MongoDB database is known for its flexibility, scalability, and high performance. Its advantages include: a document data model that allows data to be stored in a flexible and unstructured way. Horizontal scalability to multiple servers via sharding. Query flexibility, supporting complex queries and aggregation operations. Data replication and fault tolerance ensure data redundancy and high availability. JSON support for easy integration with front-end applications. High performance for fast response even when processing large amounts of data. Open source, customizable and free to use.

Yes, Node.js can be used for front-end development, and key advantages include high performance, rich ecosystem, and cross-platform compatibility. Considerations to consider are learning curve, tool support, and small community size.

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

Vue is a front-end JavaScript framework for building user interfaces, focusing mainly on client-side code development. Its features include: 1. Componentization: improving code maintainability and reusability; 2. Responsive data binding: UI automatically updates ; 3. Virtual DOM: Optimize rendering performance; 4. State management: Manage application shared state. Vue is widely used for building single page applications, mobile applications, desktop applications, and web components.

Combination of Golang and front-end technology: To explore how Golang plays a role in the front-end field, specific code examples are needed. With the rapid development of the Internet and mobile applications, front-end technology has become increasingly important. In this field, Golang, as a powerful back-end programming language, can also play an important role. This article will explore how Golang is combined with front-end technology and demonstrate its potential in the front-end field through specific code examples. The role of Golang in the front-end field is as an efficient, concise and easy-to-learn

Yes, you can use jQuery with Vue. Common reasons for using jQuery include: integrating with legacy code, using specific jQuery plugins, and handling complex DOM manipulations. To use jQuery in a Vue project, you need to install the jQuery library and import it into the component. However, it is recommended to use it with caution and only when absolutely necessary to avoid conflicts with Vue.

The steps to start a project using WebStorm are as follows: Open WebStorm IDE, open or create a project; right-click the project file and select "Run"; in the "Run/Debug Configuration" window, select the launch configuration to be used to launch the project; configure Start the configuration (optional); click the "Run" button to start the project; if necessary, you can use WebStorm's debugging tools to debug the project.

Vue.js is a progressive JavaScript framework mainly used to simplify the front-end development process. Its functions include: declarative template syntax to improve readability; responsive data binding to automatically synchronize interface and data; component development to improve maintainability; state management (Vuex) to simplify state management; routing (Vue Router) , manage single-page applications; enrich tools and ecosystem to accelerate development.
