Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 6, 2023 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/8d0f45cc8b18082748993289b4f5fa11 to your computer and use it in GitHub Desktop.
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
// 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