Microservice Architectures Dr. Andreas Schroeder



Similar documents
The Hyper-Text Transfer Protocol (HTTP)

Hypertext for Hyper Techs

THE PROXY SERVER 1 1 PURPOSE 3 2 USAGE EXAMPLES 4 3 STARTING THE PROXY SERVER 5 4 READING THE LOG 6

From the Monolith to Microservices: Evolving Your Architecture to Scale. Randy linkedin.com/in/randyshoup

CS640: Introduction to Computer Networks. Applications FTP: The File Transfer Protocol

Vodia PBX RESTful API (v2.0)

1. When will an IP process drop a datagram? 2. When will an IP process fragment a datagram? 3. When will a TCP process drop a segment?

Security Testing For RESTful Applications

reference: HTTP: The Definitive Guide by David Gourley and Brian Totty (O Reilly, 2002)

All You Can Eat Realtime

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

<Insert Picture Here> Oracle Web Cache 11g Overview

Table of Contents. Open-Xchange Authentication & Session Handling. 1.Introduction...3

REST web services. Representational State Transfer Author: Nemanja Kojic

Architecture of So-ware Systems HTTP Protocol. Mar8n Rehák

Project #2. CSE 123b Communications Software. HTTP Messages. HTTP Basics. HTTP Request. HTTP Request. Spring Four parts

Study of the architecture for a new webbased software system using commercial ERP system

API Architecture. for the Data Interoperability at OSU initiative

CONTENT of this CHAPTER

Web Services and Service Oriented Architectures. Thomas Soddemann, RZG

Business-Driven Software Engineering Lecture 3 Foundations of Processes

Adding scalability to legacy PHP web applications. Overview. Mario Valdez-Ramirez

Playing with Web Application Firewalls

Research of Web Real-Time Communication Based on Web Socket

Varnish Tips & Tricks, 2015 edition

Internet Technologies Internet Protocols and Services

CS 188/219. Scalable Internet Services Andrew Mutz October 8, 2015

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Security-Assessment.com White Paper Leveraging XSRF with Apache Web Server Compatibility with older browser feature and Java Applet

ebay : How is it a hit

World Wide Web. Before WWW

Modern Web Development From Angle Brackets to Web Sockets

Protocolo HTTP. Web and HTTP. HTTP overview. HTTP overview

HTTP Caching & Cache-Busting for Content Publishers

EnergySync and AquaSys. Technology and Architecture

Building Hyper-Scale Platform-as-a-Service Microservices with Microsoft Azure. Patriek van Dorp and Alex Thissen

Chapter 2 TOPOLOGY SELECTION. SYS-ED/ Computer Education Techniques, Inc.

Sticky Session Setup and Troubleshooting

Cache All The Things

Demystifying cache. Kristian Lyngstøl Product Specialist Varnish Software AS

Service Oriented Architecture

SiteCelerate white paper

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

Application layer Web 2.0

Reference Model for Cloud Applications CONSIDERATIONS FOR SW VENDORS BUILDING A SAAS SOLUTION

Session 6 Patterns and best practices in SOA/REST

Web Architecture I u

HTTP. Internet Engineering. Fall Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Service Oriented Architecture (SOA) Architecture, Governance, Standards and Technologies

perspective Microservices A New Application Paradigm Abstract

Service-Oriented Architecture and Software Engineering

HTTP Protocol. Bartosz Walter

International Journal of Engineering & Technology IJET-IJENS Vol:14 No:06 44

Jenkins User Conference Herzelia, July #jenkinsconf. Testing a Large Support Matrix Using Jenkins. Amir Kibbar HP

Outline SOA. Properties of SOA. Service 2/19/2016. Definitions. Comparison of component technologies. Definitions Component technologies

Oracle Communications WebRTC Session Controller: Basic Admin. Student Guide

LBL Application Availability Infrastructure Unified Secure Reverse Proxy

Designing RESTful Web Applications

Using SAML for Single Sign-On in the SOA Software Platform

DEPLOYMENT GUIDE DEPLOYING F5 WITH MICROSOFT WINDOWS SERVER 2008

Playing with Web Application Firewalls

Migrating Applications From IBM WebSphere to Apache Tomcat

Cloud computing - Architecting in the cloud

