Tüm uzmanlıklarTeknoloji · İş görüşmesi

Kafka

Kafka soruları yalnızca API'yi değil, log'u anlayıp anlamadığınızı sınar. Partition'ları, offset'leri ve garantileri sade İngilizceyle anlatmayı öğrenin.

Kelimeler → ifadeler → cümleler → konuşma

SpeakRole’i dene ↗
İş görüşmesiKafka
V

When is Kafka a better fit than a simple message queue?

0:18
Mülakat sorusu

Kafka

Kafka mülakatları genellikle Kafka'nın neden var olduğuyla ve klasik bir mesaj kuyruğundan farkıyla başlar, ardından partition'lara, consumer group'lara ve teslim garantilerine geçer. Birçok soru aslında bir şey bozulduğunda ne olduğuyla ilgilidir.

Küçük bir örnekle anlatın: orders adlı bir topic, üç partition ve iki consumer. Somut bir resim hem size hem mülakatçıya yardımcı olur ve belirsiz sözcüklere kaçmanızı önler.

  • ✓Kelimeler → ifadeler → cümleler → konuşma
  • ✓Yanıtın anlamı
  • ✓Dil

Sık sorulan mülakat soruları ve örnek cevaplar

When is Kafka a better fit than a simple message queue?

Kafka ne zaman basit bir mesaj kuyruğundan daha uygundur?

Mülakatçı ne duymak ister. Yeniden okuma (replay) imkânı olan bir log fikri, birden fazla consumer group, yüksek throughput ve dürüst bir sınır.

Yüksek sesle çalışmak için İngilizce örnek cevap

Kafka is a distributed, append-only log. Messages are not removed when they are read. They stay for a configured time, and each consumer group keeps its own position, called an offset. This is useful when several systems need the same events, when I want to replay history, for example after a bug fix, or when throughput is very high. A simple queue like RabbitMQ is often better for task distribution with complex routing, where each message is processed once and then disappears. If the load is small and I do not need replay, a simple queue is easier to run.

How do partitions affect ordering and scaling?

Partition'lar sıralamayı ve ölçeklemeyi nasıl etkiler?

Mülakatçı ne duymak ister. Sıralamanın yalnızca bir partition içinde geçerli olması, key'ler ve paralelliğin birimi olarak partition'lar.

Yüksek sesle çalışmak için İngilizce örnek cevap

A topic is split into partitions, and each partition is an ordered log. Kafka guarantees ordering only inside one partition, not across the whole topic. The producer chooses the partition, usually by hashing the message key, so all messages with the same key, for example one customer ID, go to the same partition and stay in order. Partitions are also the unit of parallelism: more partitions allow more consumers to work in parallel. But the number cannot be reduced later, and increasing it changes where new messages with the same key go, so I choose it with growth in mind.

What is a consumer group, and what happens when a consumer fails?

Consumer group nedir ve bir consumer çöktüğünde ne olur?

Mülakatçı ne duymak ister. Partition ataması, rebalance ve commit edilmiş offset'ler.

Yüksek sesle çalışmak için İngilizce örnek cevap

A consumer group is a set of consumers that share the work of a topic. Each partition is assigned to only one consumer in the group, so the group processes the topic in parallel without duplicates. If there are more consumers than partitions, the extra ones stay idle. When a consumer crashes or a new one joins, Kafka rebalances: it reassigns partitions between the members. The new owner continues from the last committed offset. During a rebalance, processing pauses for a moment, so I try to keep processing fast and to avoid long pauses that look like a failure.

What delivery guarantees does Kafka give?

Kafka hangi teslim garantilerini verir?

Mülakatçı ne duymak ister. En fazla bir kez, en az bir kez ve tam olarak bir kez (exactly once); her biri için koşullarıyla birlikte.

Yüksek sesle çalışmak için İngilizce örnek cevap

