← revolut Interview Insights

revolut·Backend Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Revolut backend interview that went straight into concurrency territory. The transfer function problem sounds deceptively manageable until you're actually in the room trying to remember why naive locking blows up.

Questions Asked (1)

Q1

Implement a transfer(from, to, amount) function that moves money between two accounts in a multithreaded environment. How do you guarantee correctness without introducing deadlocks?

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

I started with the obvious read-write lock approach and the interviewer just kind of waited.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the concurrency model and requirements, then propose a locking strategy that orders locks consistently to prevent deadlocks. Discuss trade-offs between pessimistic and optimistic concurrency, and mention how to handle failures and ensure atomicity.

Pro tip: Mention that you would use a lock ordering based on account IDs (e.g., always lock the lower ID first) to prevent deadlocks, and consider using a database transaction with SELECT ... FOR UPDATE if accounts are persisted. This shows practical experience with real-world systems.

1. Clarify requirements and constraints

Ask about the environment: in-memory vs. database, expected concurrency level, and whether accounts can be locked individually. Confirm that the transfer must be atomic and consistent.

2. Choose a locking strategy

Decide between pessimistic locking (e.g., mutexes per account) and optimistic locking (e.g., version numbers). For pessimistic, ensure locks are acquired in a consistent global order to avoid deadlocks.

3. Implement deadlock avoidance

Order locks by a unique identifier (e.g., account ID) so that all threads acquire locks in the same sequence. Alternatively, use a single global lock or lock-free techniques if contention is low.

4. Ensure atomicity and handle failures

Wrap the transfer in a transaction or critical section. If using a database, use transactions with appropriate isolation levels. Handle exceptions by rolling back and releasing locks.

5. Discuss trade-offs and alternatives

Compare performance implications: lock contention, throughput, and scalability. Mention optimistic concurrency for low-conflict scenarios and database-level solutions for distributed systems.

Key Points to Mention

  • Deadlock prevention via lock ordering (e.g., always lock lower account ID first)
  • Pessimistic vs. optimistic concurrency control and when to use each
  • Atomicity and isolation: using transactions or critical sections
  • Handling partial failures and rollback mechanisms
  • Performance considerations: lock granularity, contention, and throughput
  • Real-world example: database transactions with SELECT ... FOR UPDATE or application-level locks

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.