DEPLOYMENT GUIDE Version 1.2. Deploying the BIG-IP System v9.x with Microsoft IIS 7.0 and 7.5

Software-Defined Networks Powered by VellOS

DEPLOYMENT GUIDE DEPLOYING THE BIG-IP SYSTEM WITH MICROSOFT INTERNET INFORMATION SERVICES (IIS) 7.0

Network Technologies

The Web History (I) The Web History (II)

Put a Firewall in Your JVM Securing Java Applications!

Policy Guide Access Manager 3.1 SP5 January 2013

Choose an IBM WebSphere Application Server configuration to suit your business needs

CloudOYE CDN USER MANUAL

HTTP/2: Operable and Performant. Mark

Cyber Security Workshop Ethical Web Hacking

ORACLE COHERENCE 12CR2

DEPLOYMENT GUIDE Version 1.1. Deploying F5 with IBM WebSphere 7

Lecture 8a: WWW Proxy Servers and Cookies

Fairsail REST API: Guide for Developers

Customer Bank Account Management System Technical Specification Document

Setting the World on FHIR

Service-oriented architecture in e-commerce applications

Motivation Definitions EAI Architectures Elements Integration Technologies. Part I. EAI: Foundations, Concepts, and Architectures

Open Source egovernment Reference Architecture Osera.modeldriven.org. Copyright 2006 Data Access Technologies, Inc. Slide 1

Domain Name System (DNS)

The Virtualization Practice

Chapter 27 Hypertext Transfer Protocol

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

ORACLE MOBILE SUITE. Complete Mobile Development Solution. Cross Device Solution. Shared Services Infrastructure for Mobility

How Comcast Built An Open Source Content Delivery Network National Engineering & Technical Operations

DEPLOYMENT GUIDE Version 1.0. Deploying the BIG-IP LTM with Apache Tomcat and Apache HTTP Server

Cloud Powered Mobile Apps with Microsoft Azure

S y s t e m A r c h i t e c t u r e

Welcome to the Force.com Developer Day

WebSphere ESB Best Practices

Transcription:

Microservice Architectures Dr. Andreas Schroeder 1

About me Dr. Andreas Schroeder codecentric AG Elsenheimerstr 55A 80687 München andreas.schroeder@codecentric.de www.codecentric.de blog.codecentric.de 250+ staff 12 offfices (9 in Germany) Experts for developing custom IT solutions Involvement in the IT community via twitter github meetup 2

Agenda The Pain Therefore, Microservices Stable Interfaces: HTTP, JSON, REST Characteristics Comparison with Precursors Challenges With special focus on Service Versioning Conclusion 3

The Pain

Observed problems Area of consideration Web systems Built collaboratively by several development teams With traffic load that requires horizontal scaling (i.e. load balancing across multiple copies of the system) Observation Such systems are often built as monoliths or layered systems (JEE) 5

Software Monolith A Software Monolith One build and deployment unit One code base One technology stack (Linux, JVM, Tomcat, Libraries) Benefits Simple mental model for developers one unit of access for coding, building, and deploying Simple scaling model for operations just run multiple copies behind a load balancer 6

Problems of Software Monoliths Huge and intimidating code base for developers Development tools get overburdened refactorings take minutes builds take hours testing in continuous integration takes days Scaling is limited Running a copy of the whole system is resource-intense It doesn t scale with the data volume out-of-the-box Deployment frequency is limited Re-deploying means halting the whole system Re-deployments will fail and increase the perceived risk of deployment 7

Layered Systems A layered system decomposes a monolith into layers Usually: presentation, logic, data access At most one technology stack per layer Presentation: Linux, JVM, Tomcat, Libs, EJB client, JavaScript Logic: Linux, JVM, EJB container, Libs Data Access: Linux, JVM, EJB JPA, EJB container, Libs Benefits Presentation Logic Data Access Simple mental model, simple dependencies Simple deployment and scaling model DB 8

Problems of Layered Systems Still huge codebases (one per layer) with the same impact on development, building, and deployment Scaling works better, but still limited Staff growth is limited: roughly speaking, one team per layer works well Developers become specialists on their layer Communication between teams is biased by layer experience (or lack thereof) 9

Growing systems beyond the limits Applications and teams need to grow beyond the limits imposed by monoliths and layered systems, and they do in an uncontrolled way. Large companies end up with landscapes of layered systems that often interoperate in undocumented ways. These landscapes then often break in unexpected ways. How can a company grow and still have a working IT architecture and vision? Observing and documenting successful companies (e.g. Amazon, Netflix) lead to the definition of microservice architecture principles. 10

Therefore, Microservices

History 2011: First discussions using this term at a software architecture workshop near Venice May 2012: microservices settled as the most appropriate term March 2012: Java, the Unix Way at 33rd degree by James Lewis September 2012: µservice Architecture at Baruco by Fred George All along, Adrian Cockroft pioneered this style at Netflix as fine grained SOA James Lewis Fred George http://martinfowler.com/articles/microservices.html#footnote-etymology Adrian Cockroft 12

Underlying principle On the logical level, microservice architectures are defined by a functional system decomposition into manageable and independently deployable components The term micro refers to the sizing: a microservice must be manageable by a single development team (5-9 developers) Functional system decomposition means vertical slicing (in contrast to horizontal slicing through layers) Independent deployability implies no shared state and inter-process communication (often via HTTP REST-ish interfaces) 13

More specifically Each microservice is functionally complete with Resource representation Data management Each microservice handles one resource (or verb), e.g. Clients Shop Items Carts Checkout Microservices are fun-sized services, as in still fun to develop and deploy 14

Independent Deployability is key It enables separation and independent evolution of code base technology stacks scaling and features, too 15

Independent code base Each service has its own software repository Codebase is maintainable for developers it fits into their brain Tools work fast building, testing, refactoring code takes seconds Service startup only takes seconds No accidental cross-dependencies between code bases 16

Independent technology stacks Each service is implemented on its own technology stacks The technology stack can be selected to fit the task best Teams can also experiment with new technologies within a single microservice No system-wide standardized technology stack also means No struggle to get your technology introduced to the canon No piggy-pack dependencies to unnecessary technologies or libraries It s only your own dependency hell you need to struggle with Selected technology stacks are often very lightweight A microservice is often just a single process that is started via command line, and not code and configuration that is deployed to a container. 17

functional decomp. Independent Scaling Each microservice can be scaled independently Identified bottlenecks can be addressed directly Data sharding can be applied to microservices as needed Parts of the system that do not represent bottlenecks can remain simple and un-scaled Netflix Scaling Cube JEE Pet Store horizontal & vertical 18

Independent evolution of Features Microservices can be extended without affecting other services For example, you can deploy a new version of (a part of) the UI without re-deploying the whole system You can also go so far as to replace the service by a complete rewrite But you have to ensure that the service interface remains stable 19

Stable Interfaces standardized communication Communication between microservices is often standardized using HTTP(S) battle-tested and broadly available transport protocol REST uniform interfaces on data as resources with known manipulation means JSON simple data representation format REST and JSON are convenient because they simplify interface evolution (more on this later) 20

Stable Interfaces: HTTP, JSON, REST

HTTP Example GET / HTTP/1.1 Host: www.codecentric.de Connection: keep-alive Cache-Control: max-age=0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36 Accept-Encoding: gzip,deflate Accept-Language: de-de,de;q=0.8,en-us;q=0.6,en;q=0.4 Cookie: HTTP/1.1 200 OK Date: Tue, 21 Oct 2014 06:34:29 GMT Server: Apache/2.2.29 (Amazon) Cache-Control: no-cache, must-revalidate, max-age=0 Content-Encoding: gzip Content-Length: 8083 Connection: close Content-Type: text/html; charset=utf-8 22

HTTP Available verbs GET, POST, PUT, DELETE (and more) Safe verbs: GET (and others, but none of the above) Non-idempotent: POST (no other verb has this issue) Mechanisms for caching and cache control content negotiation session management user agent and server identification Status codes in response (200, 404, etc) for information, success, redirection, client error, server error Rich standardized interface for interacting over the net 23

JSON Minimal and popular data representation format Schemaless in principle, but can be validated if need be Example of two bank accounts: [{ "number" : 12345, "balance" : -20.00, "currency" : "EUR" }, { "number" : 12346, "balance" : 120.00, "currency" : "USD" }] json.org 24

