60
“So, ihr macht dann mal Microservices!” Und nu? André Goliath (English slide deck for a german title, because why not)

Javaland 2017: "You´ll do microservices now". Now what?

Embed Size (px)

Citation preview

Page 1: Javaland 2017: "You´ll do microservices now". Now what?

“So, ihr macht dann mal Microservices!”

Und nu?

André Goliath

(English slide deck for a german title, because why not)

Page 2: Javaland 2017: "You´ll do microservices now". Now what?

Disclaimer

Everything in this talk is based on experiences…

… from my current project

… from other projects I worked on

… from other colleagues’ projects

… from other smart people

About me?

Full-Stack Dev. since around 2006.

But basically just a guy that worked on

and discussed a lot about microservices.

Page 3: Javaland 2017: "You´ll do microservices now". Now what?
Page 4: Javaland 2017: "You´ll do microservices now". Now what?

Spoiler:

That´s not how it works.

Page 5: Javaland 2017: "You´ll do microservices now". Now what?

Before we start:

What are we actually talking about?

What is a microservice?

Page 6: Javaland 2017: "You´ll do microservices now". Now what?

A microservice is not…

… something with X lines of code.

Page 7: Javaland 2017: "You´ll do microservices now". Now what?

A microservice is not…

… your monolith cut into pieces.(Well, maybe it is, if it was a good one.)

(But most likely not.)

Page 8: Javaland 2017: "You´ll do microservices now". Now what?

A microservice is not…

… the cure to all your pain.

Page 9: Javaland 2017: "You´ll do microservices now". Now what?

Anyway, let´s start coding!

Page 10: Javaland 2017: "You´ll do microservices now". Now what?
Page 11: Javaland 2017: "You´ll do microservices now". Now what?

Microservices are not about code.

They are about functional domains.

(Bummer, I know.)

Page 12: Javaland 2017: "You´ll do microservices now". Now what?

Designing a microservice landscape

is all about bounded contexts

and domain driven design.

https://www.infoq.com/minibooks/domain-driven-design-quickly

Page 13: Javaland 2017: "You´ll do microservices now". Now what?

Loose Frontend Integration

Accounts

Custo

mer

Managem

ent

Cre

dit

Card

Managem

ent

One Microservice represents

one domain.

Domains are technically separated

all the way from the Frontend to the Backend.

The concept of ‘microservices’

is only the first step in the right direction.

Eventually we want to achieve

truly Self Contained Systems.

Messaging / Data Sync.

Page 14: Javaland 2017: "You´ll do microservices now". Now what?

Big Pile of HTML

Accou

nts

Big Pile of Data

Custo

mer

Managem

ent

Cre

dit

Card

Managem

ent

You are not doing it right if your microservices

somewhat represent bounded contexts,

but everything above and below is shared

and tightly coupled. Things WILL break.

Please read up on domain driven

design before doing microservices.

Legacy Backends are no excuse.

Page 15: Javaland 2017: "You´ll do microservices now". Now what?

Okay, okay, got it. Domain first.

So we can code now, right?

Page 16: Javaland 2017: "You´ll do microservices now". Now what?

Yes, but know what you are doing!

Page 17: Javaland 2017: "You´ll do microservices now". Now what?

Spring Boot can be scary!(and sometimes somewhat frustrating)

Get to know it.

Page 18: Javaland 2017: "You´ll do microservices now". Now what?

Understand auto configuration

Page 19: Javaland 2017: "You´ll do microservices now". Now what?

C:\example\target>java -jar demo-0.0.1-SNAPSHOT.jar –debug

2017-03-26 13:54:24.371 DEBUG 5316 --- [ main]

AutoConfigurationReportLoggingInitializer :

=========================

AUTO-CONFIGURATION REPORT

=========================

Positive matches:

-----------------

DispatcherServletAutoConfiguration matched:

- @ConditionalOnClass found required class

'org.springframework.web.servlet.DispatcherServlet';

@ConditionalOnMissingClass did not find unwanted class (OnClassCondition)

- @ConditionalOnWebApplication (required) found StandardServletEnvironment

(OnWebApplicationCondition)

Negative matches:

-----------------

ActiveMQAutoConfiguration:

Did not match:

- @ConditionalOnClass did not find required classes

'javax.jms.ConnectionFactory', 'org.apache.activemq.ActiveMQConnectionFactory'

(OnClassCondition)

Page 20: Javaland 2017: "You´ll do microservices now". Now what?

Auto Configuration Test Questions• What does @EnableAutoConfiguration do?

• What is the purpose of spring.factories files?

• How would you replace the standard Spring Boot error page?

Try to solve this without looking up the docs, dive right into

org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration

Page 21: Javaland 2017: "You´ll do microservices now". Now what?

Read the release notes!

There WILL be breaking changes

going from 1.x to 1.y

Page 22: Javaland 2017: "You´ll do microservices now". Now what?

shamelessly copy&pasted from

https://github.com/spring-projects/spring-boot/wiki/spring-boot-1.3-release-notes

Page 23: Javaland 2017: "You´ll do microservices now". Now what?

Now you´ve got 1 Microservice.

How about 2? Or 100?

Page 24: Javaland 2017: "You´ll do microservices now". Now what?

1) Code sharing

2) Communication

3) Ops & Deployment

4) Compliance, Processes, Team Setup

Page 25: Javaland 2017: "You´ll do microservices now". Now what?

1)

Code Sharing

sharing is caring

Page 26: Javaland 2017: "You´ll do microservices now". Now what?

Share framework code, nothing else.

Page 27: Javaland 2017: "You´ll do microservices now". Now what?

Share framework code, nothing else.

If you have no regrets

about sharing your code

on github, it is probably

framework code

Page 28: Javaland 2017: "You´ll do microservices now". Now what?

Share framework code, nothing else.

Filter (security, logging, monitoring,…)

Error handling

Profile / Environment configuration

Logging configuration

Common documentation

If you have no regrets

about sharing your code

on github, it is probably

framework code

Page 29: Javaland 2017: "You´ll do microservices now". Now what?

2)

Communication

Blah, blah, blah, blah…

Page 30: Javaland 2017: "You´ll do microservices now". Now what?

There are (at least) 2 different kinds

of communication going on

Page 31: Javaland 2017: "You´ll do microservices now". Now what?

Client Microservice Communication

REST, but how?

HATEOAS yes/no/maybe?

One API for all clients?

Page 32: Javaland 2017: "You´ll do microservices now". Now what?

Customer Search Card Management Account Management

„Backend“ Microservices

Mobile App Online Banking Branch

Actual Frontends

Page 33: Javaland 2017: "You´ll do microservices now". Now what?

Customer Search Card Management Account Management

„Backend“ Microservices

Mobile App Online Banking Branch

Actual Frontends

„API Gateway“ / „BFF (Backend For Frontend)“ Microservices

Mobile App

BFF Service

Online Banking

BFF Service

Branch

BFF Service

Page 34: Javaland 2017: "You´ll do microservices now". Now what?

Customer Search Card Management Account Management

„Backend“ Microservices

Mobile App

BFF Service

Online Banking

BFF Service

Branch

BFF Service

Mobile App Online Banking Branch

Actual Frontends

„API Gateway“ / „BFF (Backend For Frontend)“ Microservices

Data

TailoringHATEOAS

Links

Service

Orchestration

Clientspecific

Security

Page 35: Javaland 2017: "You´ll do microservices now". Now what?

Microservice Microservice Communication

REST will usually work.

But many use cases profit

from asynchronous messaging.

(Just talk to one of the ‘reactive’ experts)

Page 36: Javaland 2017: "You´ll do microservices now". Now what?

3)

Ops and Deployment

Page 37: Javaland 2017: "You´ll do microservices now". Now what?

Keep in mind:

Microservices make devs’ life a lot easier,

but will make ops’ life much more difficult.

Page 38: Javaland 2017: "You´ll do microservices now". Now what?

Keep in mind:

Microservices make devs’ life a lot easier,

but will make ops’ life much more difficult.

TALK TO THEM. EARLY. OFTEN.

THEY ARE YOUR FRIENDS.

Page 39: Javaland 2017: "You´ll do microservices now". Now what?

The three golden rules

of microservice deployments

(In my opinion. Don´t ask for scientific proof.)

Page 40: Javaland 2017: "You´ll do microservices now". Now what?

1) Build once, run everywhere.

Page 41: Javaland 2017: "You´ll do microservices now". Now what?

Build once, run everywhere.

