Microsoft logo

Microsoft Software Engineer System Design Questions

48 practice questions for Microsoft Software Engineer interviews

Microsoft 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
1
System Design
system design Hard Verified Question #1

1. Top 5 System Design Questions Jan 2026


Category: Interval-based system design problem

Top 5 Recently Asked System Design Questions - Microsoft These are the commonly asked system design questions from Microsoft interviews and some...

Input: List
Output: Computed result
Want to practise this one?
Create a free account to open the full question and practise Microsoft questions with AI.
Sign up free
system design Hard caching #1

1. Design BlobMetadataCache — a byte-bounded LRU cache with per-entry expiration


Background
Azure Storage services repeatedly read blob metadata such as access tiers and serialized property documents. Implement an in-process cache whose keys include the blob version, whose memory budget is measured in UTF-8 payload bytes, and whose TTL prevents metadata from remaining cached indefinitely. This exercise adapts a candidate-reported Microsoft Azure Storage interview question about an LRU cache with TTL; the byte-budget rules are an extension for this exercise.
Requirements
1. Construct the cache with a nonnegative capacity_bytes. Keys are opaque, case-sensitive strings such as account/container/blob@version; values are strings. An entry costs exactly len(value.encode("utf-8")) bytes. Ignore key and bookkeeping memory when enforcing capacity.
2. Every public operation receives now_ms. Calls use globally nondecreasing timestamps. An entry written with TTL ttl_ms expires at now_ms + ttl_ms and is unavailable when now_ms >= expires_at. Logically remove all expired entries before executing each operation, including a rejected write.
3. put inserts or replaces an entry and makes it most recently used. If the new payload alone exceeds capacity, return false without changing any unexpired entry or its recency. Otherwise, remove the previous version of that key, evict least-recently-used entries until the new value fits, insert it with a fresh TTL, and return true.
4. A successful get makes the entry most recently used but does not extend its TTL. A missing or expired key returns null. Expiration events from an earlier write must never remove a later replacement of the same key.
5. invalidate removes a live entry and reports whether it existed. stats reports the number of live entries and their total payload bytes. Neither operation changes the recency of remaining entries.
6. Avoid scanning the whole cache on each operation. Use an object-oriented implementation with efficient recency tracking, lookup, and expiration processing. Calls are sequential; thread safety is not required.
Class API
  • BlobMetadataCache(capacity_bytes: int) — construct an empty cache.

  • put(key: str, value: str, ttl_ms: int, now_ms: int) -> bool — insert or replace a payload, possibly evicting LRU entries.

  • get(key: str, now_ms: int) -> str | None — return a live payload and update its recency.

  • invalidate(key: str, now_ms: int) -> bool — remove a live entry if present.

  • stats(now_ms: int) -> dict[str, int] — return exactly {"entries": count, "bytes": payload_bytes}.


Example 1:
Input sequence:
cache = BlobMetadataCache(10)
cache.put("acct/logs/a@v1", "Hot", 10, 0)
cache.put("acct/logs/b@v1", "Cool", 20, 0)
cache.get("acct/logs/a@v1", 1)
cache.put("acct/logs/c@v1", "Cool", 20, 1)
cache.get("acct/logs/b@v1", 1)
cache.stats(1)
cache.get("acct/logs/a@v1", 10)
cache.stats(10)

Output, excluding construction:
[true, true, "Hot", true, null, {"entries": 2, "bytes": 7}, null, {"entries": 1, "bytes": 4}]

Explanation: Hot costs 3 bytes and Cool costs 4. Reading a makes b least recently used. Inserting c would require 11 bytes, so b is evicted, leaving 7 bytes. At time 10, a expires exactly at its deadline; only c remains.
Example 2:
Input sequence:
cache = BlobMetadataCache(5)
cache.put("acct/docs/a@v1", "é", 3, 0)
cache.put("acct/docs/a@v1", "123456", 100, 1)
cache.get("acct/docs/a@v1", 1)
cache.put("acct/docs/b@v1", "XYZ", 10, 1)
cache.stats(1)
cache.put("acct/docs/a@v1", "Q", 20, 2)
cache.get("acct/docs/a@v1", 3)
cache.invalidate("acct/docs/b@v1", 3)
cache.stats(3)
cache.get("acct/docs/a@v1", 22)

