Last active
May 25, 2024 10:20
-
-
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/d31044c91536eb6e056296d840012e18bef7d916
This file contains hidden or 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.4.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