Implementing Raft Protocol by Coroutines and Ktor Framework
summary
Concrete Raft implementation using coroutines + Ktor and gRPC style RPCs, with randomized election timeouts, channels for state transitions, and a countdown latch for elections to stop parallel vote requests once a majority is reached. Implements appendEntries heartbeats with fixed-rate timers, retry logic for unreachable nodes, and in-memory key‑value store built on the replicated log. Demo runs on three to five nodes (majority = 3), shows leader election, log replication, and successful catch-up when a downed node restarts.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:27Agenda
- 2:38Why Coroutines
- 14:35Raft Explanation
- 20:11Raft Methods
- 20:51Raft Architecture
- 22:24Building Blocks
- 25:21State Transition
- 29:19Retry Logic
- 30:57Leader Election
- 34:57Timer
- 35:57Example
related talks
47mRediscovering gRPC with Kotlin coroutines
46mIntroduction to Ktor
51mFunctional fashion for Kotlin projects
21mBuilding asynchronous API with Ktor & Kotlin
45mManaging parallelism using coroutines
45mOffline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
42mBuilding Microservices with Kotlin and gRPC
37mKotlin on the server with Ktor
