Slide 1

Slide 1 text

GILMOUR DESIGN PATTERNS IN MICRO-SERVICES ARCHITECTURES & * THIS TALK IS BUZZWORD COMPLIANT.

Slide 2

Slide 2 text

MICROSERVICES & GILMOUR?

Slide 3

Slide 3 text

ABOUT WHO AM I? ▸ Twitter: @meson10 ▸ mailto: [email protected] ▸ piyushverma.net

Slide 4

Slide 4 text

SOA (VS SERVERS) WHAT ARE SERVICES? ▸ Logical Entities. ▸ Independent. ▸ Comprised of more services. ▸ Multiple instances. ▸ Scalable. ▸ Flexible.

Slide 5

Slide 5 text

WHODUNNIT WHY ARE SERVICES? ▸ Software Problem ▸ Heterogeneity ▸ Flexibility ▸ Scalability ▸ Management Problem ▸ Authority ▸ Responsibility.

Slide 6

Slide 6 text

DESIGN PATTERNS

Slide 7

Slide 7 text

REQUEST RESPONSE Boomerang

Slide 8

Slide 8 text

REQUEST RESPONSE CALLER SERVICE HELLO? ALOHA! WRONG NUMBER SENDER_ID CODE

Slide 9

Slide 9 text

REQUEST req := g.NewRequest(“message.echo”) data := G.NewMessage().SetData("hello?") resp, err := req.Execute(data) fmt.Println("Echoclient: received", resp) g.ReplyTo(“message.echo", func(req *G.Request, resp *G.Message) { var msg string req.Data(&msg) //Parse data from incoming request. resp.SetData(“Pong") //Send response. }, opts) RECEIVER REQUEST

Slide 10

Slide 10 text

ASYNC / SIGNAL-SLOTS

Slide 11

Slide 11 text

ASYNC: SIGNALS AND SLOTS Slots Signal EVENT.POWER_UP EVENT.* EVENT.* GROUP: REVENUE FP SCALING PUSH MESSAGE SERVER ADS/ MARKETINGSERVER ANALYTICS/ LOGS BADGES/ UNLOCKS EVENT.* ADS/MARKETING GAME GILMOUR EVENT EVENT.BRIDGE_FALL FALL FROM BRIDGE FALL FROM BRIDGE FALL FROM BRIDGE GROUP: BRIDGE_FALL

Slide 12

Slide 12 text

ASYNC: SLOTS g.Slot("example.log", func(req *G.Request) { var msg string req.Data(&msg) log.Println(req.Sender(), "->", msg) }) msg := G.NewMessage().SetData(“log message emitted”) g.Signal("example.log", msg) SIGNAL RECEIVER / SLOT

Slide 13

Slide 13 text

SIGNAL-SLOT VS. REQUEST-RESPONSE

Slide 14

Slide 14 text

ASYNC VS SYNC: WHAT TO USE WHEN? REQUEST-RESPONSE ▸ Confirmed delivery. ▸ Response or Error; Guaranteed. ▸ HTTP-like. ▸ Sender responsible for Errors.

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

ASYNC VS SYNC: WHAT TO USE WHEN? SIGNAL-SLOTS ▸ Broadcasting. ▸ Wildcard topics. ▸ UDP-Like. ▸ Ok with unreliable delivery. ▸ Receiver responsible for Errors.

Slide 17

Slide 17 text

ERRORS: REQUEST - RESPONSE CALLER SERVICE HELLO? WRONG NUMBER SENDER_ID CODE ERROR REPORTER HYSTRIX PAGER DUTY HONEY BADGER EMAIL ALERTS

Slide 18

Slide 18 text

ERRORS: SIGNAL - SLOTS WEB GILMOUR EMAIL NOTIFIER SMS NOTIFIER PUSH MESSAGE Slots Signal PAGER DUTY HONEY BADGER EMAIL ALERTS ERROR REPORTER GILMOUR.ERROR

Slide 19

Slide 19 text

DISCOVERY & LOAD-BALANCING

Slide 20

Slide 20 text