In practice there are three levels. At most once means that a message can be lost but is never repeated. At least once means that it is never lost but can be repeated, and this is the most common setup: I commit the offset only after processing. Exactly once is possible with the idempotent producer and transactions, mainly for flows from Kafka to Kafka. For a producer, I set acks to all and use enough in-sync replicas, so a broker failure does not lose data. Because duplicates can still happen, I make my consumers idempotent.

What is consumer lag, and what do you do when it grows?

Consumer lag nedir ve büyüdüğünde ne yaparsınız?

Mülakatçı ne duymak ister. Net bir tanım, bir teşhis adımı ve birkaç olası çözüm.

Yüksek sesle çalışmak için İngilizce örnek cevap

Consumer lag is the difference between the latest offset in a partition and the offset the consumer has processed. If it grows, the consumers cannot keep up. First I look at why: is processing slow because of a database call, or did the producer traffic increase? Then I have a few options. I can optimise the processing, add consumers up to the number of partitions, or add partitions if I need more parallelism. I set an alert on lag, because a growing lag is usually the first signal of a problem, long before users complain.

Anahtar terimler nasıl telaffuz edilir

Kafka
KAF-kı
partition
par-Tİ-şın
offset
OF-set
broker
BRO-kır
throughput
THRU-put (th: dil dişlerin arasında)
replica
REP-li-kı

Cevap vermek için kullanışlı kalıplar

  • Think of a topic as an append-only log.Bir topic'i, yalnızca sonuna ekleme yapılan bir log olarak düşünün.
  • Ordering is guaranteed only within a partition.Sıralama yalnızca bir partition içinde garanti edilir.
  • We commit the offset after processing.Offset'i, mesajı işledikten sonra commit ederiz.
  • The consumer has to be idempotent, because duplicates can happen.Consumer idempotent olmalı, çünkü mesajlar birden fazla kez gelebilir.
  • It depends on the required guarantees and the throughput.Bu, gereken garantilere ve throughput'a bağlı.
  • In that case I would look at the consumer lag first.Bu durumda önce consumer lag'e bakardım.

Sık yapılan hatalar

  • Kafka'nın global sıralama garanti ettiğini söylemek. Kafka sıralamayı yalnızca bir partition içinde garanti eder.
  • Koşullarını söylemeden “exactly once” demek. Idempotent producer'lardan ve transaction'lardan söz edin; consumer'ların yine de idempotent olması gerektiğini ekleyin.
  • Kafka'yı her şey için bir veritabanı gibi görmek. Olay akışları için mükemmeldir; bu yüzden neleri başka yerde sakladığınızı söyleyin.
  • Arızalardan hiç söz etmemek. Bir broker ya da consumer çöktüğünde ne olduğunu açıklayın.

Sıkça sorulan sorular

Sıradan bir backend mülakatında Kafka'nın iç yapısını bilmem gerekir mi?

Modeli bilmeniz gerekir: topic'ler, partition'lar, offset'ler, consumer group'lar ve teslim garantileri. Controller ya da log segment'leri gibi iç yapı konuları uzmanlık pozisyonlarına aittir.

Hangi araçlardan veya sürümlerden söz etmeliyim?

Kullandıklarınızı söyleyin: client kütüphanesini, lag'i nasıl izlediğinizi ve schema registry kullanıp kullanmadığınızı. Dürüst ayrıntılar sürüm numaralarından daha önemlidir.

Kafka'yı not almadan anlatmayı nasıl çalışabilirim?

Üç partition'lı bir topic için küçük bir örnek çizin ve bir mesaj geldiğinde, bir consumer çöktüğünde ve bir consumer eklediğinizde ne olduğunu anlatın. Yaklaşık bir dakika sürene kadar yüksek sesle tekrarlayın.

Bir cevabı okumak ile onu söylemek aynı şey değildir. Her soruyu yüksek sesle çalışın, ardından kendi cevabınızın anlamını ve dilini karşılaştırın.

SpeakRole’i dene ↗

Bu alandaki diğer konular