iot and microservice

34
1 Pivotal Confidential–Internal Use Only 1 Pivotal Confidential–Internal Use Only Cloud Native Application, Microservices and Realtime Streaming Demo Pivotal Cloud Foundry Pivotal Big Data Suite Kapil Shukla

Upload: kgshukla

Post on 13-Apr-2017

766 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: IoT and Microservice

1Pivotal Confidential–Internal Use Only 1Pivotal Confidential–Internal Use Only

Cloud Native Application, Microservices and Realtime Streaming Demo

Pivotal Cloud FoundryPivotal Big Data Suite

Kapil Shukla

Page 2: IoT and Microservice

2Pivotal Confidential–Internal Use Only

Agenda Problem Statement Architecture Problem Solution Demo

Page 3: IoT and Microservice

3Pivotal Confidential–Internal Use Only

Problem StatementData Model1. Taxi data streamed for New York region2. Data contains details like taxi number,

pickup time, dropoff time, pickup and dropoff lat/long, fare, taxes

1. Area to be divided as squares. Each square is 1kmx1km

Find out EVERY 10 SECONDSa. Inconsistent datab. Top 10 areas where taxies are plying the

most (Report starting and ending area and number of taxies that traveled in these areas)

c. Total data processed d. Free taxies available in different areas (only

50 taxies)

Analytical Queriese. Which taxi driver is not reporting data

correctlyf. Top 10 taxi driver earning the most

Page 4: IoT and Microservice

4Pivotal Confidential–Internal Use Only

Page 5: IoT and Microservice

5Pivotal Confidential–Internal Use Only

SpringXD(Fast Ingestion)

Real Time Analytics Demo - Flow

Spark Streaming(In Memory analytics)

Gemfire(In memory data store)

Filter

Business logic(filter, transformation)

10s moving window

Monolithic App

Data is streamed to network port where springXD is listening

Data stream is forwarded to SPARK streaming which collects data for every 10seconds and process the data

After processing, various aggregated metrics are uploaded to Gemfire

A php webapp then shows the data and refreshes the data every 10 seconds.

Pivotal HD (long term storage)

Terminal Output

NP

PCF

Page 6: IoT and Microservice

6Pivotal Confidential–Internal Use Only

Real Time Analytics Demo – Tools used

SpringXD Data Ingestion

Spark Streaming In-memory stream computing

Gemfire In- memory data store

HAWQ Analytic SQL queries on Hadoop

Spring Boot Microservices

Gcharts PHP based web application

Pivotal Cloud Foundry Application Runtime Platform

Page 8: IoT and Microservice

8Pivotal Confidential–Internal Use Only

Challenges with Monolithic App?

1. INEFFICIENT SCALING

2. ERROR HANDLING

4. CONFIGURATION MANAGEMENT

5. APPLICATION UPGRADE

6. AGGREGATION

3. TIGHTLY COUPLED

Page 9: IoT and Microservice

9Pivotal Confidential–Internal Use Only

Monolithic App

SpringXD(Fast Ingestion)

Real Time Analytics Demo - Flow

Spark Streaming(In Memory analytics)

Gemfire(In memory data store)

Filter

Business logic(filter, transformation)

10s moving window

Microservices Oriented Webapp

We will change this monolithic application to microservices.

Pivotal HD (long term storage)

Terminal Output

NP

PCF

Page 10: IoT and Microservice

10Pivotal Confidential–Internal Use Only

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

Let’s build the architectureARCHITECTURE

We need these components for microservices management,

Circuit breaker, Service Registry and Configuration server

Page 11: IoT and Microservice

11Pivotal Confidential–Internal Use Only

Spring Cloud Services Suite

Spring Cloud Services

Config Server Service Registry Circuit Breaker Dashboard

Page 12: IoT and Microservice

12Pivotal Confidential–Internal Use Only

Spring Cloud Config Server

Config Server

• Spring Cloud Config Server• Service Binding via Spring Cloud

Connector• Git URL for Config Repo provided via

Service Dashboard (post-provisioning)

Use Case: Move app from one environment to other without change

Page 13: IoT and Microservice