LOAD BALANCING - TYPICAL NOTIFICATION SERVER 1 REPLICATED LOAD BALANCER X.Y.Y.Z? CALLER SERVICE REGISTER I, AM HEALTHY? NOTIFICATION SERVER 2 NOTIFICATION SERVER 3

Slide 21

Slide 21 text

LOAD BALANCING : GILMOUR NOTIFICATION SERVER 2 GILMOUR MANAGER.NOTIFICATION NOTIFICATION SERVER 1 NOTIFICATION SERVER 3 MANAGER.NOTIFICATION MANAGER.NOTIFICATION CALLER SERVICE MANAGER.NOTIFICATION {“NOTIFICATION”: “DATA”}

Slide 22

Slide 22 text

DISCOVERY AND LOAD BALANCING LOOK MA, NO SERVICE DISCOVERY ▸ Gilmour works on Subscriber Publisher. ▸ No querying discovery process. ▸ Call service and not servers.

Slide 23

Slide 23 text

DISCOVERY AND LOAD BALANCING LOOK MA, NO LOAD BALANCING ▸ Has Capacity, Will Serve. ▸ Message delivered to one and all. ▸ Fittest node acquires lock first.

Slide 24

Slide 24 text

ERRORS: DETECTION & HANDLING

Slide 25

Slide 25 text

GILMOUR ERRORS ERROR DETECTION ▸ Timeout: ▸ Server-side - Execution expired. ▸ Client-side - Response too late. ▸ Confirm Subscribers or 404. ▸ Distinguished network failures.

Slide 26

Slide 26 text

GILMOUR ERRORS ERROR HANDLING ▸ Ignore ▸ Publish ▸ Queue func main() { redis := backends.MakeRedis("127.0.0.1:6379", "pass") g := G.Get(redis) //g.SetErrorPolicy(protocol.ErrorPolicyQueue) //g.SetErrorPolicy(protocol.ErrorPolicyIgnore) g.SetErrorPolicy(protocol.ErrorPolicyPublish) }

Slide 27

Slide 27 text

ERRORS: type GilmourError interface { Marshal() ([]byte, error) GetTopic() string GetSender() string GetCode() int GetTimestamp() string GetRequestData() string GetUserData() string GetBacktrace() interface{} } type gError struct { topic string //topic to which the request was sent requestData string //request payload userData string //implementation dependent information sender string //sender from the request timestamp string //timestamp of error backtrace interface{} //backtrace of the error code int //response code (non-200) } ERROR IMPLEMENTATION

Slide 28

Slide 28 text

GILMOUR ERRORS ERROR SAMPLE

Slide 29

Slide 29 text

OPS: MONITORING

Slide 30

Slide 30 text

OPS: MONITORING SERVERS ▸ Logging ▸ Error Reporting ▸ Health

Slide 31

Slide 31 text

OPS: MONITORING SERVICES ▸ Are the services servicing? ▸ Do services have spare capacity? ▸ Do services respond in time? ▸ Health Bulletin: github.com/gilmour-libs/health-bulletin

Slide 32

Slide 32 text

OPS: MONITORING

Slide 33

Slide 33 text

OPS: MONITORING

Slide 34

Slide 34 text

OPS: MONITORING Feb 23 12:25:14 qa-next-backend-manager0.datascale.io gilmour_health: D, [2016-02-23T06:55:12.930435 #22111] DEBUG -- : Ensuring topics have at least one subscriber Feb 23 12:25:14 qa-next-backend-manager0.datascale.io gilmour_health: D, [2016-02-23T06:55:12.931160 #22111] DEBUG -- : Ensuring that gilmour servers respond to health ping Feb 23 12:26:14 qa-next-backend-manager0.datascale.io backend_manager: D, [2016-02-23T06:56:12.932775 #9605] DEBUG -- : Executing handler for gilmour.health.ip-10-0-0-146-pid-9605-uuid-9d0484dd-08e5-4ec3- a3e4-9a109634712b from 2881867d41f24228b462b9eff0b7e88e 2016-04-03 00:06:56 d0e4ea929645600e2fa97657091613a4 -> Cleared VPC jenkins-backend-manager-pipeline-qa-17 2016-04-03 00:06:56 d0e4ea929645600e2fa97657091613a4 -> Clearing databag customer_jenkins-backend-manager- pipeline-qa-17_config::vpc_config 2016-04-03 00:06:57 d0e4ea929645600e2fa97657091613a4 -> Deleted data_bag[customer_jenkins-backend-manager- pipeline-qa-17_config] 2016-04-03 00:06:57 d0e4ea929645600e2fa97657091613a4 -> Clearing DNS entries 2016-04-03 00:07:00 d0e4ea929645600e2fa97657091613a4 -> Cleaning Chef environment 2016-04-03 00:07:01 d0e4ea929645600e2fa97657091613a4 -> Deleted customer_jenkins-backend-manager-pipeline- qa-17 REQUEST LOGGING

Slide 35

Slide 35 text


 COMPOSITIONS

Slide 36

Slide 36 text

COMPOSITION ▸ compose - service1 | service2 | composition3 ▸ andand - service1 && service2 && composition3 ▸ oror - service1 || composition2 || service3 ▸ batch ▸ (service1; service2; service3) > out ▸ service1; composition2; service3 > out ▸ parallel ▸ lambda functions

Slide 37

Slide 37 text

COMPOSITION popular := g.NewParallel( g.NewRequestComposition("example.popular3"), g.NewRequestComposition("example.popular4"), ) batch := g.NewPipe( g.NewRequestComposition("example.fetch"), g.NewRequestComposition("example.words"), g.NewRequestComposition("example.count"), popular, ) data := G.NewMessage() data.SetData("https://s3.amazonaws.com/ds-data-sample/test.txt") msg := <-batch.Execute(data)

Slide 38

Slide 38 text

COMPOSITION popular := g.NewParallel( g.NewRequestComposition("example.popular3"), g.NewRequestComposition(“example.popular4"), g.NewRequestComposition("example.popular5"), ) batch := g.NewPipe( g.NewRequestComposition("example.fetch"), g.NewRequestComposition("example.words"), g.NewRequestComposition("example.stopfilter"), g.NewRequestComposition("example.count"), popular, &MyComposer{}, ) 
 data := G.NewMessage() data.SetData("https://s3.amazonaws.com/ds-data-sample/test.txt") msg := <-batch.Execute(data)

Slide 39

Slide 39 text

COMPOSITION batch := e.NewPipe( e.NewRequest("weather.fetch"), e.NewRequest("weather.group"), e.NewParallel( e.NewPipe( e.NewLambda(monthLambda("jan")), e.NewParallel( e.NewRequest("weather.min"), e.NewRequest("weather.max"), ), ), e.NewPipe( e.NewLambda(monthLambda("feb")), e.NewParallel( e.NewRequest("weather.min"), e.NewRequest("weather.max"), ), ), ), )

Slide 40

Slide 40 text

DEMO Please contact to advertise here.

Slide 41

Slide 41 text

SAMPLE TEXT

Slide 42

Slide 42 text

EXAMPLES: POPULAR WORD COUNT ▸ Given ▸ A S3 URL pointing to a file that has (lot of) random text. ▸ Goal ▸ Eliminate stop words from the file. ▸ Find most popular 3, 4, and 5 letter words. ▸ Find these in parallel.

Slide 43

Slide 43 text

EXAMPLES: WEATHER AGGREGATION ▸ Output ▸ Popular 3 letter words: [way, for] ▸ Popular 4 letter words: [Text, copy] ▸ Popular 5 letter words: [Blind, blind]

Slide 44

Slide 44 text

EXAMPLES: COMPOSITION

Slide 45

Slide 45 text

GILMOUR RECAP ▸ No Load Balancer ▸ No Service Discovery ▸ Signal, Slots. ▸ Broadcast using Wildcard Topics. ▸ Exclusion groups. ▸ Sync - Request, Reply ▸ Error and Health Monitoring - HealthBulletin. ▸ Failure Detection ▸ Composition - Real micro-services. ▸ No message persistence.

Slide 46

Slide 46 text

GILMOUR CREDITS & LINKS ▸ Aditya Godbole ▸ Amit Sethi ▸ Mohan Dutt ▸ Poorva Mahajan ▸ Datascale.IO datascale.io ▸ Repository github.com/gilmour-libs