Question library
Questions from real interviews. Drill any of them by voice in a couple of minutes, with an interviewer, a score and feedback.
Why does a backend need a cache, and what problems show up when you add one?JuniorWhen do you use functools.lru_cache, and what problems can you run into with it?Mid-levelWhere does LazyInitializationException come from, and how do Hibernate's first-level and second-level caches affect working with entities?Mid-levelYou added a cache in front of the database for product cards, and users started complaining that they see outdated prices. How should you set up caching to avoid this?Mid-levelYou have a popular key in Redis with a TTL, and every time it expires, the database gets a load spike and starts to slow down. What's going on, and how do you fix it?Mid-levelПеред базой стоит кеш в Redis с карточками товаров, TTL — пять минут. Расскажите, как бы вы организовали чтение и обновление, как кеш может разойтись с базой, и что произойдёт, когда истечёт TTL у очень популярного ключа.Mid-levelDesign a URL shortener: a user submits a long URL and gets a short one, and following the short link redirects to the original.Mid-levelDesign a local in-memory cache for reference data in a Java service: it's read by thousands of requests per second, and the data in the source is updated every few minutes.Mid-levelYou put a cache in front of a heavy database query. What problems do you expect with this cache under high load, and how will you solve them?SeniorA product catalog service written in Python gets tens of thousands of read requests per second, and the database can't keep up anymore. How would you design caching?SeniorDesign caching for a high-load Spring Boot application running as several instances. How would you choose between a local and a distributed cache, and how would you handle invalidation?SeniorWrite a memoizeAsync function. It takes an async function of a string key and a cache time to live in milliseconds, and returns a wrapper: a repeated call with the same key doesn't go to the network, concurrent calls share a single request, and errors aren't cached.Senior