A microservice JAR file is built exactly once

and then never touched again.

Goodjava –jar service.jar –spring.profiles.active=“production”

Badmvn clean install spring-boot:repackage -P “production”

Page 42: Javaland 2017: "You´ll do microservices now". Now what?

2) Use the same tools. Everywhere.

Page 43: Javaland 2017: "You´ll do microservices now". Now what?

Use the same tools. Everywhere.

Development, test, production. Everywhere.

Page 44: Javaland 2017: "You´ll do microservices now". Now what?

Use the same tools. Everywhere.

Development, test, production. Everywhere.

no can do

in

Production

Page 45: Javaland 2017: "You´ll do microservices now". Now what?
Page 46: Javaland 2017: "You´ll do microservices now". Now what?

“You can not use the same software tools and

infrastructure components in test and production.”

– No regulatory body, never.

Page 47: Javaland 2017: "You´ll do microservices now". Now what?

DeveloperJenkins / Ansible / PaaS / …

Development / Test Environment

Service

Host A

Service

Host B

Config

Server

Ops Guy

Production Environment

Gateway

Jenkins / Ansible / PaaS / …

Service

Host A

Service

Host B

Config

Server

Use a gateway if you need to.

“You can not use the same software tools and

infrastructure components in test and production.”

– No regulatory body, never.

Note: This has nothing to do with DevOps*.

*) DevOps is helpful, but by no means required. Nevertheless, Dev and Ops need to talk.

Page 48: Javaland 2017: "You´ll do microservices now". Now what?

3) if it hurts, do it more often.

You’ve heard that one before?

SCRUM feedback cycles maybe?

Page 49: Javaland 2017: "You´ll do microservices now". Now what?

if it hurts, do it more often.

The most important steps of a delivery pipeline

should be based on the most tested and

bullet-proof processes and tools.

Page 50: Javaland 2017: "You´ll do microservices now". Now what?

That´s hardly the case

if you deploy to production only twice a year

and use production-only scripts for that.

if it hurts, do it more often.

The most important steps of a delivery pipeline

should be based on the most tested and

bullet-proof processes and tools.

Page 51: Javaland 2017: "You´ll do microservices now". Now what?

4)

Compliance, Processes, Team Setup

Strong, the dark side is with this one...

Page 52: Javaland 2017: "You´ll do microservices now". Now what?

Very specific to your individual setting.

Here are two general tips though.

Page 53: Javaland 2017: "You´ll do microservices now". Now what?

1)

Don´t let the word ‘Compliance’ stop you

from taking the first steps to revamp

your software delivery process.

Page 54: Javaland 2017: "You´ll do microservices now". Now what?

2)

The company needs to work vertically,

not horizontally.

Page 55: Javaland 2017: "You´ll do microservices now". Now what?

Team „Business“

Team „Frontend Developer“

Team „Middleware Developer“

Team „Database and Backend Gurus“

Credits Online Channels

Internal Online

JEE COBOL

COBOL DB Admins

Teaming up along technology

antagonizes a domain driven

software architecture.

(Ever heard of

Conway’s law?)

Page 56: Javaland 2017: "You´ll do microservices now". Now what?

Team „Credit“

Domain Experts

Domain Experts

Frontend Frontend

Tester

Tester

BackendBackend

Teaming up along domain

expertise makes

Domain Driven Development

much easier.

Team „Account“

Page 57: Javaland 2017: "You´ll do microservices now". Now what?

Team „Credit“

Domain Experts

Domain Experts

Frontend

Tester

Tester

BackendBackend

Still, Tech Experts

need to be aware

of each other.

But it remains a

“Domain First” organization.

Team „Account“

Frontend

Page 58: Javaland 2017: "You´ll do microservices now". Now what?

Key Takeaways

Page 59: Javaland 2017: "You´ll do microservices now". Now what?

A microservice is defined by a Bounded Context,

not by anything else.

Know your Spring Boot (or whatever else you use).

Build once, run everywhere.

Use the same tools. Everywhere.

if it hurts, do it more often.

Don’t let ‘Compliance’ stop you.

Only vertical teams will succeed.

Page 60: Javaland 2017: "You´ll do microservices now". Now what?

Thank You!

André Goliath

[email protected]

https://www.slideshare.net/andregoliath

https://blog.senacor.com/author/andre/