Design Techniques for Building Streaming Data, Cloud-Native Applications: Part 2 - Akka Streams, Kafka Streams, and Friends

A Look At Streaming Libraries and Fast Data Architectures

This is the second of six posts in our cloud-native series that focuses on streaming data applications. In the first post, we summarized common requirements, architecture considerations, and design patterns. We explored a few specific tools, namely Apache Spark and Apache Flink, which are engines, the term we use for systems designed for large-scale processing, often with standalone services to which work is submitted and subdivided across a cluster. (There are various ways to run these jobs…)

This post explores an alternative class of compute tools, libraries that provide streaming semantics, but which you embed in your microservices.

For a more detailed examination of these topics, see my free O’Reilly report, Fast Data Architectures for Streaming Applications. The last several posts in this series on streaming will discuss serving machine learning and artificial intelligence models in streaming applications, authored by Boris Lublinsky. For an in-depth analysis of this topic, see his free O’Reilly report, Serving Machine Learning Models.

For comparison, here is the architecture diagram I shared in the first post:

Figure 1: Representative Streaming Architecture

Figure 1 is taken from my Fast Data Architectures for Streaming Applications report. The numbers correspond to notes in the report. I won’t discuss all the details here, but note a few things that I also highlighted in the previous post. Kafka plays the central role of integrating services, both data processing and microservices, and capturing incoming data. Spark and Flink are popular tools for processing data, which I discussed in the previous post. This post discusses Akka Streams and Kafka Streams.

Characteristics of a Streaming Library

The previous post discussed characteristics of engines like Spark and Flink. In contrast, the libraries all share a few common characteristics:

  1. They provide high-level abstractions for data transformations, but don’t abstract away the partitioning that might be required in a large data set. You have to partition the data as you see fit, e.g., into Kafka topic partitions, and you have to explicitly launch instances of your application targeted to one or more partitions, as appropriate.

  2. They provide tremendous flexibility in how you integrate streaming into the rest of the application logic.

  3. They can run with very low resource overhead, including the time it takes to process each record, depending on the application.

Specifically, for Akka Streams vs. Kafka Streams:

  1. Kafka Streams supports event-time windowing, processing triggers, and SQL over streams.

  2. Akka Streams supports fine-grained manipulation of data flows and record processing.

  3. Kafka Streams reads and writes Kafka topic partitions. Akka Streams integrates with a wide variety of sources and sinks, through the Alpakka library.

  4. Both libraries support durability and resiliency mechanisms to enable effectively once processing of records and preservation of evolving application state, even in the presence of failures.

While the engines like Spark and Flink provide a lot of benefits vs. drawbacks, the libraries are complementary:

  1. Integration with microservices and the engines usually requires that you run the engines separately from the microservices and exchange data through Kafka topics or other means. This adds some latency and more running applications at the system level, but also helps prevent monolithic applications. In contrast, the libraries are embedded into the microservices, providing fast access (the cost of a function call).

  2. Compared to the engines, libraries enable very flexible choices for how data is processed at runtime and how the applications are deployed, monitored, and managed, including scaling. However, you have to implement many of these capabilities yourself.

  3. Library-based applications are often easier to tune, because they are fundamentally simpler systems, but the autosizing on start-up provided by Spark and Flink and their abilities to scale up and down in some context are capabilities you have to implement yourself in a library-based approach.

    경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
    어린이용이며, 설치가 필요없는 브라우저 게임입니다.
    https://s1004games.com

  4. The low overhead of these systems make them ideal for smaller data streams, especially when partitioning is not required.

Comparing the Streaming Engines and Libraries

So, which should you choose, Apache Spark, Apache Flink, Akka Streams, or Kafka Streams. Here are some basic rule-of-thumb guidelines. You could easily use more than one option, depending on the particular problem:

  • Pick a streaming engine when your data streams are usually large enough to require partitioning and you want to minimize manual handling of this task:

    • Pick Spark if you already use it for batch processing or you want lots of options for out-of-the-box integration with machine learning systems.

    • Pick Flink if you aren’t using Spark for batch processing or you need the most state-of-the-art streaming semantics.

  • Pick a streaming library when partitioning is less often required or you prefer to work with the same microservices tools and processes you already know:

    • Pick Akka Streams when you need very fine-grained control over the data flow processing and you want the full suite of Lightbend Platform tools for your microservices (e.g., the rest of Akka!).

    • Pick Kafka Streams if all your streaming data is stored in Kafka, so your streaming jobs only need to read from and write to Kafka topics, or you come from a data background where SQL-like operations and windowing semantics are important to you.

