Ctrl K

Question library

Questions from real interviews. Drill any of them by voice in a couple of minutes, with an interviewer, a score and feedback.

What is a race condition? Give an example from the backend and explain how to avoid it.Backend · TheoryJuniorWhat is the GIL in Python, and how does it affect multithreaded programs?Python · TheoryJuniorDuring a sale, an online store sold more units of a product than it had in stock. The code first checks the stock level and then decrements it. Why did this happen, and how would you fix it?Backend · TheoryMid-levelOne thread sets a stop flag, and a worker thread checks that flag in a loop, but sometimes the worker never stops. Why does that happen and how do you fix it?Java · TheoryMid-levelYou have a script that first downloads several thousand images over the network and then resizes them. What would you use for each part — threads, processes, or asyncio — and why?Python · TheoryMid-levelYou need to call three external services in parallel and assemble one result from their responses. How would you do this with CompletableFuture, and what would you watch out for?Java · TheoryMid-levelYou need to configure a thread pool to process incoming tasks in a service. Which ThreadPoolExecutor parameters would you set, and why isn't Executors.newFixedThreadPool always a good fit?Java · TheoryMid-levelНесколько потоков одновременно делают counter++ над общей переменной, и в итоге значение получается меньше ожидаемого. Объясните, что именно происходит на уровне процессора и памяти, и какими способами это можно исправить — чем они отличаются внутри.TheoryMid-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.Java · System designMid-levelExplain what the GIL is and how it affects the choice between threads, processes and asyncio. What does the free-threaded build of CPython change?Python · TheorySeniorHow does ConcurrentHashMap work in modern versions of Java, and how is its internal structure different from a regular HashMap?Java · TheorySeniorHow would you test a payment creation API for idempotency and concurrent requests?QA · TheorySeniorSeveral instances of a service run the same background job once a minute, and sometimes it runs twice. How would you fix this?Backend · TheorySeniorWhat is the Java Memory Model, and what is the happens-before relationship? Tell me what guarantees volatile gives and where it isn't enough.Java · TheorySeniorYou orchestrate several calls to external services using CompletableFuture. What pitfalls have you run into, and how do you work around them?Java · TheorySeniorВозьмём перевод между двумя счетами, которые лежат в одной базе: списать с одного, зачислить на другой. Как вы это реализуете, чтобы при параллельных операциях деньги не потерялись и баланс не ушёл в минус?TheorySeniorDesign a Java service that consumes events from Kafka, processes them in parallel, and writes the results to a database. How would you ensure performance, ordering, and no data loss?Java · System designSeniorDesign a Java service that handles thousands of requests per second and, for each one, calls several slow external systems. How would you organize threads, pools, and overload protection?Java · System designSeniorDesign a concert ticket sales system where, the moment sales open, hundreds of thousands of people show up for a few thousand seats.Backend · System designSeniorWrite a rate limiter for an API using the token bucket algorithm: an allow function takes a client identifier and returns whether its request can go through. Each client has a bucket capacity and a token refill rate per second, and the limiter itself is called from many threads at once.Backend · CodingSeniorWrite a thread-safe RateLimiter class: the constructor takes how many requests per second are allowed, and the tryAcquire method, without waiting, returns true if the request can be let through and false if the limit is exhausted. It will be called concurrently from many threads.Java · CodingSeniorWrite an async function fetch_all that takes a list of URLs, an async function that fetches a single URL, and a limit on concurrent requests. It returns the results in the same order as the URLs, and a failure of one request must not take down the others.Python · CodingSenior