SlideShare a Scribd company logo
@NSilnitsky
@NSilnitsky
How to successfully manage a ZIO Fiber
How to successfully manage a
ZIO Fiber’s lifecycle
Natan Silnitsky Backend Infra TL, Wix.com
natansil.com twitter@NSilnitsky linkedin/natansilnitsky github.com/natansil
@NSilnitsky
How to successfully manage a ZIO Fiber
>200 Million registered users from 190 countries
Agenda 1. What’s a Fiber?
2. Handling unexpected failure
3. Interrupt a Fiber
4. Monitoring Fibers state
How to successfully manage a ZIO Fiber
@NSilnitsky
What’s a Fiber?
01
What’s a Fiber?
A lightweight concurrency mechanism.
* little mem, no block, yield, multi task 1 the, GC
@NSilnitsky
object WhatIsAFiber extends App {
override def run(args: List[String]): URIO[zio.ZEnv,
ExitCode] =
for {
fiber <- runSomething().fork
_ <- runSomethingElse()
_ <- fiber.join
} yield ExitCode(0)
}
What’s a Fiber?
Fork
Join
@NSilnitsky
What’s a Fiber?
01
What’s a Fiber
Usually work with higher level operators:
● ZIO#foreachPar
● ZIO#zipPar
● ZIO#race
@NSilnitsky
object WhatIsAFiber extends App {
override def run(args: List[String]): URIO[zio.ZEnv,
ExitCode] =
for {
fiber <- runSomething().forkDaemon
_ <- runSomethingElse()
_ <- fiber.join
} yield ExitCode(0)
}
What’s a
Fiber
What’s a Fiber?
M
Main
Fiber
B
A
Fork
A1 A2 B1
M2
Fork
Daemon
Fork
@NSilnitsky
object WhatIsAFiber extends App {
override def run(args: List[String]): URIO[zio.ZEnv,
ExitCode] =
for {
fiber <- runSomething().forkDaemon
_ <- runSomethingElse()
_ <- fiber.join
} yield ExitCode(0)
}
What’s a
Fiber
What’s a Fiber?
Main
Fiber
B
A
Fork
A1 A2 B1
Fork
M2
M
Fork
Daemon
@NSilnitsky
object WhatIsAFiber extends App {
override def run(args: List[String]): URIO[zio.ZEnv,
ExitCode] =
for {
fiber <- runSomething().forkDaemon
_ <- runSomethingElse()
_ <- fiber.join
} yield ExitCode(0)
}
What’s a
Fiber
What’s a Fiber?
Main
Fiber
B
A
Fork
A1 A2 B1
Fork
M M2
Fork
Daemon
@NSilnitsky
Handling unexpected failures
Make sure the job continues to run periodically
even when an unexpected error occurs
→
02
Handling
unexpected
failures
* imagine - periodic, update state
@NSilnitsky
object DefectNotHandledExample extends App {
import zio._
import zio.duration._
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
_ <- runSomePeriodicJob
.catchAll(e => console.putStrLn(s"job failed with $e"))
.repeat(Schedule.spaced(1.seconds))
.forkDaemon
_ <- console.putStrLn("do other stuff")
.repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
private def runSomePeriodicJob = {
ZIO.succeed(throw new RuntimeException("unexpected defect")) *> ZIO.effect(println("running job..."))
}
}
Death of a Fiber
@NSilnitsky
object DefectNotHandledExample extends App {
...
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
_ <- runSomePeriodicJob
.catchAll(e => console.putStrLn(s"job failed with $e"))
.repeat(Schedule.spaced(1.seconds))
.forkDaemon
_ <- console.putStrLn("do other stuff")
.repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
private def runSomePeriodicJob = {
ZIO.succeed(throw new RuntimeException("unexpected defect")) *>
ZIO.effect(println("running job..."))
}
}
Death of a Fiber
@NSilnitsky
@NSilnitsky
do other stuff
Fiber failed.
An unchecked error was produced.
java.lang.RuntimeException: unexpected defect
…
do other stuff
do other stuff
do other stuff
…
Handling unexpected failures
@NSilnitsky
Handling unexpected failures
catchAll doesn’t catch all failures
catchAllCause does
@NSilnitsky
Handling unexpected failures
catchAll doesn’t catch all failures
catchAllCause does
The E type of ZIO[R, E, A] refers only to expected
failures.
Cause[E] is a description of a full story of failure.
Cause can be either Fail[+E](value: E), Die(value:
Throwable), or Interrupt(fiberId: Fiber.Id)
@NSilnitsky
object DefectNotHandledExample extends App {
...
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
_ <- runSomePeriodicJob
.catchAllCause(cause => console.putStrLn(s"job failed with $cause"))
.repeat(Schedule.spaced(1.seconds))
.forkDaemon
_ <- console.putStrLn("do other stuff")
.repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
private def runSomePeriodicJob = {
ZIO.succeed(throw new RuntimeException("unexpected defect")) *>
ZIO.effect(println("running job..."))
}
}
Death of a Fiber
@NSilnitsky
@NSilnitsky
do other stuff
job failed with Traced(Die(...RuntimeException: unexpected defect)…
do other stuff
job failed with Traced(Die(...RuntimeException: unexpected defect)…
…
Cause -> Throwable
Handling unexpected failures
cause.squashTrace
@NSilnitsky
runtime.mapPlatform(_.withReportFailure(_ => [report unexpected failure]))
Handling unexpected
failures
* monitoring service
@NSilnitsky
Interrupt a Fiber
03
Interrupt a Fiber
There are certain situations where interrupting
a fiber is required.
Releasing a managed resource, that forked a
fiber, when it was acquired.
@NSilnitsky
object InterruptExample extends App {
...
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
fiber <- runSomeLongJob
.ensuring(printWithTime("finalizing job!"))
.forkDaemon
_ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2))
_ <- fiber.interrupt
_ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
private def runSomeLongJob = {
printWithTime("long running job...") *> clock.sleep(100.seconds)
}
}
Interrupt a Fiber
@NSilnitsky
object InterruptExample extends App {
...
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
fiber <- runSomeLongJob
.ensuring(printWithTime("finalizing job!"))
.forkDaemon
_ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2))
_ <- fiber.interrupt
_ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
private def runSomeLongJob = {
printWithTime("long running job...") *> clock.sleep(100.seconds)
}
}
Interrupt a Fiber
@NSilnitsky
@NSilnitsky
19:15:38.445 long running job…
19:15:38.501 do stuff
19:15:39.696 do stuff
19:15:40.701 do stuff
19:15:40.862 finalizing job!
19:15:40.871 do other stuff
19:15:41.873 do other stuff
Interrupt a Fiber
@NSilnitsky
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
fiber <- runSomeLongJob
.ensuring(printWithTime("finalizing job!"))
.forkDaemon
_ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2))
timeout <- fiber.join.resurrect.ignore.disconnect.timeout(5.seconds)
_ <- ZIO.when(timeout.isEmpty)(fiber.interruptFork)
_ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
Graceful
Termination
@NSilnitsky
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
fiber <- runSomeLongJob
.ensuring(printWithTime("finalizing job!"))
.forkDaemon
_ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2))
timeout <- fiber.join.resurrect.ignore.disconnect.timeout(5.seconds)
_ <- ZIO.when(timeout.isEmpty)(fiber.interruptFork)
_ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
Graceful
Termination
@NSilnitsky
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
for {
fiber <- runSomeLongJob
.ensuring(printWithTime("finalizing job!"))
.forkDaemon
_ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2))
timeout <- fiber.join.resurrect.ignore.disconnect.timeout(5.seconds)
_ <- ZIO.when(timeout.isEmpty)(fiber.interruptFork)
_ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
Graceful
Termination
@NSilnitsky
@NSilnitsky
19:23:01.422 long running job…
19:23:01.492 do stuff
19:23:02.689 do stuff
19:23:03.693 do stuff
19:23:08.960 finalizing job!
19:23:08.963 do other stuff
19:23:09.964 do other stuff
Interrupt a Fiber
@NSilnitsky
Monitoring Fiber state
04
Monitoring Fiber
state
Good old Java thread dumps don’t give you
interesting information when it comes to ZIO apps
ZIO fiber dumps can give you stack traces...
@NSilnitsky
@NSilnitsky
---- test dump results ----
+---#756 Status: Running()
+---#603480 Status: Suspended(interruptible, 1395652 asyncs,
zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70))
+---#760 Status: Running()
+---#64569 Status: Suspended(interruptible, 5520272 asyncs,
zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70))
+---#2399 Status: Suspended(interruptible, 6099394 asyncs,
zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70))
+---#1478 Status: Suspended(interruptible, 5862206 asyncs,
zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70))
+---#1654 Status: Suspended(interruptible, 6108699 asyncs,
zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70))
Monitoring Fiber state
@NSilnitsky
@NSilnitsky
#64569 (7h476m28609s28609166ms)
Status: Suspended(interruptible, 5520272 asyncs,
zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70))
Fiber:Id(1615104333320,64569) was supposed to continue to:
a future continuation at zio.ZIO$._IdentityFn(ZIO.scala:3973)
a future continuation at zio.ZIO.onInterrupt(ZIO.scala:981)
a future continuation at <unknown>.<unknown>(ZIO.scala:0)
a future continuation at zio.ZIO.repeatUntilM(ZIO.scala:1529)
Fiber:Id(1615104333320,64569) execution trace:
at zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70)
at zio.ZIO$.effectAsyncInterrupt(ZIO.scala:2582)
at zio.ZIO$.effectAsyncInterrupt(ZIO.scala:2582)
at zio.clock.package$.sleep(package.scala:118)
Monitoring Fiber state
@NSilnitsky
ZIO-ZMX
val diagnosticsLayer: ZLayer[ZEnv, Throwable, Diagnostics] =
Diagnostics.live(“localhost”, 1111)
val runtime: Runtime[ZEnv] =
Runtime.default.mapPlatform(_.withSupervisor(ZMXSupervisor))
Monitoring Fibers
state
@NSilnitsky
Or roll your own...
object RuntimeOps {
implicit class RuntimeEnvOps[R <: Has[_]](val runtime: zio.Runtime[R]) extends AnyVal {
def withFiberTracking(implicit tag: zio.Tag[R]): zio.Runtime[R with FiberTracking] = {
val supervisor = runtime.unsafeRunTask(Supervisor.track(weak = false))
runtime
.mapPlatform(_.withSupervisor(supervisor))
.map(_.union[FiberTracking](FiberTracking.make(supervisor)))
}
}
}
Monitoring Fibers
state
Summary
1. What’s a Fiber
2. Handling unexpected failure
3. Interrupt a Fiber
4. Monitoring Fiber state
How to successfully manage a ZIO Fiber
2. catchAllCause, ensuring, withReportFailure
4. Supervisor, fiber dumps
3. resurrect, interruptFork and disconnect
@NSilnitsky
https://medium.com/wix-engineering/how-to-successfully-manage-a-zi
o-fibers-lifecycle-96fe9c4ecd06
The blog post
How to successfully manage a ZIO Fiber
@NSilnitsky
A Scala ZIO high-level functional SDK for Apache Kafka.
github.com/wix/greyhound
How to successfully manage a ZIO Fiber
0.2 is out!
@NSilnitsky
@NSilnitsky
Thank
You!
natansil.com twitter@NSilnitsky linkedin/natansilnitsky github.com/natansil
👉 slideshare.net/NatanSilnitsky
Any questions?
How to successfully manage a ZIO Fiber
@NSilnitsky
@NSilnitsky
Q&A
natansil.com twitter@NSilnitsky linkedin/natansilnitsky github.com/natansil
👉 slideshare.net/NatanSilnitsky
Any questions?
How to successfully manage a ZIO Fiber

