LEAN & MEAN - GO MICROSERVICES WITH DOCKER SWARM AND SPRING CLOUD

Similar documents
LEAN & MEAN - GO MICROSERVICES WITH DOCKER SWARM MODE AND SPRING CLOUD

CADEC 2016 MICROSERVICES AND DOCKER CONTAINERS MAGNUS LARSSON

MICROSERVICES I PRAKTIKEN från tröga monoliter till en arkitektur för kortare ledtider, högre skalbarhet och ökad feltolerans

Microservices mit Java, Spring Boot & Spring Cloud. Eberhard Wolff

GAVIN KING RED HAT CEYLON SWARM

Cloud Native Architecture 300. Copyright 2014 Pivotal. All rights reserved.

Spring Cloud, Spring Boot and Netflix OSS

Microservices Implementations not only with Java. Eberhard Wolff Fellow

Four times Microservices: REST, Kubernetes, UI Integration, Async. Eberhard Fellow

grpc - A solution for RPCs by Google Distributed Systems Seminar at Charles University in Prague, Nov 2016 Jan Tattermusch - grpc Software Engineer

Developer Experience with. Spencer Gibb, Dave Syer, Spring Cloud

SQUASH. Debugger for microservices. Idit Levine solo.io

JFOKUS 2017 EXPERIENCES FROM USING DISCOVERY SERVICES IN A MICROSERVICE LANDSCAPE

Containers, Serverless and Functions in a nutshell. Eugene Fedorenko

Implementing Microservices Tracing with Spring Cloud and Zipkin

WHITE PAPER. RedHat OpenShift Container Platform. Benefits: Abstract. 1.1 Introduction

The Awesomeness of Go. Igor Lankin DevFest Karlsruhe, Nov 2016

SPRING CLOUD AGIM EMRULI - MIMACOM

Kubernetes 101. Doug Davis, STSM September, 2017

