r/leetcode • • Dec 02 '25

Question PayPal Interview Experience | System Design | Sr Software Engineer

Question
Design a notification service.

While solving the problem, for idempotency handling, I have used even-driven architecture.
The solution that I gave is publishing the messages in Kafka, and processing the messages through Flink. So that unique message gets processed exactly once, with respect to the idempotent id.

Interviewer's (Staff Software Engineer) comments

  1. There is no way to handle idempotency using event driven architecture.
  2. He was expecting solution with Redis. (Synchronous write-through caching)

I did some research, my solution is working and much-more scalable in case of burst traffic and bust notification.

I got rejected.

Was I correct?

85 Upvotes

25 comments sorted by

11

u/tired_coder2024 Dec 02 '25

‘Unique message gets processed exactly once’ at what level .. what’s your notion of ‘processed’

  1. Exactly once at producer ?
  2. Exactly once at consumer ?

3

u/Dependent-Profile426 Dec 02 '25

exactly once in consumer because of the Apache Flink's idempotency check

13

u/tired_coder2024 Dec 02 '25

Here is the deal .. I haven’t used flink in production hence if I were to interview you generally on ‘exactly-once semantics in a distributed system especially in an event driven use-case’ I’d request you to design the consider side ensuring idempotency - Consumer reads the message —> processes (DB or whatever ) —> crashes before committing the offset … when the message is redelivered .. how do you ensure exact-once processing ( not consumption ) would have been the crux of the conversation

13

u/Silencer306 Dec 02 '25

Yea I think OP wasn’t able to explain how to handle idempotency. Flink doesn’t guarantee there won’t be duplicate effects. Thats why you either use sinks that support two phase commits or have idempotent side effects.

Just saying I will use idempotent id and flink for exactly once processing will not work, you have to explain how it all works, and scenarios where you can have duplicates. Kafka also supports exactly once using idempotent producers, but you need justifications on when you use exactly once and at lease once

2

u/Electrical-Ask847 Dec 02 '25

yep this is why op failed. for having shallow superficial understanding.

6

u/reddit_user157 Dec 02 '25 edited Dec 02 '25

As someone who has extensively worked with Flink, you are confusing Flink’s exactly-once state semantics being used for Idempotency. A simple scenario - How will you handle scenarios when something breaks in producer and sends 2 events with the same message-id?

Did you get into any details on how Flink will work during the interview? Because you just sound like throwing fancy words around without experience.

Read up more here https://flink.apache.org/2018/02/28/an-overview-of-end-to-end-exactly-once-processing-in-apache-flink-with-apache-kafka-too/

2

u/Electrical-Ask847 Dec 02 '25

yep exactly. even if flink job processes exactly once. there are no such gaurentees in notifications service, network etc.

Client device needs to have a local cache that rejects duplicate notfication ids.

55

u/Party-Cartographer11 Dec 03 '25

The problem here is you are using brand names instead of the specifics of how your proposed system works.

The brand names have a pile of assumptions or features and constraints that may or may not be known by the interviewer.

This sounds more like a system integrator/IT shop answer of how existing systems work.  A software architect discussion should be more generic and about algorithms.

"I would use a distributed stream processing system which reads an ID field that ensures only once processing."

"Ok, and how would you handle when the producer has a bug and sends out duplicate IDs?"

Now talk about exactly how Flink handles or doesn't handle this (if you want to use Flink as a reference) and what you would do if it doesn't.

18

u/qrcode23 Dec 02 '25

I had to design a subscription service.

6

u/qrcode23 Dec 02 '25

But yeah that topic was a big one since we were moving money.

33

u/nsxwolf Dec 02 '25

The interviewer was wrong about your solution not working.

He had a preference for a simpler, synchronous solution with fewer moving parts - but accidentally exposed his ignorance in the process.

Not a Staff level moment for that guy.

40

u/qrcode23 Dec 02 '25

In an interviewing, interviewer is god. Make him happy. When you join a team, disagree all you want, lol.

4

u/nsxwolf Dec 02 '25

Yep. Sucks when they fail you over their hidden preferences though.

1

u/Electrical-Ask847 Dec 02 '25

yes they are not hiring machines. your job at work is not to be "correct" . That is usually the trap junior fall into and never get promoted

2

u/nsxwolf Dec 02 '25

Ok but can we admit that interviews are bad?

Let me give you this totally open ended toy problem and you can solve it however you like. But really I have a very specific solution in mind and if you don’t regurgitate it, no job for you. I won’t even give you any real hints as to what I want no matter how many clarifying questions you ask.

1

u/Electrical-Ask847 Dec 02 '25

yea i agree they shouldn't be pattern matching to what they have in mind already. but i don't belive thats what happened here though.

1

u/Adventurous-Cycle363 Dec 03 '25

Well it is not that simple. Sometimes idiots are known to deliberately mislead candidates by asking these and checking if the candidate produces the correct solution by correcting them.

0

u/NewEducator8402 Dec 10 '25 edited Dec 10 '25

This solution does not work. A side effect is an action that has a real and irreversible impact outside your program.

The real problem here is synchronized deduplication at the time of the side effect.

The solution he proposes is over-engineered for the problem.

Kafka + Flink:

✅ Highly scalable.

✅ Excellent for massive streaming.

❌ Poor response to business idempotence --> this is the issue to be resolved.

❌ Enormous cognitive cost.

❌ Operational complexity.

❌ High risk in production.

2

u/NewEducator8402 Dec 10 '25 edited Dec 10 '25

No, you were not correct in the context of the question, and the rejection is consistent.

Your solution works technically, but it does not address the problem as it was posed in the system design interview.

1. Key confusion: idempotence ≠ exactly-once processing: your answer with: Kafka + Flink + exactly-once → guaranteed idempotence, which is conceptually incorrect.

Idempotence is a business property, not a pipeline property. Exactly-once guarantees that Flink processes an event only once in its internal state, which does not guarantee that an external notification (email, SMS, push) will not be sent twice.

Even with Kafka + Flink perfectly configured, you can send an SMS twice. Concrete examples: HTTP timeout after sending → retry → double notification

2. The real problem: synchronized deduplication at the time of the side effect

A notification service has an irreversible side effect. The only reliable way is to check and record the idempotent ID at the exact moment the effect is produced.

This involves:

  • An atomic read + write
  • Before the actual sending
  • Shared between all instances

Here with Redis, you can use SETNX / write-through cache, which allows:

IF NOT EXISTS(notification_id):
    send_notification()
    store(notification_id)

So there is no way to manage idempotence with an event-driven architecture.

1

u/HumanAd2237 Dec 03 '25

In PayPal don't they have multiple rounds scheduled at once? How did you perform in the other rounds op? Also, could you tell your location?

1

u/InformationHungry163 Dec 03 '25

Whcih loc? How did you apply? Yoe?

1

u/Least-Gift-7646 Dec 03 '25

even i had to design a subscription service , i had 2 more rounds coming up its for san jose location

1

u/Mindless-Answer5643 Jan 19 '26

If I get offer letter and I give notice in my current company... has there been any scenario that paypal hr has then turned down the offer because of any hiring freeze or any other reason?

1

u/Subject-Pie-3907 Apr 26 '26

you had to spit out what he was prepared to listen.