Logo

Coding preview

Rate-Limited PubSub

What this preview is

About this preview

Rate-Limited PubSub is a medium quant coding problem on language knowledge in Cpp / Python, asked at Quant.

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.

Implementing a rate-limited publish-subscribe system

This medium-difficulty coding problem tests your ability to design and implement a distributed messaging system with rate-limiting constraints—a core concern at quantitative trading firms where market-data feeds can overwhelm downstream consumers. The challenge lies in balancing correct subscription management, efficient message delivery, and accurate rate-limit tracking across a sliding time window.

A working solution requires careful bookkeeping: maintaining subscriber-to-topic mappings, tracking message counts per subscriber within the active time window, and enforcing a global (not per-topic) rate limit. You'll need to handle window expiry correctly as time advances, manage subscriptions and unsubscriptions, and silently drop messages when a subscriber hits their quota—without affecting other subscribers to the same topic.

  • Sliding-window rate limiting and timestamp-based expiry
  • Efficient data structures for topic subscriptions and message counts
  • State management under sequential time progression
  • Edge cases: duplicate subscriptions, unsubscribe during window, window boundary conditions