Shared libraries vs code duplication in microservices
Sarah Zhang
·31 views
my team is facing the classic shared library vs. code duplication dilemma in our microservices architecture. we have about 20 services, and there's a significant amount of common code: logging patterns, authentication middleware, error handling, health checks, etc. currently, it's mostly copy-pasted, which obviously leads to inconsistencies and painful updates. we've tried a few approaches for sharing. shared npm packages felt like a dependency hell, making deployments tricky when updates weren't backward compatible. git submodules ended up being a maintenance nightmare. some teams just copy-paste and accept the tech debt. none of these feel like a truly elegant solution. what strategies have you found effective for managing common code across a decent number of microservices without introducing tight coupling or significant operational overhead?
22 comments