fs2 (Functional Streams for Scala)

Pure functional streaming library for Scala built on Cats Effect. fs2 Stream[F, A] is a lazy, effectful, backpressure-aware stream of values. Key features: composable pipes (Stream transformations), concurrent streams (Stream.merge, parJoin), resource-safe bracketing, interruption/cancellation, and integration with files, sockets, and message queues. Used in http4s (request/response bodies), Doobie (streaming SQL results), and most Typelevel libraries.

Evaluated Mar 07, 2026 (0d ago) v3.x
Homepage ↗ Repo ↗ Developer Tools scala streaming functional-programming typelevel cats-effect backpressure pipes concurrent
⚙ Agent Friendliness
64
/ 100
Can an agent use this?
🔒 Security
91
/ 100
Is it safe for agents?
⚡ Reliability
81
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
82
Error Messages
80
Auth Simplicity
95
Rate Limits
92

🔒 Security

TLS Enforcement
100
Auth Strength
90
Scope Granularity
85
Dep. Hygiene
90
Secret Handling
88

Pure functional design prevents implicit side effects. Resource safety prevents connection leaks. Backpressure prevents unbounded memory growth. No external network calls.

⚡ Reliability

Uptime/SLA
82
Version Stability
80
Breaking Changes
75
Error Recovery
88
AF Security Reliability

Best When

You're processing large datasets or event streams in Cats Effect Scala applications and need backpressure, resource safety, and concurrency built into the stream.

Avoid When

You're using ZIO (use ZIO Streams) or Akka (use Akka Streams) ecosystems, or you need simple sequential processing where Iterator suffices.

Use Cases

  • Process large agent datasets in constant memory using fs2 Stream — read from file, transform, write to database without loading entire dataset
  • Build backpressure-aware agent data pipelines from message queues using fs2 concurrent streams with configurable parallelism
  • Stream agent LLM responses token-by-token using fs2 Stream connected to http4s streaming HTTP response bodies
  • Implement agent event processing pipelines using fs2's sliding/chunkN/groupWithin for batching events before downstream processing
  • Compose agent data transformation pipelines as Stream pipes — reusable transformations that can be tested independently

Not For

  • Teams not using Cats Effect — fs2 is tightly coupled to Cats Effect IO; use Akka Streams for Akka ecosystem, or ZIO Streams for ZIO
  • Simple sequential data processing — Iterator or List suffice for non-concurrent non-streaming data; fs2's power is wasted on simple transformations
  • Java codebases — fs2 is Scala-specific; use Project Reactor or Akka Streams for Java streaming

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Streaming library — no auth concepts.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

fs2 is MIT licensed and maintained by the Typelevel organization.

Agent Metadata

Pagination
cursor
Idempotent
Full
Retry Guidance
Documented

Known Gotchas

  • fs2 Stream is lazy and cold — nothing happens until .compile.drain/.toList/etc is called; building Stream pipelines without running them is a common beginner mistake
  • Stream.eval wraps a single F[A] effect — Stream.eval(fa) emits the value of fa; Stream.exec(fu) runs the effect for its side effects; confusing them causes missing output or unexpected emissions
  • Concurrent streams require care with resources — Stream.parJoin(n) runs n streams concurrently; resources opened in each stream must be closed in that stream's bracket, not after parJoin
  • Chunk size affects throughput — fs2 processes streams in chunks; small chunk sizes (1) are slow; use Stream.chunkN or Stream.groupWithin to build larger chunks before emission
  • Stream interruption doesn't stop upstream immediately — in pull-based pipelines, upstream continues until next pull; design for graceful shutdown via SignallingRef[IO, Boolean] interrupt signals
  • fs2 2.x to 3.x migration — fs2 3.x removed many deprecated methods and changed synchronous stream processing; code using fs2 2.x must be updated; don't mix 2.x and 3.x in same project

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for fs2 (Functional Streams for Scala).

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-07.

6470
Packages Evaluated
26150
Need Evaluation
173
Need Re-evaluation
Community Powered