REST REST is an architectural style for systems built on the web. It consists of a set of coordinated architectural constraints for distributed hypermedia systems. REST describes how to build systems on battle-tested protocols and standards that are already out there (like HTTP) REST describes the architectural ideas behind HTTP, and how HTTP can be used to do more than serving static web content 25

REST Architectural Constraints Client-Server: Separation of logic from user interface Stateless: no client context on the server Cacheable: reduce redundant interaction between client and server Layered System: intermediaries may relay communication between client and server (e.g. for load balancing) Code on demand: serve code to be executed on the client (e.g. JavaScript) Uniform interface Use of known HTTP verbs for manipulating resources Resource manipulation through representations which separated from internal representations Hypermedia as the engine of application state (HATEOAS): the response contains all allowed operations and the resource identifiers needed to trigger them 26

HATEOAS example in JSON Resource representation { "number" : 12345, "balance" : -20.00, "currency" : "EUR", "links" : [ { "rel" : "self", "href" : "https://bank.com/account/12345" }, { "rel" : "deposit", "href" : "https://bank.com/account/12345/deposit" } ] } relation name (known by clients) URI for operation 27

Stable Interfaces HTTP offers a rich set of standardized interaction mechanisms that still allow for scaling JSON offers a simple data format that can be (partially) validated REST provides principles and ideas for leveraging HTTP and JSON to build evolvable microservice interfaces Be of the web, not behind the web Ian Robinson 28

Characteristics

Componentization via Services Interaction mode: share-nothing, cross-process communication Independently deployable (with all the benefits) Explicit, REST-based public interface Sized and designed for replaceability Upgrading technologies should not happen big-bang, all-or-nothing-style Downsides Communication is more expensive than in-process Interfaces need to be coarser-grained Re-allocation of responsibilities between services is harder 30

Favors Cross-Functional Teams Line of separation is along functional boundaries, not along tiers Presentation VS Logic Data Access DB 31

Decentralized Governance Principle: focus on standardizing the relevant parts, and leverage battle-tested standards and infrastructure Treats differently What needs to be standardized Communication protocol (HTTP) Message format (JSON) What should be standardized Communication patterns (REST) What doesn t need to be standardized Application technology stack 32

Decentralized Data Management OO Encapsulation applies to services as well Each service can choose the persistence solution that fits best its Data access patterns Scaling and data sharding requirements Only few services really need enterprisey persistence 33

Infrastructure Automation Having to deploy significant number of services forces operations to automate the infrastructure for Deployment (Continuous Delivery) Monitoring (Automated failure detection) Managing (Automated failure recovery) Consider that: Amazon AWS is primarily an internal service Netflix uses Chaos Monkey to further enforce infrastructure resilience 34

Comparisons with Precursors

DATA SERVICE ORCHESTRATION Service-Oriented Architecture 36

Service-Oriented Architecture SOA systems also focus on functional decomposition, but services are not required to be self-contained with data and UI, most of the time the contrary is pictured. It is often thought as decomposition within tiers, and introducing another tier the service orchestration tier In comparison to microservices SOA is focused on enabling business-level programming through business processing engines and languages such as BPEL and BPMN SOA does not focus on independent deployment units and its consequences Microservices can be seen as SOA the good parts 37

Component-Based Software Engineering Underlying functional decomposition principle of microservices is basically the same. Additionally, the following similarities and differences exist: State model Many theoretical component models follow the share-nothing model Communication model Component technologies often focus on simulating in-process communication across processes (e.g. Java RPC, OSGi, EJB) Microservice communication is intra-process, serialization-based Code separation model Component technologies do require code separation Components are often developed in a common code repository Deployment model Components are often thought as being deployed into a uniform container 38

Challenges

Fallacies of Distributed Computing Essentially everyone, when they first build a distributed application, makes the following eight assumptions. All prove to be false in the long run and all cause big trouble and painful learning experiences. The network is reliable Latency is zero Bandwidth is infinite The network is secure Topology doesn t change There is one administrator Transport cost is zero The network is homogeneous Peter Deutsch 40

Microservices Prerequisites Before applying microservices, you should have in place Rapid provisioning Dev teams should be able to automatically provision new infrastructure Basic monitoring Essential to detect problems in the complex system landscape Rapid application deployment Service deployments must be controlled and traceable Rollbacks of deployments must be easy Source http://martinfowler.com/bliki/microserviceprerequisites.html 41