More Related Content

What's hot

ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional ProgrammingZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional ProgrammingJohn De Goes
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack7mind
 
Ad hoc Polymorphism using Type Classes and Cats
Ad hoc Polymorphism using Type Classes and CatsAd hoc Polymorphism using Type Classes and Cats
Ad hoc Polymorphism using Type Classes and CatsPhilip Schwarz
 
Refactoring Functional Type Classes
Refactoring Functional Type ClassesRefactoring Functional Type Classes
Refactoring Functional Type ClassesJohn De Goes
 
The Expression Problem - Part 2
The Expression Problem - Part 2The Expression Problem - Part 2
The Expression Problem - Part 2Philip Schwarz
 
ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022Alexander Ioffe
 
Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...
Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...
Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...Philip Schwarz
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaJorge Vásquez
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Philip Schwarz
 
Left and Right Folds - Comparison of a mathematical definition and a programm...
Left and Right Folds- Comparison of a mathematical definition and a programm...Left and Right Folds- Comparison of a mathematical definition and a programm...
Left and Right Folds - Comparison of a mathematical definition and a programm...Philip Schwarz
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...Philip Schwarz
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOJorge Vásquez
 
Quill vs Slick Smackdown
Quill vs Slick SmackdownQuill vs Slick Smackdown
Quill vs Slick SmackdownAlexander Ioffe
 
The Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldThe Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldPhilip Schwarz
 
Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldJorge Vásquez
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 

What's hot (20)

ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional ProgrammingZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
ZIO Schedule: Conquering Flakiness & Recurrence with Pure Functional Programming
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
 
Ad hoc Polymorphism using Type Classes and Cats
Ad hoc Polymorphism using Type Classes and CatsAd hoc Polymorphism using Type Classes and Cats
Ad hoc Polymorphism using Type Classes and Cats
 
Refactoring Functional Type Classes
Refactoring Functional Type ClassesRefactoring Functional Type Classes
Refactoring Functional Type Classes
 
The Expression Problem - Part 2
The Expression Problem - Part 2The Expression Problem - Part 2
The Expression Problem - Part 2
 
ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022ZIO-Direct - Functional Scala 2022
ZIO-Direct - Functional Scala 2022
 
Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...
Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...
Refactoring: A First Example - Martin Fowler’s First Example of Refactoring, ...
 
ZIO Queue
ZIO QueueZIO Queue
ZIO Queue
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in Scala
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
 
Left and Right Folds - Comparison of a mathematical definition and a programm...
Left and Right Folds- Comparison of a mathematical definition and a programm...Left and Right Folds- Comparison of a mathematical definition and a programm...
Left and Right Folds - Comparison of a mathematical definition and a programm...
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
 
