Meta logo

Meta Software Engineer System Design Questions

46 practice questions for Meta Software Engineer interviews

Meta software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for Meta.

system design Medium messaging #1

1. Design WhatsAppMailbox — reliable message delivery through polling APIs


Background
WhatsApp clients may need to retrieve messages through request/response APIs rather than a persistent WebSocket connection. Model an in-memory service that supports retry-safe sending, non-destructive polling, and explicit acknowledgments when clients reconnect. This is a scoped OOP adaptation of a community-reported Meta interview prompt about WhatsApp-style messaging using API calls instead of WebSockets, not a description of WhatsApp's production implementation.
Requirements
1. Implement a WhatsAppMailbox class for direct messages. Each recipient has an independent sequence starting at 1. Every new message for that recipient receives the next sequence number, regardless of its sender.
2. Make sending idempotent using (sender_id, request_id). Retrying with the same recipient and text returns the original sequence number without creating another message, even if the original was acknowledged. Reusing that key with a different recipient or text raises ValueError without changing state.
3. poll returns up to limit unacknowledged messages in ascending sequence order. Polling does not remove messages: consecutive polls without an acknowledgment return the same prefix. Track the highest sequence ever returned by a poll for each recipient.
4. acknowledge cumulatively removes all messages through the supplied sequence. The sequence must be between 0 and that recipient's highest-ever-polled sequence, inclusive; otherwise raise ValueError without changing state. Valid acknowledgments at or below the already-acknowledged sequence are no-ops. Return the number of newly removed messages.
5. unread_count returns the number of unacknowledged messages, including messages already polled. Unknown users have empty mailboxes, a highest-ever-polled sequence of 0, and an unread count of 0. Returned messages must be immutable so callers cannot modify stored message data.
Class API
  • WhatsAppMailbox() — Construct an empty service.

  • send(sender_id: str, recipient_id: str, request_id: str, text: str) -> int — Enqueue a new message or return the sequence from an identical retry.

  • poll(recipient_id: str, limit: int) -> list[Message] — Return the earliest pending messages; raise ValueError unless 1 <= limit <= 100.

  • acknowledge(recipient_id: str, through_sequence: int) -> int — Cumulatively acknowledge messages, subject to the delivery bound above.

  • unread_count(recipient_id: str) -> int — Return the current pending-message count.

  • Message — An immutable record with sequence: int, sender_id: str, recipient_id: str, and text: str.


Example 1:
Input sequence, starting with a new service:
[
  {"method":"send","args":["alice","bob","req-1","Hi"]},
  {"method":"send","args":["alice","bob","req-1","Hi"]},
  {"method":"send","args":["carol","bob","req-1","Hello"]},
  {"method":"poll","args":["bob",1]},
  {"method":"poll","args":["bob",1]},
  {"method":"acknowledge","args":["bob",1]},
  {"method":"poll","args":["bob",10]},
  {"method":"unread_count","args":["bob"]}
]

Output, with immutable records serialized as JSON objects:
[
  1,
  1,
  2,
  [{"sequence":1,"sender_id":"alice","recipient_id":"bob","text":"Hi"}],
  [{"sequence":1,"sender_id":"alice","recipient_id":"bob","text":"Hi"}],
  1,
  [{"sequence":2,"sender_id":"carol","recipient_id":"bob","text":"Hello"}],
  1
]

Explanation: Alice's retry creates no message. Carol can use the same request ID because idempotency keys include the sender. Polling twice returns sequence 1 twice. Acknowledging it leaves only sequence 2 pending.
Example 2:
Input sequence, starting with a new service:
[
  {"method":"send","args":["alice","bob","r1","Hi"]},
  {"method":"acknowledge","args":["bob",1]},
  {"method":"poll","args":["bob",10]},
  {"method":"acknowledge","args":["bob",1]},
  {"method":"send","args":["alice","bob","r1","Hi"]},
  {"method":"send","args":["alice","bob","r1","Changed"]},
  {"method":"acknowledge","args":["bob",1]},
  {"method":"unread_count","args":["bob"]}
]

Output; the test harness represents a raised ValueError as an error object and continues:
[
  1,
  {"error":"ValueError"},
  [{"sequence":1,"sender_id":"alice","recipient_id":"bob","text":"Hi"}],
  1,
  1,
  {"error":"ValueError"},
  0,
  0
]

Explanation: The first acknowledgment fails because no message has been polled. After polling, acknowledging sequence 1 removes one message. Retrying the original send returns 1 without restoring that message, and changing its text is rejected.
Constraints
  • At most 100,000 method calls and 10,000 distinct users per service instance. IDs are nonempty strings of at most 64 characters; text contains 1–4,096 characters.

  • Calls are single-threaded. Inputs satisfy the stated types and string bounds; explicitly validate poll limits, acknowledgment bounds, and conflicting idempotency keys.

  • State is in memory only. Keep idempotency information for the lifetime of the instance; persistence, authentication, encryption, group messaging, and time-based expiration are out of scope.

  • Target expected O(1) send and count operations, O(k) polling for k returned messages, and O(r + 1) acknowledgment for r removed messages, excluding string hashing/comparison costs.
Want to practise this one?
Create a free account to open the full question and practise Meta questions with AI.
Sign up free
system design Hard caching #2

2. [OA] LRU Cache — Implement the caching system for Instagram feed

Instagram relies on providing quick access to user feeds, which requires an efficient cache management system. Design an LRU Cache to ensure optimal performance.
Class LRUCache:
  • LRUCache(int capacity): Initializes the cache with a positive size capacity.

  • int get(int key): Returns the value of the key if the key exists, otherwise returns -1.

  • void put(int key, int value): Update the value of the key if present, or add the key-value pair if not existing. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.


Example 1:
Input: LRUCache(2); cache.put(1, 1); cache.put(2, 2); cache.get(1); cache.put(3, 3); cache.get(2); cache.put(4, 4); cache.get(1); cache.get(3); cache.get(4);
Output: 1; -1; 3; 4
Constraints:
  • capacity is always positive and will not exceed 1000

  • The operations get and put will always be called with valid keys.

Related Meta Software Engineer interview prep

Start practicing Meta questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free