What is a framework?
A framework can be viewed as scaffolding or a standardized template.
It provides the expected components, reduces repetitive work, and gives projects a consistent style and directory structure.
A shared framework makes projects easier to take over and maintain. Security fixes can be applied consistently, though individual services still need to update their dependencies. Logging and monitoring are often repeated across services; standard components let developers spend more effort on business logic and write less plumbing.
Java has a widely used ecosystem around Spring. Many problems have already been encountered by other developers, and the documentation and technical articles are extensive. That mature ecosystem is a real advantage.
Common frameworks in Go development
Go was officially released in 2009. Its framework ecosystem is more varied than the Spring-centered Java ecosystem: large companies often have their own frameworks, and open-source teams maintain others.
Infrastructure teams may build frameworks tailored to company needs. This is not simple: they must consider connections to other systems, private protocols, usability, stability, and security as well as business requirements.
When learning, I want to understand the ideas behind a framework, rather than only how to call its APIs. Learn to build the wheels, then the car.
Core microservice components
-
Logging, with support for different logging configurations
-
Centralized configuration, instead of configuring every service separately
-
Database access
-
Message queues, such as Kafka and RabbitMQ
-
Metrics and monitoring
-
Tracing: following the lifecycle of a request to find bottlenecks
-
Service registration and discovery
-
Dependency injection
-
RPC: exchanging data between services through remote procedure calls
-
Circuit breaking and rate limiting, to prevent failures from spreading
-
……
Common open-source choices
-
- A Go microservice toolkit: relatively small building blocks that can be combined into a service.
-
Go-micro
- An early Go microservice framework; check the specific version for compatibility with newer Go releases.
-
Go-kratos
- An open-source framework from Bilibili, allowing component selection or custom implementations.
-
Kitex
- An open-source ByteDance framework with a custom netpoll implementation, emphasizing performance and requiring some familiarity with the stack.
-
Go-zero
- A comprehensive microservice framework originally open-sourced by TAL. I once walked past their office at dinner time; people seemed to finish work fairly early.