microservices and docker

33
Microservice s & Docker Võ Duy Tuấn CEO/Founder Teamcrop.com

Upload: vo-duy-tuan

Post on 11-Apr-2017

3.042 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Microservices and docker

Microservices & Docker

Võ Duy TuấnCEO/FounderTeamcrop.com

Page 2: Microservices and docker

• Monolithic vs Microservices

• Lesson learned

• Docker for microservices

Table of contents

Page 3: Microservices and docker

1. Monolithic

AB

C

Once upon a time…

DB

Page 4: Microservices and docker

1. Monolithic (cont.)

A

BC

1 year later…

DB

D

M

HL

K

G

I

EF

J

Page 5: Microservices and docker

1. Monolithic (cont.)

2 years later…

DB(Master)

DBDB(Slave)

Repl

icat

e

Load Balancer

Page 6: Microservices and docker

1. Monolithic (cont.)

3 years later…

DB(Master)

DBDB(Slave)

Repl

icat

e

Load Balancer

DB(Master)

DB(Slave)DB

(Slave)DB(Slave)DB

(Slave)

OH MY GOD!

Page 7: Microservices and docker

2. Microservices

A

B

C

Once upon a time…

DB1

Load Balancer

DB2

DB3

Page 8: Microservices and docker

2. Microservices (cont.)

A

B

C

1 year later…

D

G

H

E

K M

JL

I F

Load Balancer

DB1

DB2

DB3

DB4

DB5

OH MY GOD!

A

Page 9: Microservices and docker

DB1 (Slave)

2. Microservices (cont.)

A

2 years later…

Load Balancer

DB1(Master)AA

Repl

icat

e

……

Page 10: Microservices and docker

DB1 (Slave)

2. Microservices (cont.)

A

3 years later…

Load Balancer

DB1(Master)

AA

Repl

icat

e

……

AAA

DB1 (Slave)

DB1 (Slave)

DB1 (Slave)

DB1(Master)

Page 11: Microservices and docker

3. Summary of long term grow

MONOLITHIC MICROSERVICES

Page 12: Microservices and docker

Lesson Learned

Page 13: Microservices and docker

1. Bounded context

Page 14: Microservices and docker

1. Bounded context (cont.)

Page 15: Microservices and docker

2. Service Communication

• External request• Internal request• Message Queue

Page 16: Microservices and docker

2.1. External request

Service X

3rd-party system • JSON Web Token

(JWT):o Expirationo Blacklisto Sizeo CORS policy (ajax)

• Restful WS• Rate Limit

Page 17: Microservices and docker

2.2. Internal request

Service X

• Access Trusted Network:o Key exchangeo Overheado Monitoro Fail in the middleo Timeouto SDKo Request type:

o Fire & Waito Fire & Forget

Service Y

Page 18: Microservices and docker

2.3. Message Queue

Service X

• Service Bus:o Pub/Subo Acko Retryo Delayo Load Balancero Consumer HA

Service Z

Call X Call Y Call X Call A

Call X BrokerCall X

Call X Call Y

Job Queue (Ex: RabbitMQ)

Page 19: Microservices and docker

3. Centralized Configuration

Page 20: Microservices and docker

4. Request Log

Page 21: Microservices and docker

5. Service Monitoring

status.teamcrop.com

Page 22: Microservices and docker

6. Service discovery

Page 23: Microservices and docker

OPS / Service discovery (cont.)

Page 24: Microservices and docker

6. Service discovery (cont.)

HAProxy

Consul-template

Docker Engine

Backend 01 : Port 32680

Backend 02 : Port 32681

Backend 03 : Port 32682

Update haproxy.cfg& Reload haproxy

CONSUL REGISTRATOR

Notify

Update

Pull1

2

3

45

Client

gliderlabs/registratorgliderlabs/consul-server

Page 25: Microservices and docker

7. Distributed Transaction

T: TransactionC: Compensation (Undo)

Learn more: http://kellabyte.com/2012/05/30/clarifying-the-saga-pattern/

SAGA Pattern

Page 26: Microservices and docker

8. Deployment

Page 27: Microservices and docker

Docker for Microservices

Page 28: Microservices and docker

1. What is Docker?

Page 29: Microservices and docker

2. Docker container in real

Page 30: Microservices and docker

3. Docker container stats> docker stats $(docker ps --format '{{.Names}}')

Page 31: Microservices and docker

4. Docker RUN example

docker run -ti -d \

-h tc-notify \

--restart=always \

--name tc-notify-$RANDOM -p :80 \

-e SERVICE_TAGS=tc-notify \

-e SERVICE_NAME=tc-microx \

-e CONFIG_URL=http://configurl.com/?abc \

-e LOG_IP=127.0.0.1 \

-v /data/logs/tc-notify:/var/www/log \

teamcropregistry.com/teamcrop/tc-notify

Page 32: Microservices and docker

5. Docker UI - Rancher

Page 33: Microservices and docker

Thanks!CONTACT:[email protected]

0938 916 902

teamcrop.com