“Purikura” culturein Japan andour web application architecture

Post on 05-Apr-2017

134 views 0 download

transcript

Koichi SakataFURYU CORPORATION /

KanJava JUG

“Purikura” culture in Japan and

our web application architecture

#DevoxxUS @jyukutyo#purijp

Where is Japan?

Talk about• Japanese culture– “Purikura”• Products that I’m using– MogileFS– Spring Cloud Contract Stub Runner

Japan of today• Ninja• Samurai• Anime/Manga• Purikura

“Purikura”

Photo sticker machine

• printed sticker• digital images

10 years6000 machines in JP$60 million / year

Japanese culture

Overview ofour system

MogileFS• Distributed filesystem• Open source product• has three components

RDBMS

tracker

storage node

MogileFS

15 storage nodes10 billion files480 TB6 years

MogileFS advantages• No single point of failure

– run on multiple machines• Automatic file replication– replicate between different storage nodes

– 3 replicas

Problem• disk usage unbalancing– execute rebalancing command

Sample case

Originally...

Server1 Server2

80 80

Usage(%)

Add a server

Server1 Server2 Server3

80 80

0

Usage(%)

same disk space as

Server 1,2

Increasing

Server1 Server2 Server3

85 85

40

Usage(%)

Rebalancing

Server1 Server2 Server3

75 7540

10 10

20

Another problems• Not support Perl 6.• Last commit is in Dec 2014.

Clouds?• in the process of reviewing– AWS S3• need to transfer 10 billion files...

MogileFS• capable of managing tera byte data• not active now

Our applicationarchitecture

Monolithic...• build time is long• difficult to change code• run tests again

Microservice

• eureka– Service Discovery• ribbon– Client Side Load Balancing• Hystrix– Circuit Breaker

Spring• Spring Boot

• Spring Cloud Netflix

Problem

End to end test• How to test the case?– the case that an exception happens in the microservice

throw an exception and return

500 HTTP status code

Spring Cloud Contract Stub

Runner

Spring Cloud Contract Stub Runner

• replaces microservices with stubs

• Stubs are run on WireMock• https://

github.com/spring-cloud/spring-cloud-contract/tree/master/spring-cloud-contract-stub-runner

• http://wiremock.org/

Stubbing

How to make and run stubs

• Add maven plugin.• Write stub behavior in Groovy • Deploy stub to a repository• Run a Stub Runner with stubs

Maven plugin

<plugin>

<groupId>org.springframework.cloud</groupId>

<artifactId>

spring-cloud-contract-maven-plugin </artifactId>

<version>${spring-cloud-contract.version}</version>

<extensions>true</extensions>

<configuration>

<!-- By default it would search under src/test/resources/ -->

<contractsDirectory>${project.basedir}</contractsDirectory>

</configuration>

</plugin>

Groovy DSL

org.springframework.cloud.contract.spec.Contract.make {

    request {

        method 'POST'

        url '/example'

        body([ "id": 12345 ])     }

    response {

        status 201

        body([ “name”: “john” ])

        headers {

            contentType('application/json;charset=UTF-8’)

        }

    }

}

Maven Deploy

$ mvn deploy/install[INFO] Installing ... stubs.jar

Run stub runner

$ cd to/stubrunner$ java -jar -Dstubrunner.ids=[groupId]:[artifactId] -Dstubrunner.idsToServiceIds. [artifactId]=something stubrunner.jar

Stub runner downloads stubs from repository

Stub port?

http://localhost:9001/

stubs

stub app port

$ cd to/stubrunner$ java -jar -Dstubrunner.ids=[groupId]:[artifactId]-Dstubrunner.idsToServiceIds.

[artifactId]=something stubrunner.jarused to register

in eureka

Summary• MogileFS is capable of managing tera byte data.• Spring Cloud Contract Stub Runner is useful.• Purikura is Japanese culture.

Thank youagain

for coming.#DevoxxUS @jyukutyo#purijp

Thank youfor coming