In addition to gRPC, there are also many excellent RPC frameworks to choose from in Go language. 1. Kitex: a high-performance framework with open source bytes, suitable for high throughput and low latency scenarios, supports multi-protocol and plug-in mechanisms, suitable for projects that require flexible customization; 2. Dubbo-Go: Apache Dubbo Go implementation, suitable for multi-language architectures, especially good interoperability with Java services, comprehensive functions but slightly high learning costs; 3. Micro: a lightweight microservice framework with clear modular design and supports multiple transmission protocols, suitable for developers who want to independently control the details of the architecture; 4. Net/RPC standard library: a simple and direct choice, suitable for small projects or learning purposes, but lacks modern functions. Just select the most suitable framework according to project needs.
gRPC is one of the most mainstream RPC frameworks in the Go language, but if you are already using it or want to try other solutions, you will find that the Go community actually has some good alternative frameworks, each with its own characteristics and suitable for different scenarios.

1. Kitex: a high-performance framework with open source bytes
Kitex is ByteDance's open source high-performance, strongly scalable RPC framework designed for large-scale services. It is relatively mature in performance optimization, protocol extension and middleware support, especially suitable for scenarios that require high throughput and low latency.
- Supports multi-protobuf, such as Thrift, Kitex-PB (similar to Protobuf) and so on
- Built-in common functions such as load balancing, service discovery, fuse current limiting, etc.
- Support plug-in mechanism to facilitate access to infrastructure such as monitoring, logging, and link tracking.
When using Kitex, it is usually used to define the interface and generate service code with Thrift IDL. If you are already using Thrift, or want a more flexible and customizable framework, Kitex is a great choice.

2. Dubbo-Go: Apache Dubbo Go implementation
Dubbo-Go is one of the multilingual implementations of Apache Dubbo, suitable for scenarios where multilingual hybrid architecture is required. If your backend has Java services and is using Dubbo, then Dubbo-Go can communicate well with them.
- Supports multiple protocols, including Dubbo protocol, gRPC, REST, etc.
- Provide core functions such as service registration discovery, configuration management, and load balancing.
- The community is active, the documents are gradually improved, suitable for medium and large projects
The configuration and usage of Dubbo-Go are more inclined toward traditional RPC frameworks, with a slightly higher learning cost, but the migration cost is lower for teams with existing Dubbo systems.

3. Micro: Lightweight Microservices Framework
Go Micro is a lightweight microservice development framework. Although the update frequency is not as frequent as before, it is still suitable for building RPC-based microservice architectures.
- Supports multiple transmission protocols (HTTP, gRPC, etc.)
- Provides functions such as service discovery, client load balancing, message encoding, etc.
- Plug-in design, high flexibility
Micro is characterized by a clear modular design, suitable for developers who want to control the details of their own service architecture. If you don't want to be "kidnapped" by a large framework, but rather want to combine components on demand, Micro can consider it.
4. Net/RPC Standard Library: Simple and Direct Choice
Although net/rpc
in the Go standard library is simple, it is still available in some lightweight scenarios.
- Built-in HTTP transmission, easy to use
- Supports custom codecs, which can be combined with JSON, Gob and other formats
- No dependency on third-party libraries, suitable for small projects or internal services
Of course, it lacks the common service discovery, circuit breaking, current limiting and other functions of modern RPC frameworks, so it is more suitable for simple scenarios or learning purposes.
If you're just looking for a high-performance, full-featured alternative, Kitex is the most recommended one at the moment. If multilingual compatibility is required, Dubbo-Go is more suitable. And if you just want to quickly build a simple RPC service, the standard library net/rpc
is enough.
Basically, these are all. Different frameworks are suitable for different scenarios. Just choose one that meets your project needs.
The above is the detailed content of Go RPC Frameworks Beyond gRPC. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Go's switch statement will not be executed throughout the process by default and will automatically exit after matching the first condition. 1. Switch starts with a keyword and can carry one or no value; 2. Case matches from top to bottom in order, only the first match is run; 3. Multiple conditions can be listed by commas to match the same case; 4. There is no need to manually add break, but can be forced through; 5.default is used for unmatched cases, usually placed at the end.

In Go, to break out of nested loops, you should use labeled break statements or return through functions; 1. Use labeled break: Place the tag before the outer loop, such as OuterLoop:for{...}, use breakOuterLoop in the inner loop to directly exit the outer loop; 2. Put the nested loop into the function, and return in advance when the conditions are met, thereby terminating all loops; 3. Avoid using flag variables or goto, the former is lengthy and easy to make mistakes, and the latter is not recommended; the correct way is that the tag must be before the loop rather than after it, which is the idiomatic way to break out of multi-layer loops in Go.

Usecontexttopropagatecancellationanddeadlinesacrossgoroutines,enablingcooperativecancellationinHTTPservers,backgroundtasks,andchainedcalls.2.Withcontext.WithCancel(),createacancellablecontextandcallcancel()tosignaltermination,alwaysdeferringcancel()t

Use a dedicated and reasonably configured HTTP client to set timeout and connection pools to improve performance and resource utilization; 2. Implement a retry mechanism with exponential backoff and jitter, only retry for 5xx, network errors and 429 status codes, and comply with Retry-After headers; 3. Use caches for static data such as user information (such as sync.Map or Redis), set reasonable TTL to avoid repeated requests; 4. Use semaphore or rate.Limiter to limit concurrency and request rates to prevent current limit or blocking; 5. Encapsulate the API as an interface to facilitate testing, mocking, and adding logs, tracking and other middleware; 6. Monitor request duration, error rate, status code and retry times through structured logs and indicators, combined with Op

To correctly copy slices in Go, you must create a new underlying array instead of directly assigning values; 1. Use make and copy functions: dst:=make([]T,len(src));copy(dst,src); 2. Use append and nil slices: dst:=append([]T(nil),src...); both methods can realize element-level copying, avoid sharing the underlying array, and ensure that modifications do not affect each other. Direct assignment of dst=src will cause both to refer to the same array and are not real copying.

Gooffersfasterexecutionspeedduetocompilationtonativemachinecode,outperforminginterpretedlanguageslikePythonintaskssuchasservingHTTPrequests.2.Itsefficientconcurrencymodelusinglightweightgoroutinesenablesthousandsofconcurrentoperationswithlowmemoryand

InitializeaGomodulewithgomodinit,2.InstallgqlgenCLI,3.Defineaschemainschema.graphqls,4.Rungqlgeninittogeneratemodelsandresolvers,5.Implementresolverfunctionsforqueriesandmutations,6.SetupanHTTPserverusingthegeneratedschema,and7.RuntheservertoaccessGr

Go uses time.Time structure to process dates and times, 1. Format and parse the reference time "2006-01-0215:04:05" corresponding to "MonJan215:04:05MST2006", 2. Use time.Date(year, month, day, hour, min, sec, nsec, loc) to create the date and specify the time zone such as time.UTC, 3. Time zone processing uses time.LoadLocation to load the position and use time.ParseInLocation to parse the time with time zone, 4. Time operation uses Add, AddDate and Sub methods to add and subtract and calculate the interval.
