antonputra / tutorials

DevOps Tutorials
https://youtube.com/antonputra
MIT License
3.2k stars 2.5k forks source link

Lesson 207 - add pure Zig implementation #271

Closed zigster64 closed 2 months ago

zigster64 commented 2 months ago

Keeping the ZAP version intact, I have added a 3rd implementation here that does the same /healthz and /api/devices endpoints ... but using a pure zig lib instead

This creates an additional deployment 'zig-app' to go next to 'zap-app'. Hope that makes sense

This uses async IO (ie - old school worker pool of threads + non-blocking IO)

I have fine-tuned the server config in this case to reduce memory usage ... this should have no effect on performance, it's just to reduce runtime memory consumption. You should in theory be able to run this in a pod with only 4 MB memory allocation !!

Running this on local (Mac M2), im seeing around the same perf on Zig vs Rust.

Best Rust run is around 185k r/s on my machine Best Zig run is around 198k r/s on my machine

Zig marginally better across the board, but more scatter in the results. Much of a Muchness

A Rust expert could probably tune the Actix build to get closer to the Zig peak figure ?

Memory usage and binary footprint significantly better than Rust

Im not seeing any significant improvements in the Zap version by applying different tweaks. I am not familiar with Zap or facil so much


Later on, will followup with an extension to lesson 205, to do some Postgres and S3 (minio) updates inline with the Go version

Enjoy