how to shrink from 5 tiers to 2 in a multitier microservices architecture

37
#nginx #nginxconf 1 Hello, My name is Vasiliy I am a Sr. Developer with My.com, Mail.Ru, Moscow HQ

Upload: vsoshnikov

Post on 22-Jan-2018

521 views

Category:

Software


0 download

TRANSCRIPT

Page 1: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf1

Hello,

My name is Vasiliy I am a Sr. Developer with My.com, Mail.Ru, Moscow HQ

Page 2: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

Page 3: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf

• Introduction • How it works • Examples • Benchmarks

3

Agenda

Page 4: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf4

CachesApplicationserver #1

Architecture

Applicationserver #N

Read-only slavesWrite-only master

Async replication

Page 5: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf5

Tier 1 - NginXTier 2 - application server, some languageTier 3 - cache or cachesTier 4 - database proxyTier 5 - database server

Tiers

Page 6: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf6

From 5 tiers to 2

database & database proxy

CachesApplication

server

ТTARANTOOL

Tarantoolupstream module

VS

Page 7: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf7

Tier 1, 4 - NginXTier 2 - Tarantool, it is Lua application serverTier 3 - Tarantool, it is fast as cacheTier 5 - Tarantool, it is database with ACID transactions

Tiers

Page 8: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

How it works

Page 9: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf9

NginX & Tarantool

ТTARANTOOL

Tarantoolupstream module

JSON RPC or REST

MSGPack

Page 10: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf

• Docker images• https://hub.docker.com/r/tarantool/tarantool-nginx • https://hub.docker.com/r/tarantool/tarantool • Packages• https://tarantool.org/download.html • Sources• https://github.com/tarantool • https://github.com/tarantool/nginx_upstream_module

10

Download NginX & Tarantool

Page 11: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf11

Configure NginX

Page 12: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf12

Create a function inside Tarantool

Page 13: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf13

Launch Tarantool

Page 14: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf14

1.$ wget '0.0.0.0:8081/api/do?arg_1=1&arg_2=2'2.$ cat do*{"id":0, "result": [ [“first"], [ { "request":{"arg_2":"2","arg_1":"1"} "1":"Goodbye world!" } ]]}

Get result

Page 15: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

Some REST features

Page 16: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf16

1.nginx.conf directive - tnt_http_rest_methods2.HOST:PORT/FUNCTION_NAME/PATH?ARGS3.FUNCTION_NAME is optional4.PATH and ARGS are optionals

REST

Page 17: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf17

Add new location

Page 18: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf18

Add new function

Page 19: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf19

1.$ wget '0.0.0.0:8081/api_2/do?arg_1=1&arg_2=2'2.$ HTTP request sent, awaiting response... 405 Not Allowed

Try #1

Page 20: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf20

1.$ wget '0.0.0.0:8081/api_2/do?arg_1=1&arg_2=2' \2. --post-data='{"params":["String", 1, [{"rest":"args"}]]}'3.$ cat do*{"id":0, "result": [[true]]}

Try #2

Page 21: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf21

1.$ wget '0.0.0.0:8081/api_2/do?arg_1=1&arg_2=2' \2. --post-data='{"params":["String", 1, [{"rest":"args"}]]}'3.$ cat do*{"id":0,"error":{"message":"Duplicate key exists in <CUT>""code":-32771}}

Try #3

Page 22: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf22

Get some dataNew NginX location

New function

Page 23: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf23

1.$ wget '0.0.0.0:8081/get?str=String&num=1'2.$ cat get*{"id":0, "result":[ [1,"String",1,[{"rest":"args"}], {"method":"POST", … ]}

Get result

Page 24: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

Some RPC features

Page 25: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf25

1.If we are speaking in the context of NginX and Tarantool, the RPC and the REST are equal.

2.But, the FUNCTION_NAME has to be passed through json body.

RPC

Page 26: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf26

Method nameNew NginX location

New function

Page 27: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf27

1.$ wget '0.0.0.0:8081/tnt' \2. --post-data='{"method":"get_2", "params":["String", 1]}'3.$ cat get*{"id":0, "result":[ [1,”String",1,[{"rest":"args"}], {"method":"POST", … ]}

Get result

Page 28: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

Some microservices examples

Page 29: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf29

The architecture #1

Applicationserver #1

Applicationserver #N

ТTARANTOOL

database & database proxy

Page 30: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf30

The architecture #2

ТTARANTOOL Application

server #N database

Applicationserver #N database

ТTARANTOOL

Applicationserver #N database

Sharding

Nativeproto

Page 31: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf31

The architecture #3

Applicationserver #1

Applicationserver #N

ТTARANTOOL

Some DBMS

ТTARANTOOL

Page 32: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

Mail.Ru benchmarks

Page 33: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

Synthetic benchmarks. But, with real datasets.

Page 34: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf34

Reads per second = ~20к

Read latency

Page 35: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf35

Writes per second = ~10к

Write latency

Page 36: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

Conclusion

Page 37: How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture

#nginx #nginxconf

Thank You

37

facebook.com/vasiliy.soshnikov

linkedin.com/vasiliy-soshnikov

@vasayso