# Racket matching or exceeding Golang for Echo server performance

**URL:** <https://racket.discourse.group/t/racket-matching-or-exceeding-golang-for-echo-server-performance/660>\
**Category:** Show & Tell\
**Created:** [February 5, 2022, 7:55pm UTC](https://racket.discourse.group/t/racket-matching-or-exceeding-golang-for-echo-server-performance/660 "2022-02-05T19:55:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pseud](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@pseud](https://racket.discourse.group/u/pseud)\
**Post date:** [February 5, 2022, 7:55pm UTC](https://racket.discourse.group/t/racket-matching-or-exceeding-golang-for-echo-server-performance/660/1 "2022-02-05T19:55:15Z")

</div>

Hey. It's hard to find many performance comparisons outside of the benchmarks team game, so I thought this might be an interesting data point.

I was stumbling around, writing a TCP-based echo server, only later coming across the "Systems programming with racket" ( [More: Systems Programming with Racket](https://docs.racket-lang.org/more/) ) article.

I ended up with a TCP-based server, spawning a (racket) thread) for each new client, using `break-thread` to terminate threads and custodians to manage resource cleanup.  
(program: [https://gist.github.com/jwdevantier/ed6aae4288bd9049034fcf95063e51bf](https://gist.github.com/jwdevantier/ed6aae4288bd9049034fcf95063e51bf) )

To ascertain performance, I wrote a program to stress-test the server in golang, spawning several client threads to send messages while keeping track of how many was sent.  
(program: [https://github.com/jwdevantier/daemonload/blob/master/cmd/spammer/spammer.go](https://github.com/jwdevantier/daemonload/blob/master/cmd/spammer/spammer.go) )

I then modified a very simple echo-server in golang to have something to test against  
(program: [https://github.com/jwdevantier/daemonload/blob/master/cmd/echosrv/echosrv.go](https://github.com/jwdevantier/daemonload/blob/master/cmd/echosrv/echosrv.go) )

Finally I benchmarked it all with the load test using 3 threads simulating 3 clients which send messages as fast as they can for 180 seconds.

Racket server: ~114,584 messages/sec  
The Go server (default): ~85,650 messages/sec  
Go server (GOMAXPROCS=1): ~108,495 messages/sec  
(full results: [https://gist.github.com/jwdevantier/469fcb6d0d150d632dd656d53a9b7355](https://gist.github.com/jwdevantier/469fcb6d0d150d632dd656d53a9b7355) )

When instructing Go to not use as many OS threads (default is 1 per CPU thread), it almost caught up, but remains behind the racket server for each test.

* * *

This, of course, does not tell us much aside from Racket doing well for echo servers, but it definitely shows that Racket is no slouch in this case 🙂

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [February 9, 2022, 1:53pm UTC](https://racket.discourse.group/t/racket-matching-or-exceeding-golang-for-echo-server-performance/660/2 "2022-02-09T13:53:10Z")

</div>

Thank you for sharing. It is gratifying to see the work by all the contributors pay off.
