Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/improbable-eng/go-srvlb

DNS SRV Load Balancer for gRPC
https://github.com/improbable-eng/go-srvlb

dns golang grpc grpc-gateway lb load-balancer srv

Last synced: 2 months ago
JSON representation

DNS SRV Load Balancer for gRPC

Awesome Lists containing this project

README

        

# Go gRPC DNS SRV Load Balancer

[![Go Report Card](https://goreportcard.com/badge/github.com/improbable-eng/go-srvlb)](http://goreportcard.com/report/improbable-eng/go-srvlb)
[![GoDoc](http://img.shields.io/badge/GoDoc-Reference-blue.svg)](https://godoc.org/github.com/improbable-eng/go-srvlb)
[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![Build Status](https://travis-ci.org/improbable-eng/go-srvlb.svg?branch=master)](https://travis-ci.org/improbable-eng/go-srvlb)

A gRPC [`naming.Resolver`](https://godoc.org/google.golang.org/grpc/naming) that uses [DNS SRV](https://en.wikipedia.org/wiki/SRV_record).
This allows you to do simple client-side Round Robin load balancing of gRPC requests.

# Usage

```go
rr := grpc.RoundRobin(grpcsrvlb.New(srv.NewGoResolver(2 * time.Second)))
conn, err := grpc.Dial("grpc.my_service.my_cluster.internal.example.com", grpc.WithBalancer(rr))
```

This will resolve the DNS SRV address `grpc.my_service.my_cluster.internal.example.com` using the Golang DNS resolver
with an assumed TTL of 2 seconds and use that as a set of backends for the gRPC `RoundRobin` policy. From this point on
all requests on the `conn` (reusable across gRPC clients) will be load balanced to a set of these backends.

# Status

This is *alpha* software. It should work, but key components are missing:

* [ ] unit tests
* [ ] integration tests with gRPC
* [ ] `srv.Resolver` implementation that respects `TTL`, see [miekg/dns](https://github.com/miekg/dns)

# License

`go-srvlb` is released under the Apache 2.0 license. See the [LICENSE](LICENSE) file for details.