Go Micro Service

Source: Internet
Author: User
Tags zookeeper etcd
This is a creation in Article, where the information may have evolved or changed.

Go-kit Getting Started

1. Microservice

Go-kit

Go Kit is a distributed set of development tools that can be used to build microservices in large organizations (businesses). It solves most of the common problems in distributed systems, so users can focus on business logic.

2. Go-kit Component Introduction

2.1 Endpoint (Endpoint)

The Go kit first resolves the RPC message pattern. It uses an abstract endpoint to create a model for each RPC.

Endpoint is either implemented by a server (implement) or called by a client. This is the basic building block for many Go kit components.

2.2 Circuit breaker (Circuit breaker)

The Circuitbreaker (Circuit breaker) module provides a number of popular circuit breaker LIB endpoint (endpoint) adapters. The circuit breaker avoids avalanches and increases the elasticity for intermittent errors. Each client's endpoint should be encapsulated (wrapped) in a circuit breaker.

2.3 Rate limiter (current limiter)

The Ratelimit module provides an endpoint adapter to the current limiter code package. The current limiter is equivalent to the service side (server-client) and the client (client-side). Using a current limiter can force incoming and outbound requests below the threshold limit.

2.4 Transport (Transport Layer)

The transport module provides a helper method that binds a particular serialization algorithm to an endpoint. Currently, Go Kit only provides helper methods for JSON and HTTP. If your organization uses a full-featured transport layer, the typical scenario is to use Go's library of functions provided at the transport layer, and go kit doesn't need to do too much. In these cases, you can consult the code example to understand how to write an adapter for your endpoint. Currently, you can view Addsvc's code to understand how the transport binding works. We also provide special examples of THIRFT,GRPC,NET/RPC, and HTTP JSON. Support for JSON/RPC and swagger is planned.

2.5 Logging (log)

The log generated by the service is deferred (used), or is a person or machine (to be used). People may be interested in debugging errors and tracking special requests. The machine may aggregate the statistics of interesting events, or the results of offline processing. In both cases, the structure and operability of log messages is important. The Go Kit's log module provides the best design for these practices.

2.6 Metrics (instrumentation) Metric/instrument panel

Until the service has been tracked, delayed, health, and other periodic or dashboard-specific requests for information, it can be considered a "production environment" complete. The Go Kit's metric module provides a common and robust set of interfaces for your service. can be bound to common backend services such as Expvar, STATSD, Prometheus.

2.7 Request tracing (requests tracking)

As your infrastructure grows, it becomes increasingly important to be able to track a request as it can be shuttled across multiple services and back to the user. The tracing module of Go Kit provides enhanced binding capabilities for endpoints and transports to capture information about requests and send them to the tracking system. (currently support Zipkin, plan to support Appdash

2.8 Service discovery and load balancing (services discovery and load Balancing)

If your service calls other services, you need to know how to find it (another service), and you should intelligently roll out the load on these discovered instances (that is, let the discovered instances intelligently share the service pressure). The LoadBalancer module of the Go Kit provides the middleware of the client endpoint to address this type of problem, whether you are using a static hostname or IP address, or a DNS SRV record, CONSUL,ETCD or Zookeeper. And, if you're using a custom system, it's also very easy to write your own Publisher to use the load balancing strategy provided by Go Kit. (Currently, static host name, ETCD, Consul, Zookeeper are supported)

3 goals

    • Operate in a variety of SOA architectures – expected to interact with a variety of non-go kit services
    • Use RPC as the primary message pattern
    • Pluggable serialization and transfer – not just JSON and HTTP
    • Simple to integrate into existing architectures – no specific instructions for any particular tool or technology

4 Beyond the goal (do not consider doing things)

    • Support for message patterns other than RPC (at least for now) – such as MPI, PUB/SUB,CQRS, etc.
    • In addition to adapting to existing software, re-implement some functions
    • Commenting on operations: deployment, configuration, process management, service orchestration, etc.

5 Dependency Management

Go Kit is a library of functions designed to be introduced into a binary file. For the author of the binary package, vendoring is the best mechanism currently used to ensure that the software is reliable and can be rebuilt. Therefore, we strongly recommend that our users use the vendoring mechanism to manage their software dependencies, including Go kit.

To avoid compatibility and usability issues, Go Kit does not vendor its own dependencies and does not recommend using a third-party referral agent.

There are tools that make the vendor mechanism simpler, including GB, glide, GVT, Govendor, and Vendetta. In addition, Go Kit uses a series of continuous integration mechanisms to ensure that complex issues are fixed as quickly as possible.

5 related projects

Items marked with ★ have a special effect on the design of Go kit (and vice versa)

  1. Service Framework

    • Gizmo, a Microservice toolkit from the New York times★
    • Go-micro, a microservices client/server library★
    • Gocircuit, Dynamic cloud orchestration
    • Gotalk, Async Peer Communication Protocol & Library
    • H2, a microservices framework★
    • Kite, a Micro-service framework
  2. Standalone components

    Afex/hystrix-go, client-side latency and fault tolerance library

    Armon/go-metrics, library for exporting performance and runtime metrics to external metrics systems

    Codahale/lunk, structured logging in the style of Google ' s Dapper or Twitter ' s Zipkin

    Eapache/go-resiliency, resiliency patterns

    Sasbury/logging, a tagged style of logging

    Grpc/grpc-go, HTTP/2 based RPC

    INCONSHREVEABLE/LOG15, simple, powerful logging for go★

    Mailgun/vulcand, programmatic load balancer backed by ETCD

    Mattheath/phosphor, Distributed System tracing

    Pivotal-golang/lager, an opinionated logging library

    Rubyist/circuitbreaker, Circuit Breaker Library

    Sirupsen/logrus, structured, pluggable logging for go★

    Sourcegraph/appdash, application tracing system based on Google ' s Dapper

    Spacemonkeygo/monitor, data collection, monitoring, instrumentation, and Zipkin client library

    Streadway/handy, Net/http handler filters

    Vitess/rpcplus, package RPC + context. Context

    Gdamore/mangos, nanomsg implementation in pure Go

  3. Web Framework

    Beego

    Gin

    Goji

    Gorilla

    Martini

    Negroni

    Revel (considered harmful)

  4. # # #其他参考

    Architecting for the Cloud-netflix

    Dapper, a large-scale distributed Systems tracing Infrastructure-google

    Your Server as a Function (PDF)-twitter

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.