Microservices pros and cons

of 20/20
Microservices Pros & Cons Things to Think About
  • date post

    14-Apr-2017
  • Category

    Software

  • view

    442
  • download

    0

Embed Size (px)

Transcript of Microservices pros and cons

Microservices

MicroservicesPros & Cons Things to Think About

What is a microservice?Small piece of software that does one thing really wellLoosely coupledSeparate data storeJust enough to solve a problemRight technology for the jobAutonomousCan update as often as is neededIntelligence in the service, not the routing/infrastructure/busImmutable infrastructure

Should I use microservices?It depends!Likely noThink about fallacies of distributed computing:The network is reliableLatency is zeroBandwidth is infiniteThe network is secureTopology doesnt changeThere is one administratorTransport cost is zeroThe network is homogeneous

When should I consider microservices?Many teams work on the same code baseMerge hell, cross team dependencies, ...Huge monolithic application which is difficult to deployMonolith cannot be scaled horizontallyDifferent parts of the application have totally different requirementsCPU boundI/O boundMemory boundetc.Some but not all areas of the application change frequentlyDevelopment stack is outdated. New tools and patterns are hard if not impossible to embrace

How big should a microservice be?Small enough to fit full context in your headBig enough to solve a problemOwned by one team

What does big enough look like...Some examples:Lambda: https://github.com/meconlin/lambda-generic-microservice C#: https://github.com/AFASSoftware/CQRS-Microservices Spring: https://github.com/kbastani/spring-cloud-microservice-exampleakka: https://github.com/theiterators/akka-http-microservicehttps://github.com/dustinbarnes/microservice-example

How should a microservice communicate?SynchronousAsynchronousMessagingFan outHTTP/RESTTCP/IPPub/sub

...but zero logic in the communication pipeline!

Are microservices less complex?Code wise, yesDeployment wise, yes

Infrastructure configuration wise, noDependency managementwise, no

Microservice Management Overview

How to manage microservices?Its a big world with lots of cutely named tools!

Deploy: Jenkins / TeamCity / Ansible / Chef / Capistrano / StackStormDiscovery/config: Consul / Consul-Templates / etcd / Registrator / skydnsContainers: Docker / Compose / Vagrant / Otto / LambdaContainer Clustering: ECS / Kubernetes / Mesos / Docker SwarmRequest Routing: Nginx / HAProxy / Kong / API GatewaySelf Healing: Consul / ZooKeeper / SerfSystem Health: hystrix, SumoLogic, Nagios, NewRelic, statsd, LogEntries

AUTOMATE EVERYTHING

DeploymentContinuous DeploymentContinuous DeliveryVersionedBlue / GreenA-B TestingNet new, add to routingZero downtime

Tools: Jenkins / TeamCity / Ansible / Chef / Capistrano / StackStorm

NEVER DESTRUCTIVE

Service Discovery & ConfigurationMinimize known dependenciesNo bottlenecks due to outage allowedDown stream health monitoringConfiguration at deployment time when possibleConfiguration in runtime if you have to (adds fragility/degradation)

Tools: Consul / Consul-Templates / etcd / Registrator / skydns

NO DEPENDENCY KNOWLEDGE

Containers & ClusteringRemoves works on my box storyInstalled software dependencies become constrained to your needNo more servers as petsInfrastructure as code becomes a realityCan deploy to fabric/cluster for better auto scaling storyServerless truly abstracts hardware from application

Tools: Docker / Compose / Vagrant / Otto / Lambda / AWS ECS / Kubernetes / Mesos / Docker Swarm

NO HARDWARE DEPENDENCY PREFERRED

Request RoutingPublic abstraction from internal detailsInternal location can become dynamicMultiple versions of the same thing can be long livedMakes deployment story more flexibleLive traffic can be drained overWarming up new instances is possible

Tools: Nginx / HAProxy / Kong / API Gateway

NEVER EXPOSE YOUR SERVICES DIRECTLY

Self HealingIts not IF it will fail but WHEN it will fail!

Auto healingAutomated RemediationCircuit breakerFallbacksGraceful degradationDont cascade failures

Tools: Consul / ZooKeeper / Serf

PLAN FOR FAILURE FIRST

System HealthMeasure anything, measure everythinghttps://codeascraft.com/2011/02/15/measure-anything-measure-everything/ Performance monitoring, exception monitoring, logs, metricsNewRelic, nagios, SumoLogicstatsd / graphite (hosted graphite) / kibana / grafana Centralized logging (logentries, logstash)Circuit Breaker (hystrix)

Tools: hystrix, SumoLogic, Nagios, NewRelic, statsd, LogEntries

VISUALIZE EVERYTHING

Circuit Breakers with Hystrix

Questions?James Allenhttp://www.linkedin.com/in/jamesallenatx

Miguel Gonzalezhttps://www.linkedin.com/in/[email protected]

Gabriel Schenkerhttps://www.linkedin.com/in/[email protected]

Andrew Siemerhttps://www.linkedin.com/in/[email protected]