Note that you can still complement Kafka Streams with the Lightbend Platform for the rest of your microservice needs.

There’s really a lot more to it. See my O’Reilly report listed above for more details on these choices and how to select which ones are best for your needs. Also, my colleague Boris Lublinsky and I developed several tutorials that illustrate using these options. They are freely available on GitHub:

  • Kafka-with-akka-streams-kafka-streams-tutorial - Uses Scala and Java examples for stream processing with Akka Streams and Kafka Streams. The sample application serves machine learning models (i.e., scores data records with them), including the ability to dynamically update the models in the running applications.

  • Model-serving-tutorial - An update to the previous tutorial that is more focused on the model serving problem. It adds examples using Spark, Flink, and TensorFlow serving. The code examples are all in Scala.

The next post in this series explores the important problem of managing state in a streaming application and how to access that state from outside the application, e.g., using queryable state. 

Finally, if you'd like to learn how to make using Akka Streams and Spark more simple with Kafka and Kubernetes, check out Lightbend Pipelines, the newest module in Lightbend Platform. You can watch a 2-min intro video, or read more about it here:

CHECK OUT LIGHTBEND PIPELINES

 

[출처] https://www.lightbend.com/blog/cloud-native-streaming-data-with-akka-streams-kafka-steams

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
20 [nest.js] [NestJS] NestJS 구조 이해를 위한 필수 개념 정리 - Node.js/TypeScript/Express 비교 포함 file 졸리운_곰 2025.12.12 501
19 [node.js 개발] Apache Reverse Proxy 설정(아파치와 노드 연동) file 졸리운_곰 2024.03.17 300
18 [node.js 개발] PM2로 Node.js 앱 프로세스 배포하기 file 졸리운_곰 2024.03.16 405
17 [node.js 개발] PM2를 활용한 Node.js 무중단 서비스하기 file 졸리운_곰 2024.03.16 517
16 [node.js 응용] Next.js : Next.js14에 Mysql연결하기 졸리운_곰 2024.03.03 379
15 [node.js 응용] Node.js에서 다른 파일의 함수를 "include" 하는 방법 졸리운_곰 2024.02.28 428
14 [node.js 응용] NodeJS 에서 mqtt 사용하기 file 졸리운_곰 2024.02.23 399
13 [node.js 응용] Next.js 기본 개념정리 file 졸리운_곰 2024.02.23 432
12 [node.js 응용] ejs 사용설명서 file 졸리운_곰 2023.11.25 371
11 [node.js 응용] Build a Node.js Proxy Server in Under 10 minutes! file 졸리운_곰 2023.05.07 468
10 [node.js 응용] node - pm2로 node.js 프로세스 관리하기 - 기본 명령어, 실행하기 file 졸리운_곰 2023.04.25 407
9 [node.js 응용] Node.js | MySQL과 연동(mysql모듈) - CRUD 2/2 졸리운_곰 2023.03.31 231
8 [node.js 응용] Node.js | MySQL과 연동(mysql모듈) - CRUD 1/2 file 졸리운_곰 2023.03.31 484
7 [node.js 응용] PM2 - Node.js 프로세스 관리 도구 file 졸리운_곰 2021.12.10 410
6 [node.js][nodejs] [Linux] 리눅스 내 Node.js 및 NPM 최신 버전으로 유지하기 file 졸리운_곰 2021.10.11 484
5 [node.js][typescript] 5분 안에 보는 TypeScript file 졸리운_곰 2021.07.03 428
4 Getting started with RabbitMQ and Node.js file 졸리운_곰 2019.05.09 466
3 [Node.js + RabbitMQ] Node.js + socket.io + RabbitMQ 이용한 실시간 메시지 처리 file 졸리운_곰 2019.05.09 352
2 node.js 서버 장애시 자동 재시작 설정 [forever 사용] 졸리운_곰 2019.01.24 884
1 Express 앱용 프로세스 관리자 졸리운_곰 2018.10.16 604
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED