Amazon SDE2 Interview Experience

Anonymous User
399
Apr 18, 2025
Apr 18, 2025

I had my first round of Amazon interview yesterday which was LLD round. We started off with basic intros and jumped into a few LP questions which took about 15-18 mins.

We later switched to LLD question where he asked me to design a Rate Limiter. He asked me to assume the requirements by myself. I started off with the basic requirements and explained the token bucket algorithm which would be used to design the Rate Limiter.

He asked me to code the algorithm and I did it accordingly by taking into account all the parameters. My code was something like this:

class TokenBucket:
def init(self, capacity, refill_rate):

    self.capacity = capacity
    self.tokens = capacity
    self.refill_rate = refill_rate
    self.last_refill_timestamp = time.time()
    self.lock = threading.Lock()

def refill(self):
    now = time.time()
    elapsed = now - self.last_refill_timestamp
    added_tokens = elapsed * self.refill_rate
    self.tokens = min(self.capacity, self.tokens + added_tokens)
    self.last_refill_timestamp = now

def allow_request(self, tokens_required=1):
    with self.lock:
        self.refill()
        if self.tokens >= tokens_required:
            self.tokens -= tokens_required
            return True  # Allowed
        else:
            return False  # Rate limited

He then asked me a follow up where if there are 10 threads running and there are 1000 API calls made, how would you handle it. I quite didn't understand this. Can someone help me out?

Also, what are the chances I might get a hire?

Comments (2)