Applicative Functor
Applicative FunctorApplicative Functor
Applicative Functor
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
 
Quill vs Slick Smackdown
Quill vs Slick SmackdownQuill vs Slick Smackdown
Quill vs Slick Smackdown
 
The Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldThe Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and Fold
 
Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorld
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 

Similar to How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021

soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch
 
Getting property based testing to work after struggling for 3 years
Getting property based testing to work after struggling for 3 yearsGetting property based testing to work after struggling for 3 years
Getting property based testing to work after struggling for 3 yearsSaurabh Nanda
 
Kotlin - Coroutine
Kotlin - CoroutineKotlin - Coroutine
Kotlin - CoroutineSean Tsai
 
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
«Gevent — быть или не быть?» Александр Мокров, Positive Technologiesit-people
 
Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?Artur Latoszewski
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011julien.ponge
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Do more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python wayDo more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python wayJaime Buelta
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Campjulien.ponge
 
JavaScript Async for Effortless UX
JavaScript Async for Effortless UXJavaScript Async for Effortless UX
JavaScript Async for Effortless UX재석 강
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechtureAnatoly Bubenkov
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testingFoundationDB
 

Similar to How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021 (20)

Gevent rabbit rpc
Gevent rabbit rpcGevent rabbit rpc
Gevent rabbit rpc
 
Current State of Coroutines
Current State of CoroutinesCurrent State of Coroutines
Current State of Coroutines
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
 
Getting property based testing to work after struggling for 3 years
Getting property based testing to work after struggling for 3 yearsGetting property based testing to work after struggling for 3 years
Getting property based testing to work after struggling for 3 years
 
Kotlin - Coroutine
Kotlin - CoroutineKotlin - Coroutine
Kotlin - Coroutine
 
Gevent be or not to be
Gevent be or not to beGevent be or not to be
Gevent be or not to be
 
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
«Gevent — быть или не быть?» Александр Мокров, Positive Technologies
 
Fiber supervision in ZIO
Fiber supervision in ZIOFiber supervision in ZIO
Fiber supervision in ZIO
 
Fork Join (BeJUG 2012)
Fork Join (BeJUG 2012)Fork Join (BeJUG 2012)
Fork Join (BeJUG 2012)
 
Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Do more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python wayDo more than one thing at the same time, the Python way
Do more than one thing at the same time, the Python way
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
 
JAVA SE 7
JAVA SE 7JAVA SE 7
JAVA SE 7
 
Durable Functions
Durable FunctionsDurable Functions
Durable Functions
 
JavaScript Async for Effortless UX
JavaScript Async for Effortless UXJavaScript Async for Effortless UX
JavaScript Async for Effortless UX
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechture
 
Deterministic simulation testing
Deterministic simulation testingDeterministic simulation testing
Deterministic simulation testing
 

More from Natan Silnitsky

Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILNatan Silnitsky
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConNatan Silnitsky
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...Natan Silnitsky
 
DevSum - Lessons Learned from 2000 microservices
DevSum - Lessons Learned from 2000 microservicesDevSum - Lessons Learned from 2000 microservices
DevSum - Lessons Learned from 2000 microservicesNatan Silnitsky
 
GeeCon - Lessons Learned from 2000 microservices
GeeCon - Lessons Learned from 2000 microservicesGeeCon - Lessons Learned from 2000 microservices
GeeCon - Lessons Learned from 2000 microservicesNatan Silnitsky
 
Migrating to Multi Cluster Managed Kafka - ApacheKafkaIL
Migrating to Multi Cluster Managed Kafka - ApacheKafkaILMigrating to Multi Cluster Managed Kafka - ApacheKafkaIL
Migrating to Multi Cluster Managed Kafka - ApacheKafkaILNatan Silnitsky
 
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven Microservices
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven MicroservicesWix+Confluent Meetup - Lessons Learned from 2000 Event Driven Microservices
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven MicroservicesNatan Silnitsky
 
BuildStuff - Lessons Learned from 2000 Event Driven Microservices
BuildStuff - Lessons Learned from 2000 Event Driven MicroservicesBuildStuff - Lessons Learned from 2000 Event Driven Microservices
BuildStuff - Lessons Learned from 2000 Event Driven MicroservicesNatan Silnitsky
 
