Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

feat(zio-http): add plaintext and json benchmarks for zio-http - #6447

Merged
NateBrady23 merged 8 commits into
TechEmpower:masterfrom
amitksingh1490:feat/add-zio-http-benchmark
Mar 16, 2021
Merged

NateBrady23 merged 8 commits into
TechEmpower:masterfrom
amitksingh1490:feat/add-zio-http-benchmark

Conversation

@amitksingh1490

@amitksingh1490 amitksingh1490 commented Mar 14, 2021 •

Copy link
Copy Markdown
Contributor

No description provided.

@amitksingh1490
amitksingh1490 marked this pull request as draft March 14, 2021 19:41
@amitksingh1490
amitksingh1490 marked this pull request as ready for review March 15, 2021 17:52
@amitksingh1490
amitksingh1490 marked this pull request as draft March 15, 2021 17:52
content = HttpContent.Complete(jsonstr))
}

override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = Server.start(8080, app).exitCode

@kubukoz kubukoz Mar 16, 2021 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: disable zio tracing :) that can result in potential gains.

Also, thread count should probably match the one in other frameworks (https supposedly has 32:

val blazeEc = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(32))
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default AFAIK it's going to be 2x availableCPU(). Need to check if the test machine already has virtualization because in that case it should be equal to availableCPU()

case class Message(message: String)
implicit val codec: JsonValueCodec[Message] = JsonCodecMaker.make

val jsonstr = new String(writeToArray(Message(message)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's just me, but I'd say manually encoding the value to a byte array defeats the purpose of testing the framework's performance, since this code is part of the test and not the framework.

object WebApp extends App {

val message: String = "Hello, World!"
def createDate: String = DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To stay in the idiomatic realm of using ZIO-related libraries this should be suspended in ZIO (IO.effectTotal on ZonedDateTime.now, or zio.clock.currentDateTime etc.)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will move certain "basic" headers to the core. For eg: Date and Server. Almost all libraries do it this way for performance reasons. Also, the code above will look a lot more concise.

@@ -0,0 +1,36 @@
FROM alpine as builder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a fixed alpine version here to avoid that future updates can break the build


override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = Server.start(8080, app).exitCode

} No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amitksingh1490 can you just run it thru scalafmt also.

@amitksingh1490
amitksingh1490 marked this pull request as ready for review March 16, 2021 13:48
@NateBrady23
NateBrady23 merged commit 3197c74 into TechEmpower:master Mar 16, 2021
@amitksingh1490
amitksingh1490 deleted the feat/add-zio-http-benchmark branch March 16, 2021 17:02
andreasrueb pushed a commit to digitallyinduced/IHP-FrameworkBenchmarks that referenced this pull request Apr 13, 2021
…mpower#6447)

* feat(zio-http): add plaintext and json benchmarks for zio-http

* build(zio-http): update benchmark source code

* fix(zio-http): Json encoding should be done on each response

* fix(zio-http): remove unnecessary jvm options

* build(zio-http): cleanup dockerfile

* build(zio-http): cleanup dockerfile

* style(zio-http): scalafmt

* fix(zio-http): update zhttp version and change example
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants