Microservices with Spring Boot

35
Josh Long (之春) @starbuxman [email protected] slideshare.net/joshlong github.com/joshlong http://spring.io MICROSERVICES BOOTIFUL

description

A talk introducing Microservices with Spring Boot

Transcript of Microservices with Spring Boot

Page 1: Microservices with Spring Boot

Josh Long (⻰龙之春) @starbuxman

[email protected] slideshare.net/joshlong

github.com/joshlong http://spring.io

MICROSERVICESBOOTIFUL

Page 2: Microservices with Spring Boot

@starbuxman

Spring Developer AdvocateJosh Long (⻰龙之春)

@starbuxman [email protected] |

Jean Claude van Damme! Java mascot Duke some thing’s I’ve authored...

Page 3: Microservices with Spring Boot

@starbuxman

Page 4: Microservices with Spring Boot

@starbuxman

Page 5: Microservices with Spring Boot

@starbuxman

Page 6: Microservices with Spring Boot

@starbuxman

WEB

Controllers, REST,WebSocket

INTEGRATION

Channels, Adapters,Filters, Transformers

BATCH

Jobs, Steps,Readers, Writers

BIG DATA

Ingestion, Export,Orchestration, Hadoop

DATA

NON-RELATIONALRELATIONAL

CORE

GROOVYFRAMEWORK SECURITY REACTOR

GRAILS

Full-stack, Web

XD

Stream, Taps, Jobs

BOOT

Bootable, Minimal, Ops-Ready

Page 7: Microservices with Spring Boot

@starbuxman

Microservices - just SOA redux? What does the DRY principle, microservices, SOA, and Unix command line tools have in common? They promote singly-focused*, loosely-connected systems

In object-oriented programming, the single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.!

* http://en.wikipedia.org/wiki/Single_responsibility_principle

Page 8: Microservices with Spring Boot

@starbuxman

Singly focused? Do as little as possible. Express and expose a service, isolated and encapsulated.

Page 9: Microservices with Spring Boot

@starbuxman

How do you expose a service?

How do you do so simply?

Page 10: Microservices with Spring Boot

Title Text@starbuxman

…when somebody says SOAP is “SIMPLE”

Page 11: Microservices with Spring Boot

@starbuxman

REST has no hard and fast rules. REST is an architectural style, not a standard. REST uses Headers to describe requests & responses

REST embraces HTTP verbs. (DRY)

Page 12: Microservices with Spring Boot

@starbuxman

status codes convey the result of the server’s attempt to satisfy the request. Categories: 1xx: informational 2xx: success 3xx: redirection 4xx: client error 5xx: server error

Page 13: Microservices with Spring Boot

@starbuxman

The Richardson Maturity Model is a way to grade your API according to the REST constraints with 4 levels of increasing compliance !

http://martinfowler.com/articles/richardsonMaturityModel.html

Page 14: Microservices with Spring Boot

@starbuxman

The Richardson Maturity Model Level 0: swamp of POX

http://martinfowler.com/articles/richardsonMaturityModel.html

Uses HTTP mainly as a tunnel through one URI e.g., SOAP, XML-RPC Usually features on HTTP verb (POST)

Page 15: Microservices with Spring Boot

@starbuxman

The Richardson Maturity Model Level 1: resources

http://martinfowler.com/articles/richardsonMaturityModel.html

Multiple URIs to distinguish related nouns e.g., /articles/1, /articles/2, vs. just /articles

Page 16: Microservices with Spring Boot

@starbuxman

The Richardson Maturity Model Level 2: HTTP verbs

http://martinfowler.com/articles/richardsonMaturityModel.html

leverage transport-native properties to enhance service e.g., HTTP GET and PUT and DELETE and POSTUses idiomatic HTTP controls like status codes, headers

Page 17: Microservices with Spring Boot

DemonstrationOur first @RestController

Page 18: Microservices with Spring Boot

DemonstrationWhat about headers and status codes??

Page 19: Microservices with Spring Boot

@starbuxman

The Richardson Maturity Model Level 3: Hypermedia Controls (aka, HATEOAS)

http://martinfowler.com/articles/richardsonMaturityModel.html

No a priori knowledge of service requiredNavigation options are provided by service and hypermedia controlsPromotes longevity through a uniform interface

Page 20: Microservices with Spring Boot

@starbuxman

Links provide possible navigations from a given resource !Links are dynamic, based on resource state. !

<link href=“http://...:8080/users/232/customers” rel= “customers”/>

Page 21: Microservices with Spring Boot

DemonstrationWorking with Hypermedia and Spring HATEOAS

Page 22: Microservices with Spring Boot

@starbuxman

Security is hard. Don’t reinvent the wheel! !Things to worry about when developing web applications? EVERYTHING !(cross-site scripting, session fixation, identification, authorization, and authentication, encryption, and SO much more.)

Page 23: Microservices with Spring Boot

@starbuxman

Usernames and Passwords !If you can trust the client to keep a secret like a password, then it can send the password using: ...HTTP Basic - passwords are sent plaintext! ... HTTP Digest - hashed passwords, but still plaintext. SSL/TLS encryption helps prevent man-in-the-middle attacks

Page 24: Microservices with Spring Boot

@starbuxman

Tim Bray says: Passwords don’t scale !Too easy to compromise. !Updating all your clients whenever you change your password would be a nightmare! !

Page 25: Microservices with Spring Boot

@starbuxman

OAuth is a way for one (automated) client to securely identify itself to another service !Assumes a user context: ! “I authorize $CLIENTX to act on $USER_Y’s behalf” !OAuth is a way of authorizing a client with particular access (scopes) !

Page 26: Microservices with Spring Boot

@starbuxman

Page 27: Microservices with Spring Boot

@starbuxman

Page 28: Microservices with Spring Boot

@starbuxman

Page 29: Microservices with Spring Boot

DemonstrationOAuth

Page 30: Microservices with Spring Boot

@starbuxman

So, SSL/TLS is...? !an implementation of public key cryptography: !!!

public key cryptography only works because we all agree to trust well known root CAs

so trust!wow

Page 31: Microservices with Spring Boot

@starbuxman

SSL/TLS is used routinely to verify the identify of servers. !Normally, the client confirms the server, but the server rarely requires the client to transmit a certificate. !It’s easy enough to setup SSL/TLS on your web server. !

Page 32: Microservices with Spring Boot

@starbuxman

from “Release It!”: feature complete != production ready !A microservice needs to be able to slot into a system’s monitoring, management, and other infrastructure !How do you add health checks? !JMX support? Analytics like Graphite?

Page 33: Microservices with Spring Boot

DemonstrationDesigning (or configuring!) for production

Page 34: Microservices with Spring Boot

@starbuxman

What about routing? Load balancing? Enter the smart service host, or, PaaS !You don’t want to handle this in your code. !You could build a platform that handles these things for you like Netflix, Foursquare, eBay, Google and others did. !Or you could simply use a Platform-as-a-Service, like Cloud Foundry, Heroku, OpenShift, or Azure

SPRING WORKS WELL IN THE CLOUD

Page 35: Microservices with Spring Boot

@starbuxman

Questions?References

spring.io github.com/joshlong/bookmarks github.com/joshlong/boot-it-up github.com/joshlong/boot-examples docs.spring.io/spring-boot/ !

Josh Long (⻰龙之春)

@starbuxman [email protected]

slideshare.net/joshlong github.com/joshlong

http://spring.io