Server-side Kotlin with Coroutines
summary
Kotlin coroutines replace thousands of blocking threads with a few event threads plus tiny continuations so servers scale by default and require sizing roughly to CPU cores for CPU work and to I/O threads for sockets. Suspend functions compile to callback-style continuations (one small object per suspension), integrate with Reactor/CompletableFuture or Spring 5.2, and use dispatchers to isolate blocking or CPU work. suspend functions enable low-allocation async, structured concurrency prevents leaking child tasks. Flow replaces channels for cold, cancelable streams.
AI-written summary · about
chapters (33)
- 0:00Introduction
- 1:51Old-school client-server monolith
- 2:32Sizing threads - easy
- 4:08Complex business logic
- 5:22What if a service is slow?
- 5:40Blocks threads
- 7:43Release the thread
- 10:47Suspend behind the scenes
- 11:42Performance!
- 13:43Integration
- 14:44Release thread?
- 14:58Blocking server
- 15:50Asynchronous server
- 16:40Server integrated with coroutines
- 17:30Server not integrated with coroutines
- 19:23Suspend is efficient
- 21:14Let's go deeper (with coroutines)
- 21:49Call stack with coroutines
- 23:26Thread pools
- 27:51CPU-bound code
- 28:14Fine-grained control and encapsulation
- 33:14Concurrency with async (futures)
- 35:25Concurrency with coroutines
- 38:04Without coroutine scope?
- 38:54Convention
- 39:41Types as documentation
- 40:35Types are enforced
- 42:46Green threads / Fibers
- 43:25Fibers promise
- 44:40Solution - shared thread pool
- 45:54Returning many responses
- 48:02Where's the catch?
- 50:14Flow example
related talks
01h 03mUsing Kotlin Coroutines for Asynchronous and Concurrent Programming
40mConcurrency made easy with Kotlin Coroutines
59mKotlin coroutines: new ways to do asynchronous programming
49mAsynchronous programming with Kotlin coroutines in Spring
42mKotlin Coroutines: Beyond async/await
43mCoroutines for Java Developers
44mCoroutines in Kotlin on the server
41mHandling billions of events per day with Kotlin Coroutines