13Pivotal Confidential–Internal Use Only

Spring Cloud Service Registry

Service Registry

• Service Registration and Discovery via Netflix OSS Eureka

• Service Binding via Spring Cloud Connector

• Single-tenant, scoped to CF space

• Registration via CF Route

Use Case: Register/Discover a microservice to/at a central place

Page 14: IoT and Microservice

14Pivotal Confidential–Internal Use Only

Spring Cloud Circuit Breaker

Circuit BreakerDashboard

• Netflix OSS Turbine + Hystrix Dashboard

• Handle expected failures gracefully• Aggregation via AMQP (RabbitMQ)• Binding via Spring Cloud Connector• Single-tenant, scoped to CF space

Use Case: Handle Microservice failure gracefully

Page 15: IoT and Microservice

15Pivotal Confidential–Internal Use Only

TaxiService (SB)

Events Service (SB)

Analytics Service (SB)

Aggregator Service (SB)

/routes/top10routes/freetaxies/list

/events/total/events/missed/events/quality

/top10routes/freetaxies/totalevents/missedevents/quality/top10incorrectdrivers/top10earningdrivers

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

/analytics/top10incorrectdrivers/analytics/top10earningdrivers

ARCHITECTURE

TAXISERVICE – http://ts.abc.comEVENTSERVICE – https://es.abc.comANALYTICSERVICE – https://as.abc.com

Page 16: IoT and Microservice

16Pivotal Confidential–Internal Use Only

TaxiService (SB)

Events Service (SB)

Analytics Service (SB)

Aggregator Service (SB)

/routes/top10routes/freetaxies/list

/events/total/events/missed/events/quality

/top10routes/freetaxies/totalevents/missedevents/quality/top10incorrectdrivers/top10earningdrivers

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

/analytics/top10incorrectdrivers/analytics/top10earningdrivers

ARCHITECTURE

TAXISERVICE – http://ts.abc.comEVENTSERVICE – https://es.abc.comANALYTICSERVICE – https://as.abc.com

2. http://TAXISERVICE/route/top10routes

3. http://ts.abc.com/route/top10routes

1. http://aggservice.abc.com/top10routes

How a request to a route works out

Page 17: IoT and Microservice

17Pivotal Confidential–Internal Use Only

GEMFIRE PHD/HAWQ

Web application (PHP) M O N O L I T H I C

M I C R O S E R V I C E S

Page 18: IoT and Microservice

18Pivotal Confidential–Internal Use Only

Events Service

Analytics Service

Aggregator Service

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

1. SCALING

Analytics ServiceAnalytics Service

Taxi Service

Taxi Service

Taxi Service

Scale microservices independently based on load/usage

Page 19: IoT and Microservice

19Pivotal Confidential–Internal Use Only

Taxi Service Events Service

Analytics Service

Aggregator Service

/top10routes/freetaxies/totalevents/missedevents/quality/top10incorrectdrivers/top10earningdrivers

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

2. GRACEFUL ERROR HANDLINGIf any microservice fails, then

circuit breaker kicks in and runs your default code on failure.

Graceful error handling

Page 20: IoT and Microservice

20Pivotal Confidential–Internal Use Only

3. LOOSELY COUPLED

Taxi Service (SB)

Events Service (SB)

Analytics Service (SB)

Aggregator Service (SB)

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

TAXISERVICE – http://ts.abc.comEVENTSERVICE – https://es.abc.com…

2. http://TAXISERVICE/route/top10routes

3. http://ts.abc.com/route/top10routes

1. http://aggservice.abc.com/top10routes

Agg Service does not have to know where taxi service is

running. It asks service registry for microservice named

“TAXISERVICE” and service registry returns the URL

Page 21: IoT and Microservice

21Pivotal Confidential–Internal Use Only

Taxi Service

Events Service

Analytics Service

Aggregator Service

Web application (PHP)

SERVICE REGISTRY

PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

4. CONFIGURATION MANAGEMENT

GEMFIRE TESTPROFILE = TEST

Externalize configuration parameters, put them together

under different profiles. For example here, profile “test” let’s all microservices to connect to a

test gemfire server

Page 22: IoT and Microservice