Lessons Learned from 2000 Event Driven Microservices - Reversim
Lessons Learned from 2000 Event Driven Microservices - ReversimLessons Learned from 2000 Event Driven Microservices - Reversim
Lessons Learned from 2000 Event Driven Microservices - ReversimNatan Silnitsky
 
Devoxx Ukraine - Kafka based Global Data Mesh
Devoxx Ukraine - Kafka based Global Data MeshDevoxx Ukraine - Kafka based Global Data Mesh
Devoxx Ukraine - Kafka based Global Data MeshNatan Silnitsky
 
Devoxx UK - Migrating to Multi Cluster Managed Kafka
Devoxx UK - Migrating to Multi Cluster Managed KafkaDevoxx UK - Migrating to Multi Cluster Managed Kafka
Devoxx UK - Migrating to Multi Cluster Managed KafkaNatan Silnitsky
 
Dev Days Europe - Kafka based Global Data Mesh at Wix
Dev Days Europe - Kafka based Global Data Mesh at WixDev Days Europe - Kafka based Global Data Mesh at Wix
Dev Days Europe - Kafka based Global Data Mesh at WixNatan Silnitsky
 
Kafka Summit London - Kafka based Global Data Mesh at Wix
Kafka Summit London - Kafka based Global Data Mesh at WixKafka Summit London - Kafka based Global Data Mesh at Wix
Kafka Summit London - Kafka based Global Data Mesh at WixNatan Silnitsky
 
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative Natan Silnitsky
 
5 Takeaways from Migrating a Library to Scala 3 - Scala Love
5 Takeaways from Migrating a Library to Scala 3 - Scala Love5 Takeaways from Migrating a Library to Scala 3 - Scala Love
5 Takeaways from Migrating a Library to Scala 3 - Scala LoveNatan Silnitsky
 
Migrating to Multi Cluster Managed Kafka - DevopStars 2022
Migrating to Multi Cluster Managed Kafka - DevopStars 2022Migrating to Multi Cluster Managed Kafka - DevopStars 2022
Migrating to Multi Cluster Managed Kafka - DevopStars 2022Natan Silnitsky
 
Open sourcing a successful internal project - Reversim 2021
Open sourcing a successful internal project - Reversim 2021Open sourcing a successful internal project - Reversim 2021
Open sourcing a successful internal project - Reversim 2021Natan Silnitsky
 
Advanced Caching Patterns used by 2000 microservices - Code Motion
Advanced Caching Patterns used by 2000 microservices - Code MotionAdvanced Caching Patterns used by 2000 microservices - Code Motion
Advanced Caching Patterns used by 2000 microservices - Code MotionNatan Silnitsky
 
Advanced Caching Patterns used by 2000 microservices - Devoxx Ukraine
Advanced Caching Patterns used by 2000 microservices - Devoxx UkraineAdvanced Caching Patterns used by 2000 microservices - Devoxx Ukraine
Advanced Caching Patterns used by 2000 microservices - Devoxx UkraineNatan Silnitsky
 

More from Natan Silnitsky (20)

Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
 
DevSum - Lessons Learned from 2000 microservices
DevSum - Lessons Learned from 2000 microservicesDevSum - Lessons Learned from 2000 microservices
DevSum - Lessons Learned from 2000 microservices
 
GeeCon - Lessons Learned from 2000 microservices
GeeCon - Lessons Learned from 2000 microservicesGeeCon - Lessons Learned from 2000 microservices
GeeCon - Lessons Learned from 2000 microservices
 
Migrating to Multi Cluster Managed Kafka - ApacheKafkaIL
Migrating to Multi Cluster Managed Kafka - ApacheKafkaILMigrating to Multi Cluster Managed Kafka - ApacheKafkaIL
Migrating to Multi Cluster Managed Kafka - ApacheKafkaIL
 
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven Microservices
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven MicroservicesWix+Confluent Meetup - Lessons Learned from 2000 Event Driven Microservices
Wix+Confluent Meetup - Lessons Learned from 2000 Event Driven Microservices
 
BuildStuff - Lessons Learned from 2000 Event Driven Microservices
BuildStuff - Lessons Learned from 2000 Event Driven MicroservicesBuildStuff - Lessons Learned from 2000 Event Driven Microservices
BuildStuff - Lessons Learned from 2000 Event Driven Microservices
 
Lessons Learned from 2000 Event Driven Microservices - Reversim
Lessons Learned from 2000 Event Driven Microservices - ReversimLessons Learned from 2000 Event Driven Microservices - Reversim
Lessons Learned from 2000 Event Driven Microservices - Reversim
 
