This project features two Go microservices, a Producer and a Consumer, that communicate using gRPC. The services manage tasks within a PostgreSQL database and provide endpoints for Prometheus metrics and pprof profiling.
The GOMEMLIMIT is configured in docker-compose.yml to establish a soft memory limit for the Go runtime, aiding in the prevention of OOM errors in containerized environments. While GOGC can be adjusted, GOMEMLIMIT generally offers superior control over memory usage trade-offs by dynamically modifying GC frequency as the limit is approached.
Extensive use of Go compiler and linker flags is made to optimize production binaries. Linker flags like -s (disables symbol table generation) and -w (disables DWARF generation) significantly reduce binary size when used together as -ldflags="-s -w". The flag -X 'main.Version=...' allows for dynamic injection of the version string at build time, accessible via the -version flag. Compiler flags include -pgo=auto for Profile-Guided Optimization, which uses captured CPU profiles to optimize hot functions.
Profiling endpoints are accessible on ports 6061 (Consumer) and 6062 (Producer). To capture CPU profiles and generate flame graphs, Go must be installed locally. The process involves using curl to capture the profile and then go tool pprof to visualize it, including flame graph views.
Unit tests can be executed using the command: go test ./... -v -cover.
Built with