22Pivotal Confidential–Internal Use Only

Taxi Service

Events Service

Analytics Service

Aggregator Service

Web application (PHP)

SERVICE REGISTRY

PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

4. CONFIGURATION MANAGEMENT

GEMFIRE PRODPROFILE=PROD

When profile is PROD, the same application gets

pushed into prod environment with PROD

profile.

Page 23: IoT and Microservice

23Pivotal Confidential–Internal Use Only

Taxi Service

Events Service

Analytics Service

Aggregator Service

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

5. VERSION UPGRADE

Page 24: IoT and Microservice

24Pivotal Confidential–Internal Use Only

Aggregator Service

Taxi Service (v1)

Web application (PHP)

SERVICE REGISTRY

GEMFIRE

CONFIG SERVER

CIRCUIT BREAKER

5. VERSION UPGRADE

TAXISERVICE-v1 – http://ts.abc.com

Taxi Service (v2)

TAXISERVICE-v1 – http://ts.abc.comTAXISERVICE-v2 - http://tsv2.abc.com

http://TAXISERVICE-v1/route/top10routes

TaxiService version 2 could be deployed in prod. Both v1 and v2 could coexist. It is up to aggregator service which

one it uses. Right now aggregator service refers to

v1

Page 25: IoT and Microservice

25Pivotal Confidential–Internal Use Only

Aggregator Service (v2)

Taxi Service (v1)

Web application (PHP)

SERVICE REGISTRY

GEMFIRE

CONFIG SERVER

CIRCUIT BREAKER

5. VERSION UPGRADE

TAXISERVICE-v1 – http://ts.abc.com

Taxi Service (v2)

TAXISERVICE-v1 – http://ts.abc.comTAXISERVICE-v2 - http://tsv2.abc.com

http://TAXISERVICE-v2/route/top10routes

When aggregator service is upgraded, v2 version starts referring to taxi service v2. You could now delete taxi

service v1.

Page 26: IoT and Microservice

26Pivotal Confidential–Internal Use Only

Taxi Service

Events Service

Analytics Service

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

6. AGGREGATION

If you don’t have agg service, your web app needs to make three calls to three diff service. Causes battery

drain on mobiles/ipads

Page 27: IoT and Microservice

27Pivotal Confidential–Internal Use Only

Taxi Service

Events Service

Analytics Service

Aggregator Service

Web application (PHP)

SERVICE REGISTRY

GEMFIRE PHD/HAWQ

CONFIG SERVER

CIRCUIT BREAKER

6. AGGREGATIONOne call to agg service which calls all other microservices,

prepares relevant data and sends back to webapp

Page 28: IoT and Microservice

28Pivotal Confidential–Internal Use Only

Boon for DevelopersDeploying an applica-tion

Page 29: IoT and Microservice

29Pivotal Confidential–Internal Use Only

Just push your apps

Page 30: IoT and Microservice

30Pivotal Confidential–Internal Use Only

Saviour for OperatorsScaling an application

Page 31: IoT and Microservice

31Pivotal Confidential–Internal Use Only

PCF alleviates many operational concernsIn-built functionalities

In-built app scaling

In-built self healing

Logging aggregation & audit trail

Strong IT and user governance

App lifecycle mgmt (perf, upgrade)

Page 32: IoT and Microservice

32Pivotal Confidential–Internal Use Only

Container Scheduling

Application Framework

ServicesPlatform Runtime

Routing DatabaseConfigurationService Discovery

Big Data

Object Storage

Mobile

Build CI

User ProvidedLogging & Metrics Messaging

Circuit Breakers

12 Factor Apps

RESTful Services

Microservices

.NETSpring Boot Node.jsRuby on Rails

Operations

Zero Downtime

Deployments

Failover & Recovery Scaling Security

PatchingPlatformUpgrades

Infrastructure

OpenStack AmazonVMware

Page 33: IoT and Microservice

33Pivotal Confidential–Internal Use Only

Pivotal Big Data Suite Is a Complete Tool Set for Data-Driven Enterprises

Page 34: IoT and Microservice

A NEW PLATFORM FOR A NEW ERA