0Pricing
Apache Kafka & Stream Processing Fundamentals · 강의

대화형 쿼리와 상태 저장소

Kafka Streams가 로컬 상태 저장소를 직접 조회할 수 있도록 노출하여 스트림 애플리케이션을 짧은 지연 시간의 구체화된 뷰로 바꾸는 방법을 배우세요.

대화형 쿼리와 상태 저장소은(는) CoddyKit의 무료 Apache Kafka & Stream Processing Fundamentals 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Apache Kafka & Stream Processing Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Apache Kafka & Stream Processing Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

State Stores Recap

Stateful operations like aggregations and joins keep their data in state stores — local key-value stores backed by changelog topics for fault tolerance.

Normally results flow out to a topic, but they also live right inside your app.

What Are Interactive Queries?

Interactive Queries (IQ) let your application read those local state stores directly — no extra database, no re-consuming a topic.

Your streaming app effectively becomes a queryable materialized view.

Naming a Store

To query a store you must name it during materialization.

KTable<String, Long> counts = builder
    .stream("clicks")
    .groupByKey()
    .count(Materialized.as("clicks-store"));

Getting a Read Handle

After the app is running, fetch a read-only view of the store from the KafkaStreams instance.

ReadOnlyKeyValueStore<String, Long> store =
    streams.store(StoreQueryParameters.fromNameAndType(
        "clicks-store",
        QueryableStoreTypes.keyValueStore()));

Point Lookups & Range Scans

Once you have the store, query it like a map.

Long value = store.get("user-42");

KeyValueIterator<String, Long> all = store.all();
while (all.hasNext()) {
  KeyValue<String, Long> kv = all.next();
}
all.close();

The Distribution Problem

State is partitioned across app instances. A given key lives on only one instance.

If you query the wrong instance, you won't find the key — so the app needs to know who owns each key.

Discovering Key Owners

Kafka Streams can tell you which instance hosts a key, given the store name and key serializer.

KeyQueryMetadata meta = streams.queryMetadataForKey(
    "clicks-store", "user-42", Serdes.String().serializer());
HostInfo host = meta.activeHost();

Exposing application.server

Set application.server so each instance advertises its host and port. This metadata powers cross-instance routing.

props.put(StreamsConfig.APPLICATION_SERVER_CONFIG,
    "node1.internal:8080");

Building a Query REST Layer

A typical pattern: wrap the app in an HTTP server. On a request, find the owning host. If it's local, read the store; otherwise proxy to the remote instance.

Handling Rebalances

During rebalances, stores may be migrating and temporarily unavailable, raising InvalidStateStoreException.

  • Retry with backoff.
  • Check KafkaStreams.State.RUNNING before querying.

When to Use IQ

Interactive Queries shine when you want:

  • Low-latency reads of aggregated state.
  • To avoid a separate serving database.
  • A self-contained, scalable materialized view.

For complex ad-hoc queries, a dedicated store may still be better.

Quick Check

Test your understanding of interactive queries.

Recap

You learned Interactive Queries.

  • Name a store, then get a read-only handle from KafkaStreams.
  • State is partitioned; use queryMetadataForKey to find owners.
  • Set application.server and proxy cross-instance requests.
  • Handle rebalance exceptions with retries.

자주 묻는 질문

“대화형 쿼리와 상태 저장소” 강의는 무료인가요?

네 — “대화형 쿼리와 상태 저장소” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Apache Kafka & Stream Processing Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Apache Kafka & Stream Processing Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

“대화형 쿼리와 상태 저장소”에서 뭘 배우나요?

Kafka Streams가 로컬 상태 저장소를 직접 조회할 수 있도록 노출하여 스트림 애플리케이션을 짧은 지연 시간의 구체화된 뷰로 바꾸는 방법을 배우세요. 브라우저에서 직접 실행하는 실습 코드로 Apache Kafka & Stream Processing Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Apache Kafka & Stream Processing Fundamentals을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Apache Kafka & Stream Processing Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“대화형 쿼리와 상태 저장소” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Apache Kafka & Stream Processing Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Apache Kafka & Stream Processing Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Kafka Streams의 윈도우 연산
  2. 스트림의 조인 및 집계
  3. 스트림 분석을 위한 KSQL 소개
  4. 대화형 쿼리와 상태 저장소
← Apache Kafka & Stream Processing Fundamentals(으)로 돌아가기