September 15th, Finagle + Java. A love story (

JAVA An overview for C++ programmers

Lessons learnt building Kubernetes controllers. David Cheney - Heptio

Think Small to Scale Big

Pontoon An Enterprise grade serverless framework using Kubernetes Kumar Gaurav, Director R&D, VMware Mageshwaran R, Staff Engineer R&D, VMware

The Long Road from Capistrano to Kubernetes

Ingress Kubernetes Tutorial

Lessons learnt building Kubernetes controllers. David Cheney - Heptio

SBB. Java User Group 27.9 & Tobias Denzler, Philipp Oser

A Tracing Technique for Understanding the Behavior of Large-Scale Distributed Systems

A New Model for Image Distribution

Open Cloud Engine - An Open Source Cloud Native Transformer

Microservices. Chaos Kontrolle mit Kubernetes. Robert Kubis - Developer Advocate,

Kuber-what?! Learn about Kubernetes

Eclipse MicroProfile with Thorntail (formerly WildFly Swarm)

Cloud Native Java with Kubernetes

Oh.. You got this? Attack the modern web

Go Faster: Containers, Platforms and the Path to Better Software Development (Including Live Demo)

Azure DevOps. Randy Pagels Intelligent Cloud Technical Specialist Great Lakes Region

Kubernetes The Path to Cloud Native

Important DevOps Technologies (3+2+3days) for Deployment

Accelerate at DevOps Speed With Openshift v3. Alessandro Vozza & Samuel Terburg Red Hat

ISTIO 1.0 INTRODUCTION & OVERVIEW OpenShift Commons Briefing Brian redbeard Harrington Product Manager, Istio

Introduction to Java Programming

Zero to Microservices in 5 minutes using Docker Containers. Mathew Lodge Weaveworks

Microservices stress-free and without increased heart-attack risk

Embedded type method, overriding, Error handling, Full-fledged web framework, 208 Function defer, 31 panic, 32 recover, 32 33

Building a video conference (WebRTC) controller with Elixir. Or how Elixir was introduced into VoiSmart

Open Cloud Engine - An Open Source Cloud Native Platform

What is Spring Cloud

Why real integration developers ride Camels

Index. Bessel function, 51 Big data, 1. Cloud-based version-control system, 226 Containerization, 30 application, 32 virtualize processes, 30 31

/ Cloud Computing. Recitation 5 February 14th, 2017

SAMPLE CHAPTER. John Carnell MANNING

AGILE DEVELOPMENT AND PAAS USING THE MESOSPHERE DCOS

Technologies for the future of Network Insight and Automation

CS-580K/480K Advanced Topics in Cloud Computing. Container III

Service Mesh with Istio on Kubernetes. Dmitry Burlea Software FlixCharter

Red Hat OpenShift Roadmap Q4 CY16 and H1 CY17 Releases. Lutz Lange Solution

Object-Oriented Programming CSCI-UA

Red Hat Atomic Details Dockah, Dockah, Dockah! Containerization as a shift of paradigm for the GNU/Linux OS

Nevin Dong 董乃文 Principle Technical Evangelist Microsoft Cooperation

ArcGIS for Server: Administration and Security. Amr Wahba

Investigating Containers for Future Services and User Application Support

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

OpenShift 3 Technical Architecture. Clayton Coleman, Dan McPherson Lead Engineers

64-bit ARM Unikernels on ukvm

Docker and Oracle Everything You Wanted To Know

CONTAINERIZATION ARCHITECT Certification. Containerization Architect

Implementing the Twelve-Factor App Methodology for Developing Cloud- Native Applications

Starting the Avalanche:

Cheat Sheet: Wildfly Swarm

Protocol Buffers, grpc

Managing your microservices with Kubernetes and Istio. Craig Box

Container 2.0. Container: check! But what about persistent data, big data or fast data?!

How to Re-Architect without Breaking Stuff (too much) Owen Garrett March 2018

An Introduction to Developing for Cisco Kinetic

DOCKER 101 FOR JS AFFICIONADOS. Christian Ulbrich, Zalari UG

BUILDING MICROSERVICES ON AZURE. ~ Vaibhav

Wrapp. Powered by AWS EC2 Container Service. Jude D Souza Solutions Wrapp Phone:

Accenture Cloud Platform Serverless Journey

Carbon Black QRadar App User Guide

Red Hat OpenShift Application Runtimes 0.1

Getting Started With Containers

Network Automation using modern tech. Egor Krivosheev 2degrees

Istio. A modern service mesh. Louis Ryan Principal

A Brief History of Distributed Programming: RPC. YOW Brisbane 2016

Creating Ultra-fast Realtime Apps and Microservices with Java. Markus Kett, CEO Jetstream Technologies

Microservice-Based Agile Architectures:

IBM Planning Analytics Workspace Local Distributed Soufiane Azizi. IBM Planning Analytics

Spark and Flink running scalable in Kubernetes Frank Conrad

Heroku. Rimantas Kybartas

In-cluster Open Source Testing Framework

{ REST } vs. Battle of API s

Container-based virtualization: Docker

Service Mesh and Related Microservice Technologies in ONAP

Functional Programming and the Web

Who am I? Harlan Iverson. Programming enthusiast. Seeker of truth. Imperfect. I'll be wrong about some things. Please correct me if you can.

The SMACK Stack: Spark*, Mesos*, Akka, Cassandra*, Kafka* Elizabeth K. Dublin Apache Kafka Meetup, 30 August 2017.

Diplomado Certificación

MSB to Support for Carrier Grade ONAP Microservice Architecture. Huabing Zhao, PTL of MSB Project, ZTE

Transcription:

LEAN & MEAN - GO MICROSERVICES WITH DOCKER SWARM AND SPRING CLOUD ERIK LUPANDER 2017-01-25 CALLISTAENTERPRISE.SE

2 What Go?

3

ON THE AGENDA Background: The footprint problem. The Go programming language and developing in Go. Go in the context of microservices, Spring Cloud/Netflix OSS and Docker Swarm. Demos! 4

THE FOOTPRINT PROBLEM Can Go help us help us reduce the footprint of a microservice? 5

THE FOOTPRINT PROBLEM As Björn just showed us, JVM-based solutions comes with a hefty footprint. If you need to run tens or even hundreds of microservice instances, cost is definitely a factor. For microservices, some other alternatives are NodeJS, C, C++, Python, Ruby and C#. Very interesting topic, we can return to it over beer tonight 6

THE GO LANGUAGE The Go Language 7

THE GO LANGUAGE Go is an attempt to combine the ease of programming of an interpreted, dynamically typed language, with the efficiency and safety of a statically typed, compiled language. Go official FAQ 8

THE GO LANGUAGE Go was designed 9

THE GO LANGUAGE to eliminate the slowness and clumsiness of software development at Google Go official FAQ 10

WHAT WAS FIXED? 50x build time improvement over C++ Internal C++ application builds taking 30-75 minutes. Language level concurrency Better dependency management Cross-platform builds Readable and maintainable code Even for non superstar developers 11

THE GO LANGUAGE Claims to be efficient, scalable and productive. Designed to improve the working environment for its designers and their coworkers. for people who write and read and debug and maintain large software systems. Is not a research language. 12

THE GO LANGUAGE Go is compiled, statically typed, concurrent, garbage-collected Has structs, pointers, interfaces, closures But does not have classes, inheritance, operator overloading, pointer arithmetic 13

WHY GOLANG - DEVELOPING What does actual developers think about Go? 14

a disservice to intelligent programmers Gary Willoughby - blogger 15

stuck in the 70 s Dan Given 16

17 psuedointellectual arrogance of Rob Pike and everything he stands for Keith Wesolowski

THE GO LANGUAGE But also 18

I like a lot of the design decisions they made in the [Go] language. Basically, I like all of them. Martin Odersky, creator of Scala 19

Go isn t functional, it s pragmatical. Frank Mueller, tech blogger 20

Go isn t a very good language in theory, but it s a great language in practice, and practice is all I care about anonymous hackernews poster 21

THE GO LANGUAGE Some pros and cons 22

DEVELOPMENT IN GOLANG - PROS Easy to learn, readable, productive and pretty powerful. The built-in concurrency is awesome. Cross-platform. Rich standard APIs and vibrant open source community. Quick turnaround and decent IDE support (getting better!) Nice bundled tools. Built-in unit testing, profiling, coverage, benchmarking, formatting, code quality Strongly opinionated. Code formatting, compile errors on typical warnings. 23

DEVELOPING IN GOLANG - SOME CONS Missing generics and more powerful built-in collection types. Dependency versioning Verbose Error checking, no autoboxing of primitive types etc. Unit testing and Mocking isn t very intuitive But pretty powerful once one gets the hang of it. 24

WHO USES GOLANG Some well-known software built entirely in golang Docker Kubernetes etcd Popularity rankings #13 on Tiobe Index per january 2017, up from #50, largest increase during 2016. 25

GOLANG - SYNTAX IN 2-5 MINUTES Two code samples 26

SAMPLE CODE 1 - HELLO WORLD 27

SAMPLE CODE 2 - CONCURRENCY 28

29 Go microservices

Docker Swarm cluster ARCHITECTURAL OVERVIEW Edge server (Netflix Zuul) Curl OAuth token relay Legend CB = Circuit Breaker (Go Hystrix) TA = Correlated tracing (Opentracing API / Zipkin) CB OAuth Authorization Server (spring-security) Security API (Go) OAuth Res CB / TA Monitor Dashboard (Hystrix Dashboard) Configuration Server (spring-cloudconfig) Account Composite (Go) CB / TA AMQP Hystrix Stream aggregation (Modified Netflix Turbine) AMQP Messaging (RabbitMQ) EventService (Go) Trace Analysis (Zipkin) TA TA Images (Go) Accounts (Go) Quotes-Service (Spring Boot)

WHY GOLANG - RUNTIME CHARACTERISTICS Low memory usage Overall performance on par with Java (as per Go 1.7) Fast startup However, Garbage Collector doesn t have ~20 years of maturity and isn t very configurable. 31

GO MICROSERVICES - STATICALLY LINKED BINARIES Statically linked binary produces an executable without external dependencies. No more jar- or dll-hell No requirement on the OS having a JRE or other libraries (except libc) Small executable Typically executable size for my microservices is 8-20 mb 32

DOCKER CONTAINERS & STATICALLY LINKED BINARIES In the context of Docker Containers, the statically linked binary allows use of very bare parent images. I m using iron/base which is ~6 mb, alpine is another popular choice. FROM iron/base EXPOSE 6868 ADD eventservice-linux-amd64 / ADD healthcheck-linux-amd64 / HEALTHCHECK CMD [./healthcheck-linux-amd64, -port=6868 ] ENTRYPOINT ["./eventservice-linux-amd64", -profile=test ] 33

Demo 1 Footprint @ Docker Swarm 34

GO MICROSERVICE CONSIDERATIONS? Microservices doesn t exist in isolation. A pleasant programming language and awesome runtime characteristics isn t quite enough. We need to integrate with various supporting services. 35

36 Consider:

MICROSERVICE CONSIDERATIONS Centralized configuration Service Discovery Logging Distributed Tracing Circuit Breaking Load balancing Edge Monitoring Authentication and Authorization 37

MICROSERVICE CONSIDERATIONS On the application level, also consider things like: HTTP / REST / RPC APIs Messaging APIs Persistence APIs Testability DevOps 38

MICROSERVICES - GO VS SPRING BOOT Spring Cloud / Netflix OSS with Spring Boot microservices provides a very streamlined annotation-driven configuration for integrating with these supporting services. Though the configuration files might be a bit complex. 39

MICROSERVICES - GO VS SPRING BOOT Go-based microservices in a Spring Cloud / Netflix OSS landscape requires more up-front work for integrating with the support components. With some basic software craftsmanship and code reuse I personally don t think it s a very big deal. I have published a Go-based microservice integration library for Spring Cloud / Netflix OSS on github: https://github.com/eriklupander/cloudtoolkit And there are a number of other more or less general purpose microservice toolkits for Go: go-kit, kite, micro, gizmo 40

Docker Swarm cluster ARCHITECTURAL OVERVIEW Edge server (Netflix Zuul) Curl OAuth token relay Legend CB = Circuit Breaker (Go Hystrix) TA = Correlated tracing (Opentracing API / Zipkin) CB OAuth Authorization Server (spring-security) Security API (Go) OAuth Res CB / TA Monitor Dashboard (Hystrix Dashboard) Configuration Server (spring-cloudconfig) Account Composite (Go) CB / TA AMQP Hystrix Stream aggregation (Modified Netflix Turbine) AMQP Messaging (RabbitMQ) EventService (Go) Trace Analysis (Zipkin) TA TA Images (Go) Accounts (Go) Quotes-Service (Spring Boot)

42 Things not really Go-related

EDGE SERVER Our Go services doesn t care about the EDGE / reverse-proxy Netflix Zuul, Nginx, HAProxy Must forward HTTP headers. 43

SERVICE DISCOVERY AND LOAD BALANCING Load-balancing and Service Discovery is handled by the orchestration engine. E.g. the Docker Swarm or Kubernetes Service abstraction. Eureka service discovery and Ribbon-like client-based loadbalancing is easily implemented too. 44

Demo 2 - Load balancing and fast scaling @ Docker Swarm 45

Go Microservice Anatomy TA 46

HTTP / REST FRAMEWORK HTTP/REST framework (gorilla) Configuration Server (spring-cloudconfig) Configuration Client (viper) Distributed Tracing (opentracing-go) Trace Analysis (Zipkin) Logger (logrus) AMQP Messaging (RabbitMQ) AMQP client (steadway/ amqp) Circuit Breaker (hystrix-go) Hystrix Stream aggregation (Modified Netflix Turbine) 47

HTTP FRAMEWORK (GORILLA) 48

HTTP FRAMEWORK (GORILLA) 49

CONFIGURATION HTTP/REST framework (gorilla) Configuration Server (spring-cloudconfig) Configuration Client (viper) Distributed Tracing (opentracing-go) Trace Analysis (Zipkin) Logger (logrus) AMQP Messaging (RabbitMQ) AMQP client (steadway/ amqp) Circuit Breaker (hystrix-go) Hystrix Stream aggregation (Modified Netflix Turbine) 50

CONFIGURATION USING SPRING CLOUD CONFIG AND VIPER Docker Swarm git repository HTTPS Configuration Server (spring-cloud-config) HTTP HTTP CB VIPER / TA CB VIPER / TA 51

CONFIGURATION - VIPER Viper supports YAML,.properties, JSON and Env-vars With a few lines of code, we can load and inject config from Spring Cloud Config into Viper 52

CONFIGURATION - VIPER USAGE 53

LOGGING HTTP/REST framework (gorilla) Configuration Server (spring-cloudconfig) Configuration Client (viper) Distributed Tracing (opentracing-go) Trace Analysis (Zipkin) Logger (logrus) AMQP Messaging (RabbitMQ) AMQP client (steadway/ amqp) Circuit Breaker (hystrix-go) Hystrix Stream aggregation (Modified Netflix Turbine) 54

LOGGING - LOGRUS Application logs with 3rd party library Logrus Supports levels, fields, formatters 30+ built-in hooks 55

DISTRIBUTED TRACING HTTP/REST framework (gorilla) Configuration Server (spring-cloudconfig) Configuration Client (viper) Distributed Tracing (opentracing-go) Trace Analysis (Zipkin) Logger (logrus) AMQP Messaging (RabbitMQ) AMQP client (steadway/ amqp) Circuit Breaker (hystrix-go) Hystrix Stream aggregation (Modified Netflix Turbine) 56

DISTRIBUTED TRACING Track a request over multiple microservices Also trace within services and methods Invaluable for high-level profiling across the service stack. go-opentracing and zipkin 57

DISTRIBUTED TRACING - ZIPKIN 58

CIRCUIT BREAKER HTTP/REST framework (gorilla) Configuration Server (spring-cloudconfig) Configuration Client (viper) Distributed Tracing (opentracing-go) Trace Analysis (Zipkin) Logger (logrus) AMQP Messaging (RabbitMQ) AMQP client (steadway/ amqp) Circuit Breaker (hystrix-go) Hystrix Stream aggregation (Modified Netflix Turbine) 59

CIRCUIT BREAKING - HYSTRIX Mechanism to make sure a single malfunctioning microservice doesn t halt the entire service or application. go-hystrix (circuit breaker) Netflix Turbine (aggregation) Netflix Hystrix (dashboard) 60

CIRCUIT BREAKING Example go-hystrix usage, non-blocking. 61

CIRCUIT BREAKING - HYSTRIX DASHBOARD 62

HYSTRIX STREAM AGGREGATION HTTP/REST framework (gorilla) Configuration Server (spring-cloudconfig) Configuration Client (viper) Distributed Tracing (opentracing-go) Trace Analysis (Zipkin) Logger (logrus) AMQP Messaging (RabbitMQ) AMQP client (steadway/ amqp) Circuit Breaker (hystrix-go) Hystrix Stream aggregation (Modified Netflix Turbine) 63

CIRCUIT BREAKING Hystrix stream aggregation using customized Netflix Turbine Go Services :8181/hystrix.stream CB / TA CB / TA :8181/hystrix.stream Hystrix Stream aggregation (Modified Netflix Turbine) :8282/turbine.stream Monitor Dashboard (Hystrix Dashboard) CB / TA :8181/hystrix.stream Client Discovery token Client Discovery token RabbitMQ 64

CIRCUIT BREAKING Programmatic hystrix configuration 65

SOME GENERAL CONSIDERATIONS Stability Let it crash. Let unrecoverable errors panic the microservice, let the container orchestrator handle restarts. Use HEALTHCHECK for liveness. Security EDGE + Auth Service Security context passed down the microservice stack using Go s standard Context object and HTTP headers. Testing of microservices Write unit tests as usual. Leverage Docker and the Go Docker Remote API to build integration tests with dependencies that s started with go test. I strongly recommend looking into net/http/httptest and GoConvey 66

SAMPLE CODE 3 - TESTING WITH GOCONVEY 67

SUMMARY Go is an interesting option for microservices due to runtime characteristics and rather pleasant developing. Genereally speaking, developing software in Go is often productive and quite fun, but not without it s fair share of quirks especially regarding the lack of traditional OO constructs and missing generics. Microservice development in Go requires a bit of work regarding integration with supporting services, but can be mitigated by using integration libraries such as go-kit or our own little cloud-toolkit. Don t be afraid to pick your favorites! 68

WANT TO LEARN MORE? Coming spring 2017 from Packt Technical reviewers: Magnus Larsson Erik Lupander 69

DVIZZ - A DOCKER SWARM VISUALIZER https://github.com/eriklupander/dvizz Pull requests are more than welcome! 70

RESOURCES Demo services: https://github.com/callistaenterprise/gocadec go-kit: https://github.com/go-kit/kit cloud-tookit: https://github.com/eriklupander/cloudtoolkit dvizz: https://github.com/eriklupander/dvizz packt book: https://www.packtpub.com/applicationdevelopment/building-microservices-go 71

72 Questions?