# Multithreaded Crystal initial thoughts

**URL:** <https://forum.crystal-lang.org/t/multithreaded-crystal-initial-thoughts/1089>\
**Category:** Offtopic\
**Created:** [September 3, 2019, 2:17pm UTC](https://forum.crystal-lang.org/t/multithreaded-crystal-initial-thoughts/1089 "2019-09-03T14:17:43Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![jgaskins](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jgaskins/32/2449_2.png) [@jgaskins](https://forum.crystal-lang.org/u/jgaskins)\
**Post date:** [September 4, 2019, 10:07pm UTC](https://forum.crystal-lang.org/t/multithreaded-crystal-initial-thoughts/1089/10 "2019-09-04T22:07:38Z")

</div>

> [@asterite](#):
>
> I see that in your benchmark you serialize JSON. Go is known to have slow JSON serialization because it uses reflection (and Crystal doesn’t). Could you try running a benchmark where Crystal and Go just send “Hello world” in the response?

Removing the JSON serialization from the Go app only added ~18% throughput.

```auto
  Thread Stats Avg Stdev Max +/- Stdev
    Latency 109.05us 119.22us 9.19ms 99.46%
Requests/sec: 81592.82

```

> **Golang code here**
>
> ```go
> package main
> 
> import (
> "fmt"
> "log"
> "net/http"
> )
> 
> func main() {
> http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
> fmt.Fprintf(w, "Hello")
> })
> 
> log.Fatal(http.ListenAndServe(":54321", nil))
> }
> 
> ```

It appears Crystal returns a nontrivial JSON payload faster than Go writes a hard-coded string, but let’s check Crystal anyway:

```auto
  Thread Stats Avg Stdev Max +/- Stdev
    Latency 54.06us 23.38us 723.00us 96.85%
Requests/sec: 173259.23

```

I may be going out on a limb here but … ummm … I think we’re good?

The only thing I changed in the Crystal code was to make the `call` method just run `context.response << "Hello"` to match the Go app (also removed the `Fiber.yield` for the same reason).

---

_[View the full topic](https://forum.crystal-lang.org/t/multithreaded-crystal-initial-thoughts/1089)._
