Cooperative Concurrency in Crystal with Fibers and Channels
Crystal schedules lightweight fibers cooperatively on a single OS thread. Learn how to pass messages between fibers with Channel(T) and avoid stalling the scheduler.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Crystal schedules lightweight fibers cooperatively on a single OS thread. Learn how to pass messages between fibers with Channel(T) and avoid stalling the scheduler.
Crystal's typed channels synchronize fibers with compile-time type safety, but unbuffered channels can deadlock without a matching receiver.
Learn how to implement a high-concurrency I/O service using Crystal's cooperative fibers and channels, including strategies to avoid scheduler stalls and memory leaks.
Learn how to prevent goroutine leaks and manage concurrency in Go using buffered channels, the select statement, and proper shutdown signals.
Learn how Go channels replace mutexes for safe goroutine coordination, with a worker‑pool example, select‑based timeouts, and practical trade‑offs.
Crystal's fibers and channels give you typed, backpressure-aware concurrency that reads like sequential code. Here's how the model works, a worker-pool example, and the pitfalls to avoid.
Crystal's typed channels and fibers make I/O-heavy worker pools read like plain blocking code — but fibers aren't threads. A worked example, backpressure notes, and the parallelism caveat.
Learn how to architect Phoenix Channels for real‑time apps: isolate state, enforce data boundaries, monitor PubSub, and handle failures. Includes a concrete persistent chat example and guidelines for scaling.