Devoxx Ukraine - Kafka based Global Data Mesh
Devoxx Ukraine - Kafka based Global Data MeshDevoxx Ukraine - Kafka based Global Data Mesh
Devoxx Ukraine - Kafka based Global Data Mesh
 
Devoxx UK - Migrating to Multi Cluster Managed Kafka
Devoxx UK - Migrating to Multi Cluster Managed KafkaDevoxx UK - Migrating to Multi Cluster Managed Kafka
Devoxx UK - Migrating to Multi Cluster Managed Kafka
 
Dev Days Europe - Kafka based Global Data Mesh at Wix
Dev Days Europe - Kafka based Global Data Mesh at WixDev Days Europe - Kafka based Global Data Mesh at Wix
Dev Days Europe - Kafka based Global Data Mesh at Wix
 
Kafka Summit London - Kafka based Global Data Mesh at Wix
Kafka Summit London - Kafka based Global Data Mesh at WixKafka Summit London - Kafka based Global Data Mesh at Wix
Kafka Summit London - Kafka based Global Data Mesh at Wix
 
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative
Migrating to Multi Cluster Managed Kafka - Conf42 - CloudNative
 
5 Takeaways from Migrating a Library to Scala 3 - Scala Love
5 Takeaways from Migrating a Library to Scala 3 - Scala Love5 Takeaways from Migrating a Library to Scala 3 - Scala Love
5 Takeaways from Migrating a Library to Scala 3 - Scala Love
 
Migrating to Multi Cluster Managed Kafka - DevopStars 2022
Migrating to Multi Cluster Managed Kafka - DevopStars 2022Migrating to Multi Cluster Managed Kafka - DevopStars 2022
Migrating to Multi Cluster Managed Kafka - DevopStars 2022
 
Open sourcing a successful internal project - Reversim 2021
Open sourcing a successful internal project - Reversim 2021Open sourcing a successful internal project - Reversim 2021
Open sourcing a successful internal project - Reversim 2021
 
Advanced Caching Patterns used by 2000 microservices - Code Motion
Advanced Caching Patterns used by 2000 microservices - Code MotionAdvanced Caching Patterns used by 2000 microservices - Code Motion
Advanced Caching Patterns used by 2000 microservices - Code Motion
 
Advanced Caching Patterns used by 2000 microservices - Devoxx Ukraine
Advanced Caching Patterns used by 2000 microservices - Devoxx UkraineAdvanced Caching Patterns used by 2000 microservices - Devoxx Ukraine
Advanced Caching Patterns used by 2000 microservices - Devoxx Ukraine
 

Recently uploaded

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems ApproachNeo4j
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityAPVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityamy56318795
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesNeo4j
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)Max Lee
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationHelp Desk Migration
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfMeon Technology
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationHelp Desk Migration
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfmbmh111980
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with StrimziStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzisteffenkarlsson2
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 

Recently uploaded (20)

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityAPVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with StrimziStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 

