Last active
May 6, 2023 15:39
-
-
Save dacr/8d0f45cc8b18082748993289b4f5fa11 to your computer and use it in GitHub Desktop.
ZIO learning - massive scalability thanks to fibers a very dangerous silly example / published by https://github.com/dacr/code-examples-manager #25431f87-4eeb-4a0e-9b8a-9b2165543f4b/241a06f16808f76ad81715dc91dcc3d76b545815
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// summary : ZIO learning - massive scalability thanks to fibers a very dangerous silly example | |
// keywords : scala, zio, learning, pure-functional, dos, loadtest | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 25431f87-4eeb-4a0e-9b8a-9b2165543f4b | |
// created-on : 2021-04-06T09:46:48+02:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// usage-example : scala-cli zio-learning-15-massive-scalability.sc -- http://127.0.0.1:8090/ | |
// --------------------- | |
//> using scala "3.2.2" | |
//> using dep "dev.zio::zio:2.0.13" | |
// --------------------- | |
/* | |
inspired from | |
- [John A De Goes - ZIO: Next-Generation Effects in Scala](https://www.youtube.com/watch?v=mkSHhsJXjdc) | |
*/ | |
import zio.* | |
object MassiveLoad extends ZIOAppDefault { | |
// TODO - of course rewrite to use an async http client... | |
override def run = for { | |
args <- getArgs | |
target = args.headOption.getOrElse("http://127.0.0.1:8090/") | |
loadTester = ZIO.attemptBlockingIO(scala.io.Source.fromURL(target).getLines().mkString("\n")) | |
loadTesters = List.fill(20_000)(loadTester) | |
_ <- ZIO.collectAllPar(loadTesters).as(()) | |
} yield () | |
} | |
// ------------------------------------------------------------- | |
MassiveLoad.main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment