Slide 1

Slide 1 text

Cookpad and Microservices Why and how we move to Microservices architecture style

Slide 2

Slide 2 text

Taiki Ono • @taiki45 • Joined Cookpad at 2014/3 • Dev-Infra group • Working with service integration related things and Web API

Slide 3

Slide 3 text

Sponsored by

Slide 4

Slide 4 text

Hi, we are Cookpad

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

over 50M users/month over 1.8M recipes

Slide 7

Slide 7 text

Not only recipe site…

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

You can see more products!

Slide 12

Slide 12 text

To make everyday cooking fun.

Slide 13

Slide 13 text

Why Microservices?

Slide 14

Slide 14 text

• Environment changes • Limit of Monolithic

Slide 15

Slide 15 text

• Environment changes • Limit of Monolithic

Slide 16

Slide 16 text

Our business changes

Slide 17

Slide 17 text

User agent changes

Slide 18

Slide 18 text

• Environment changes • Limit of Monolithic

Slide 19

Slide 19 text

A huge Rails app +----------------------+-------+-------+---------+---------+-----+-------+ | Name | Lines | LOC | Classes | Methods | M/C | LOC/M | +----------------------+-------+-------+---------+---------+-----+-------+ | Controllers | 46173 | 37194 | 493 | 3754 | 7 | 7 | | Helpers | 14251 | 11687 | 13 | 1367 | 105 | 6 | | Models | 10153 | 7799 | 319 | 1152 | 3 | 4 | | Mailers | 402 | 326 | 16 | 35 | 2 | 7 | | Javascripts | 40217 | 34405 | 36 | 4940 | 137 | 4 | | Libraries | 2341 | 1833 | 112 | 252 | 2 | 5 | | Async_view specs | 247 | 212 | 0 | 0 | 0 | 0 | | Controller specs | 58856 | 48671 | 7 | 121 | 17 | 400 | | Feature specs | 40886 | 33590 | 0 | 196 | 0 | 169 | | Helper specs | 4151 | 3396 | 1 | 10 | 10 | 337 | | Lib specs | 22537 | 18817 | 27 | 128 | 4 | 145 | | Mailer specs | 421 | 346 | 0 | 0 | 0 | 0 | | Model specs | 71128 | 58668 | 4 | 70 | 17 | 836 | | Policy specs | 1487 | 1219 | 0 | 0 | 0 | 0 | | Request specs | 34595 | 29677 | 0 | 12 | 0 | 2471 | | Routing specs | 661 | 533 | 0 | 0 | 0 | 0 | | View specs | 619 | 508 | 0 | 2 | 0 | 252 | | Worker specs | 862 | 715 | 0 | 1 | 0 | 713 | +----------------------+-------+-------+---------+---------+-----+-------+ | Total | 349987 | 289596 | 1028 | 12040 | 11 | 22 | +----------------------+-------+-------+---------+---------+-----+-------+

Slide 20

Slide 20 text

Slow test issue

Slide 21

Slide 21 text

RRRSpec solved

Slide 22

Slide 22 text

Slow deployment

Slide 23

Slide 23 text

mamiya solved

Slide 24

Slide 24 text

and some difficulties like scaling, upgrading Rails, etc…

Slide 25

Slide 25 text

We can’t control our own application.

Slide 26

Slide 26 text

We've found Microservices while we were challenging these issues.

Slide 27

Slide 27 text

Microservices

Slide 28

Slide 28 text

–James Lewis & Martin Fowler “an approach to developing a single application as a suite of small services” IUUQNBSUJOGPXMFSDPNBSUJDMFTNJDSPTFSWJDFTIUNM

Slide 29

Slide 29 text

Build around business capabilities

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Own process and lightweight messaging

Slide 32

Slide 32 text

HTTP JSON REST

Slide 33

Slide 33 text

Decentralization and polyglot

Slide 34

Slide 34 text

Ruby + MySQL Go + Redshift Java + MySQL

Slide 35

Slide 35 text

Characteristics of Microservices • Build around business capabilities • Own process and lightweight messaging • Decentralization and polyglot

Slide 36

Slide 36 text

We can handle our own application, by paying cost of complexity as a whole.

Slide 37

Slide 37 text

In Cookpad What we did?

Slide 38

Slide 38 text

Published service data

Slide 39

Slide 39 text

Garage Garage Garage Rails app

Slide 40

Slide 40 text

Garage and garage-client • RESTful hyper-media API • JSON message enveloped in HTTP • Implemented as a Rails extension • Standardized communication pattern

Slide 41

Slide 41 text

Solutions for product common problems

Slide 42

Slide 42 text

º

Slide 43

Slide 43 text

̋

Slide 44

Slide 44 text

Backend products • Auth server (OAuth2.0) • Personal information server • Notification base • Video backend

Slide 45

Slide 45 text

Data synchronization between products

Slide 46

Slide 46 text

Pub-Sub Topic

Slide 47

Slide 47 text

Pub-Sub Topic

Slide 48

Slide 48 text

Ping • Pub-Sub pattern • Implemented as a Rails extension • A thin wrapper of Amazon SNS and fluentd • Receive events via webhook

Slide 49

Slide 49 text

What we did are… • Published product data with Garage • Built some backend products • Built Ping for data synchronization

Slide 50

Slide 50 text

We are challenging more problems around Microservices

Slide 51

Slide 51 text

Join us!! http://recruit.cookpad.com/