dmitry petukhov (provectus): "МИКРОСЕРВИСЫ НА ПРАКТИКЕ....

37
MICROSERVICES IN REALITY: INCEPTION Dmitry Petukhov / Upwork Mobile API [email protected]

Upload: provectus

Post on 22-Jan-2018

148 views

Category:

Technology


0 download

TRANSCRIPT

MICROSERVICES IN REALITY:INCEPTION

Dmitry Petukhov / Upwork Mobile [email protected]

What are Microservices

?

Features Known

● modularity a step towards clean architecture● single responsibility principle SOLID app!● distributed deployment model scalable app!● full isolation of:

○ teams and backlogs bye 30-min meetings!○ versioning CI increments it when needed○ repositories a repo per module is faultless○ documentation small separated docs○ CI servers concurrent build of everything○ hardware isolation of JVMs and instances

Microservices vs

monoliths

Monolith

”$ pidof java9927 2151

$ ps aux | grep -v grep | grep java | awk '{print $2}'99272151

Microservice

- Milen Dyankov / Liferay, JPoint 2017

Common Idea

Microservices inJ2EE containers?

● Glassfish● JBoss / WildFly● WebSphere● WebLogic etc.

Microservices = SOA -- ESB - SOAP- centralized DB/mgmt- fixed vendors+ REST/HTTP + CI/CD + DevOps+ cross-language + containerization+ Cloud/PaaS

- Arun Gupta / AWS

Microserviceson modularplatforms?

● OSGi containers● JBoss Modules

Why use microservices

?

Benefits of Microservices

● Independent of languages true polyglot programming● Independent of frameworks choose best for purpose● Independent of datasources SQL, NoSQL, files, streams● Independent of other microservices except contracts● Independent of UI frontend guys don't even know you● Asynchronous speed up your system X times● Observable monitoring, logging, tracing● Testable embraces automated testing

What People Say

Microservicesreducecomplexity!

...do they?

Under the Hood

– Complexity reduced!

Companies Evolved To Microservices

● Google● Netflix● eBay● Amazon● Facebook

Are you operating on

the samescale?

● PayPal● Twitter● Walmart● Spotify● LinkedIn

Monolith First / Martin Fowler

Don't Start With A Monolith / Stefan Tilkov

Microservices vs Modularity / Milen Dyankov

Milen Dyankov -

Microservices and

Modularity or the difference

between treatment and cure!

JUG .ru

149 views

Uploaded on May 4, 2017

1:02:08

How we do microservices

at Upwork

Upwork Mission

1 2

3

14Musers

Upwork in Numbers

300services

30teams

Mobile API is presented by

2 teams and 11 services

Upwork Mobile API

Technology stack

Guice

REST API

● Server-side query engine greatly enriches plain REST● CQRS segregation supports queries and mutations● Sync/async execution even better in GraphQL 5.0● Schema as documentation yet another doc for your API

Service security

Business Access

Permissions

● Authentication (401)● Authorization (403)● Session management (SSO)● OAuth 2.0● JWT authorization tokens

● Role-based access● Group-based access● User-based access

Resilience

● Fault-tolerance with fallback no more cascading failures● Repeatable commands configurable● Sync/async/reactive execution thanks to RxJava!● Latency metrics for each call● Web dashboard see problems on circuits instantly

Inter-service communication

● Cross-language support● Lightweight serialization● Binary protocols

Apache Thrift

Logging

+ Transparent logging unique request ID across the system+ All services have logs from API Gateway to DB workers+ 2K requests/sec ~10K log entries per second+ Automated request logging on every Hystrix call

Monitoring and tracing

+ Hystrix metrics and healtchecks built-in+ Dropwizard metrics and healthchecks built-in+ Brave/Zipkin tracing request timespans+ Metrix from JVM threads, GC, memory, NIO buffers etc.+ Custom endpoints /ping, /properties etc.+ AWS monitoring Cloudwatch, RDS, Asgard etc.+ 3rd party monitoring Kafka/Hermes, RMQ, Icinga,

Configuration

Static

● Source configuration files● Jenkins configurations for

build & deployment

Dynamic

● Git repos for dynamic settings● Endpoints to rewrite dynamic

settings

Testing

● API unit- and IT tests JUnit/Mockito/TestNG● API load testing JMeter● API regression testing Chakram JS● Manual testing

Data storages

Documentation

1 GraphQL API Doc 2 Swagger UI Doc

upstream

requests

downstream

request

Request Processing

Jersey

endpoints

Handler

A

Handler

B

Handler

C

Operation

Handlers

Service A

Service B1

Service B2

Business

Services

Service C

Upstream

Commands

GraphQL

engine

Single-

threaded

strategy

Multi-

threaded

strategy

Resource

A

Resource

B

Resource

C

Management Console

Thank you!

from monolith to microservices

metrics, monitoring, logging

eventual consistency

transactionality

data sources

blue/green

documentation

runtime dependencies

source code dependencies

static and dynamic configuration

introducing new microservices

splitting existing service

service discovery

loadbalancing

security

resilience

fault-tolerance

invocation retries

asynchronous communication

dynamic request routing (fallbacks)

Q & A