How to successfully manage a ZIO fiber’s lifecycle - Functional Scala 2021

  • 1. @NSilnitsky @NSilnitsky How to successfully manage a ZIO Fiber How to successfully manage a ZIO Fiber’s lifecycle Natan Silnitsky Backend Infra TL, Wix.com natansil.com twitter@NSilnitsky linkedin/natansilnitsky github.com/natansil
  • 2. @NSilnitsky How to successfully manage a ZIO Fiber >200 Million registered users from 190 countries
  • 3. Agenda 1. What’s a Fiber? 2. Handling unexpected failure 3. Interrupt a Fiber 4. Monitoring Fibers state How to successfully manage a ZIO Fiber
  • 4. @NSilnitsky What’s a Fiber? 01 What’s a Fiber? A lightweight concurrency mechanism. * little mem, no block, yield, multi task 1 the, GC
  • 5. @NSilnitsky object WhatIsAFiber extends App { override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomething().fork _ <- runSomethingElse() _ <- fiber.join } yield ExitCode(0) } What’s a Fiber? Fork Join
  • 6. @NSilnitsky What’s a Fiber? 01 What’s a Fiber Usually work with higher level operators: ● ZIO#foreachPar ● ZIO#zipPar ● ZIO#race
  • 7. @NSilnitsky object WhatIsAFiber extends App { override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomething().forkDaemon _ <- runSomethingElse() _ <- fiber.join } yield ExitCode(0) } What’s a Fiber What’s a Fiber? M Main Fiber B A Fork A1 A2 B1 M2 Fork Daemon Fork
  • 8. @NSilnitsky object WhatIsAFiber extends App { override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomething().forkDaemon _ <- runSomethingElse() _ <- fiber.join } yield ExitCode(0) } What’s a Fiber What’s a Fiber? Main Fiber B A Fork A1 A2 B1 Fork M2 M Fork Daemon
  • 9. @NSilnitsky object WhatIsAFiber extends App { override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomething().forkDaemon _ <- runSomethingElse() _ <- fiber.join } yield ExitCode(0) } What’s a Fiber What’s a Fiber? Main Fiber B A Fork A1 A2 B1 Fork M M2 Fork Daemon
  • 10. @NSilnitsky Handling unexpected failures Make sure the job continues to run periodically even when an unexpected error occurs → 02 Handling unexpected failures * imagine - periodic, update state
  • 11. @NSilnitsky object DefectNotHandledExample extends App { import zio._ import zio.duration._ override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { _ <- runSomePeriodicJob .catchAll(e => console.putStrLn(s"job failed with $e")) .repeat(Schedule.spaced(1.seconds)) .forkDaemon _ <- console.putStrLn("do other stuff") .repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) private def runSomePeriodicJob = { ZIO.succeed(throw new RuntimeException("unexpected defect")) *> ZIO.effect(println("running job...")) } } Death of a Fiber
  • 12. @NSilnitsky object DefectNotHandledExample extends App { ... override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { _ <- runSomePeriodicJob .catchAll(e => console.putStrLn(s"job failed with $e")) .repeat(Schedule.spaced(1.seconds)) .forkDaemon _ <- console.putStrLn("do other stuff") .repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) private def runSomePeriodicJob = { ZIO.succeed(throw new RuntimeException("unexpected defect")) *> ZIO.effect(println("running job...")) } } Death of a Fiber
  • 13. @NSilnitsky @NSilnitsky do other stuff Fiber failed. An unchecked error was produced. java.lang.RuntimeException: unexpected defect … do other stuff do other stuff do other stuff … Handling unexpected failures
  • 14. @NSilnitsky Handling unexpected failures catchAll doesn’t catch all failures catchAllCause does
  • 15. @NSilnitsky Handling unexpected failures catchAll doesn’t catch all failures catchAllCause does The E type of ZIO[R, E, A] refers only to expected failures. Cause[E] is a description of a full story of failure. Cause can be either Fail[+E](value: E), Die(value: Throwable), or Interrupt(fiberId: Fiber.Id)
  • 16. @NSilnitsky object DefectNotHandledExample extends App { ... override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { _ <- runSomePeriodicJob .catchAllCause(cause => console.putStrLn(s"job failed with $cause")) .repeat(Schedule.spaced(1.seconds)) .forkDaemon _ <- console.putStrLn("do other stuff") .repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) private def runSomePeriodicJob = { ZIO.succeed(throw new RuntimeException("unexpected defect")) *> ZIO.effect(println("running job...")) } } Death of a Fiber
  • 17. @NSilnitsky @NSilnitsky do other stuff job failed with Traced(Die(...RuntimeException: unexpected defect)… do other stuff job failed with Traced(Die(...RuntimeException: unexpected defect)… … Cause -> Throwable Handling unexpected failures cause.squashTrace
  • 18. @NSilnitsky runtime.mapPlatform(_.withReportFailure(_ => [report unexpected failure])) Handling unexpected failures * monitoring service
  • 19. @NSilnitsky Interrupt a Fiber 03 Interrupt a Fiber There are certain situations where interrupting a fiber is required. Releasing a managed resource, that forked a fiber, when it was acquired.
  • 20. @NSilnitsky object InterruptExample extends App { ... override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomeLongJob .ensuring(printWithTime("finalizing job!")) .forkDaemon _ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2)) _ <- fiber.interrupt _ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) private def runSomeLongJob = { printWithTime("long running job...") *> clock.sleep(100.seconds) } } Interrupt a Fiber
  • 21. @NSilnitsky object InterruptExample extends App { ... override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomeLongJob .ensuring(printWithTime("finalizing job!")) .forkDaemon _ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2)) _ <- fiber.interrupt _ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) private def runSomeLongJob = { printWithTime("long running job...") *> clock.sleep(100.seconds) } } Interrupt a Fiber
  • 22. @NSilnitsky @NSilnitsky 19:15:38.445 long running job… 19:15:38.501 do stuff 19:15:39.696 do stuff 19:15:40.701 do stuff 19:15:40.862 finalizing job! 19:15:40.871 do other stuff 19:15:41.873 do other stuff Interrupt a Fiber
  • 23. @NSilnitsky override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomeLongJob .ensuring(printWithTime("finalizing job!")) .forkDaemon _ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2)) timeout <- fiber.join.resurrect.ignore.disconnect.timeout(5.seconds) _ <- ZIO.when(timeout.isEmpty)(fiber.interruptFork) _ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) Graceful Termination
  • 24. @NSilnitsky override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomeLongJob .ensuring(printWithTime("finalizing job!")) .forkDaemon _ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2)) timeout <- fiber.join.resurrect.ignore.disconnect.timeout(5.seconds) _ <- ZIO.when(timeout.isEmpty)(fiber.interruptFork) _ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) Graceful Termination
  • 25. @NSilnitsky override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = for { fiber <- runSomeLongJob .ensuring(printWithTime("finalizing job!")) .forkDaemon _ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2)) timeout <- fiber.join.resurrect.ignore.disconnect.timeout(5.seconds) _ <- ZIO.when(timeout.isEmpty)(fiber.interruptFork) _ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds)) } yield ExitCode(0) Graceful Termination
  • 26. @NSilnitsky @NSilnitsky 19:23:01.422 long running job… 19:23:01.492 do stuff 19:23:02.689 do stuff 19:23:03.693 do stuff 19:23:08.960 finalizing job! 19:23:08.963 do other stuff 19:23:09.964 do other stuff Interrupt a Fiber
  • 27. @NSilnitsky Monitoring Fiber state 04 Monitoring Fiber state Good old Java thread dumps don’t give you interesting information when it comes to ZIO apps ZIO fiber dumps can give you stack traces...
  • 28. @NSilnitsky @NSilnitsky ---- test dump results ---- +---#756 Status: Running() +---#603480 Status: Suspended(interruptible, 1395652 asyncs, zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70)) +---#760 Status: Running() +---#64569 Status: Suspended(interruptible, 5520272 asyncs, zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70)) +---#2399 Status: Suspended(interruptible, 6099394 asyncs, zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70)) +---#1478 Status: Suspended(interruptible, 5862206 asyncs, zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70)) +---#1654 Status: Suspended(interruptible, 6108699 asyncs, zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70)) Monitoring Fiber state
  • 29. @NSilnitsky @NSilnitsky #64569 (7h476m28609s28609166ms) Status: Suspended(interruptible, 5520272 asyncs, zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70)) Fiber:Id(1615104333320,64569) was supposed to continue to: a future continuation at zio.ZIO$._IdentityFn(ZIO.scala:3973) a future continuation at zio.ZIO.onInterrupt(ZIO.scala:981) a future continuation at <unknown>.<unknown>(ZIO.scala:0) a future continuation at zio.ZIO.repeatUntilM(ZIO.scala:1529) Fiber:Id(1615104333320,64569) execution trace: at zio.clock.package$Clock$Service$$anon$1.sleep(package.scala:70) at zio.ZIO$.effectAsyncInterrupt(ZIO.scala:2582) at zio.ZIO$.effectAsyncInterrupt(ZIO.scala:2582) at zio.clock.package$.sleep(package.scala:118) Monitoring Fiber state
  • 30. @NSilnitsky ZIO-ZMX val diagnosticsLayer: ZLayer[ZEnv, Throwable, Diagnostics] = Diagnostics.live(“localhost”, 1111) val runtime: Runtime[ZEnv] = Runtime.default.mapPlatform(_.withSupervisor(ZMXSupervisor)) Monitoring Fibers state
  • 31. @NSilnitsky Or roll your own... object RuntimeOps { implicit class RuntimeEnvOps[R <: Has[_]](val runtime: zio.Runtime[R]) extends AnyVal { def withFiberTracking(implicit tag: zio.Tag[R]): zio.Runtime[R with FiberTracking] = { val supervisor = runtime.unsafeRunTask(Supervisor.track(weak = false)) runtime .mapPlatform(_.withSupervisor(supervisor)) .map(_.union[FiberTracking](FiberTracking.make(supervisor))) } } } Monitoring Fibers state
  • 32. Summary 1. What’s a Fiber 2. Handling unexpected failure 3. Interrupt a Fiber 4. Monitoring Fiber state How to successfully manage a ZIO Fiber 2. catchAllCause, ensuring, withReportFailure 4. Supervisor, fiber dumps 3. resurrect, interruptFork and disconnect
  • 34. @NSilnitsky A Scala ZIO high-level functional SDK for Apache Kafka. github.com/wix/greyhound How to successfully manage a ZIO Fiber 0.2 is out!
  • 35. @NSilnitsky @NSilnitsky Thank You! natansil.com twitter@NSilnitsky linkedin/natansilnitsky github.com/natansil 👉 slideshare.net/NatanSilnitsky Any questions? How to successfully manage a ZIO Fiber
  • 36. @NSilnitsky @NSilnitsky Q&A natansil.com twitter@NSilnitsky linkedin/natansilnitsky github.com/natansil 👉 slideshare.net/NatanSilnitsky Any questions? How to successfully manage a ZIO Fiber