Evolving interfaces correctly Microservice architectures enable independent evolution of services but how is this done without breaking existing clients? There are two answers Version service APIs on incompatible API changes Using JSON and REST limits versioning needs of service APIs Versioning is key Service interfaces are like programmer APIs you need to know which version you program against As service provider, you need to keep old versions of your interface operational while delivering new versions But first, let s recap compatibility 42

API Compatibility There are two types of compatibility Forward Compatibility Upgrading the service in the future will not break existing clients Requires some agreements on future design features, and the design of new versions to respect old interfaces Backward Compatibility Newly created service is compatible with old clients Requires the design of new versions to respect old interfaces The hard type of compatibility is forward compatibility! 43

Forward compatibility through REST and JSON REST and JSON have a set of inherent agreements that benefit forward compatibility JSON: only validate for what you really need, and ignore unknown object fields (i.e. newly introduced ones) REST: HATEOAS links introduce server-controlled indirection between operations and their URIs { "number" : 12345,... "links" : [ { "https://accounts.bank.com/12345/deposit" "rel" : "deposit", "href" : "https://bank.com/account/12345/deposit" } ] } 44

Compatibility and Versioning Compatibility can t be always guaranteed, therefore versioning schemes (major.minor.point) are introduced Major version change: breaking API change Minor version change: compatible API change Note that versioning a service imposes work on the service provider Services need to exist in their old versions as long as they are used by clients The service provider has to deal with the mapping from old API to new API as long as old clients exist 45

REST API Versioning Three options exist for versioning a REST service API 1. Version URIs http://bank.com/v2/accounts 2. Custom HTTP header api-version: 2 3. Accept HTTP header Accept: application/vnd.accounts.v2+json Which option to choose? While developing use option 1, it is easy to pass around For production use option 3, it is the cleanest one 46

REST API Versioning It is important to version your API directly from the start install a clear policy on handling unversioned calls Service version 1? Service most version? Reject? Sources http://www.troyhunt.com/2014/02/your-api-versioning-is-wrong-which-is.html http://codebetter.com/howarddierking/2012/11/09/versioning-restful-services/ 47

Further Challenges Testing the whole system A single microservice isn t the whole system. A clear picture of upstream and downstream services is needed for integration testing Transactions Instead of distributed transactions, compensations are used (as in SOA) Authentication Is often offloaded to reverse proxies making use auf authentication (micro)services Request logging Pass along request tokens Add them to the log Perform log aggregation 48

Conclusion

Microservices: just? Just adopt? No. Microservices are a possible design alternative for new web systems and an evolution path for existing web systems. There are considerable amounts of warnings about challenges, complexities and prerequisites of microservices architectures from the community. Just the new fad? Yes and no. Microservices is a new term, and an evolution of long-known architectural principles applied in a specific way to a specific type of systems. The term is dev and ops-heavy, not so much managerial. The tech landscape is open source and vendor-free at the moment. 50

Summary There is an alternative to software monoliths Microservices: functional decomposition of systems into manageable and independently deployable services Microservice architectures means Independence in code, technology, scaling, evolution Using battle-tested infrastructure (HTTP, JSON, REST) Microservice architectures are challenging Compatibility and versioning while changing service interfaces transactions, testing, deploying, monitoring, tracing is/are harder Microservices are no silver bullet, but may be the best way forward for large web systems built by professional software engineers 51

Sources and Further Reading http://martinfowler.com/articles/microservices.html http://www.infoq.com/articles/microservices-intro http://brandur.org/microservices http://davidmorgantini.blogspot.de/2013/08/micro-services-what-are-micro-services.html http://12factor.net/ http://microservices.io/ https://rclayton.silvrback.com/failing-at-microservices http://www.activestate.com/blog/2014/09/microservices-and-paas-part-iii http://highscalability.com/blog/2014/7/28/the-great-microservices-vs-monolithic-apps-twittermelee.html http://capgemini.github.io/architecture/microservices-reality-check/ 52

Pictures Slide 1: Cover Picture Slide 6: Monolith Boris Macek Martin Dosch 53