Output, excluding construction:
[true, false, "é", true, {"entries": 2, "bytes": 5}, true, "Q", true, {"entries": 1, "bytes": 1}, null]

Explanation: é occupies 2 UTF-8 bytes. The 6-byte replacement is rejected, preserving the original value. Adding XYZ fills the 5-byte budget. Replacing é with Q reduces usage to 4 bytes and sets a new deadline of 22. The original deadline of 3 must not delete this replacement. Invalidating b leaves 1 byte, and a expires at time 22.
Constraints
  • 0 <= capacity_bytes <= 100,000,000; at most 100,000 public method calls per instance.

  • Keys are nonempty strings of at most 512 characters. Values are valid UTF-8-encodable strings with encoded lengths from 0 to 1,000,000 bytes; empty values are allowed.

  • 1 <= ttl_ms <= 10^12 and 0 <= now_ms <= 10^15. Method arguments satisfy these bounds, and timestamps never decrease.

  • Use only in-memory data structures and the standard library. No background timer, storage service, or network access is required.
Want to practise this one?
Create a free account to open the full question and practise Microsoft questions with AI.
Sign up free
system design Hard messaging #2

2. [OA] Basic Twitter Feed — design a simplified version of Twitter for Azure

Considering the real-time capabilities of Azure, create a basic Twitter API that can fetch user feeds. This design must include necessary features for users to follow others and retrieve their latest tweets in real-time.
Problem statement: Design a Twitter class that supports the following methods:
  • postTweet(userId: int, tweetId: int) -> None: Record a new tweet.

  • getNewsFeed(userId: int) -> List[int]: Retrieve the 10 most recent tweet IDs in the user's news feed.

  • follow(followerId: int, followeeId: int) -> None: Allow a follower to follow a followee.

  • unfollow(followerId: int, followeeId: int) -> None: Allow a follower to unfollow a followee.


Method Signatures:
- def postTweet(self, userId: int, tweetId: int) -> None
- def getNewsFeed(self, userId: int) -> List[int]
- def follow(self, followerId: int, followeeId: int) -> None
- def unfollow(self, followerId: int, followeeId: int) -> None
Example 1:
Input: twitter = Twitter()
twitter.postTweet(1, 5)
twitter.getNewsFeed(1)
Output: [5]
Example 2:
Input: twitter.follow(1, 2)
twitter.postTweet(2, 6)
twitter.getNewsFeed(1)
Output: [6, 5]
Constraints:
  • 0 <= userId, followerId, followeeId, tweetId <= 10^4

  • The number of tweets will not exceed 10^4. At most 3 * 10^4 follow operations will occur.
system design Hard caching #3

3. [OA] LRU Cache — implement caching layer for Azure API responses

Microsoft Azure commonly uses caching to speed up responses to repeated API requests. Implement an LRU (Least Recently Used) Cache to maintain efficient access and updates.
Problem statement: Design and implement an LRUCache class that supports get(key: int) -> int and put(key: int, value: int) -> None methods. The cache will have a limited capacity.
  • Method Signatures:

- def get(self, key: int) -> int: Returns the value of the key if present, otherwise -1.
- def put(self, key: int, value: int) -> None: Updates the value of the key or adds it if it's not already present. When the cache reaches its capacity, it invalidates the least recently used item before inserting a new item.
Example 1:
Input: cache = LRUCache(2)
cache.put(1, 1)
cache.put(2, 2)
cache.get(1)
Output: 1
Example 2:
Input: cache.put(2, 1)
cache.put(2, 2)
cache.get(2)
Output: 2
Constraints:
  • capacity will be between 1 and 3000.

  • key and value are integers within the range of a 32-bit signed integer.

Related Microsoft Software Engineer interview prep

Start practicing Microsoft questions

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

Get Started Free