building modular cloud applications in java - lessons learned

48
Building Modular Cloud Applications in Java Lessons Learned

Upload: bert-ertman

Post on 04-Jul-2015

3.327 views

Category:

Technology


1 download

DESCRIPTION

Over the past couple of years we have been building large scale Java applications and deployed them in the cloud. While dealing with typical cloud issues such as auto scaling, failover, and incremental deployments we meanwhile had to refactor them for significant functional changes. Being able to deal with change and dynamics are important reasons for companies to resort to the cloud for application development. Short time to market and rapidly changing requirements can lead to experimental software design however. Dealing with constant change in a codebase is non-trivial. In order to facilitate much change a modular codebase is of great importance. In this talk we will show you what we have learned on how to create modular Java applications and how to deploy them in the cloud using an Open Source approach without locking into one of the PaaS providers. We will discuss OSGi, scalable web application architecture, and Apache ACE for deployment and provisioning.

TRANSCRIPT

Page 1: Building Modular Cloud Applications in Java - Lessons Learned

Building Modular Cloud Applications

in Java

Lessons Learned

Page 2: Building Modular Cloud Applications in Java - Lessons Learned

Bert ErtmanFellow at Luminis in the NetherlandsJUG Leader for NLJUG and a Java Champion

Paul BakkerArchitect at Luminis Technologies

@BertErtman

@pbakker a presentation for

Page 3: Building Modular Cloud Applications in Java - Lessons Learned

The case

PulseOn

Educational system

focussed on personalized

learning

Used in high schools in

the Netherlands

Expand to other countries

in the near future

Page 4: Building Modular Cloud Applications in Java - Lessons Learned

Re: Cloud Applications

Some characteristics:

Application as a service over the internetImpact on some non-trivial non-functionals

AvailabilityScalabilityExtensibility

Page 5: Building Modular Cloud Applications in Java - Lessons Learned

Observations

Extremely agile

Architecture (and code base) should

be able to cope with change

Page 6: Building Modular Cloud Applications in Java - Lessons Learned

The case for modularity

Modularity is the

ultimate agile tool!

Small, disposable, components

Prevents code rot on the architectural level

Isolate problems, focus work

Page 7: Building Modular Cloud Applications in Java - Lessons Learned

Prevent (tight)

coupling

What we learned about OO design in university :

Promote cohesion

coupling

cohesion

Page 8: Building Modular Cloud Applications in Java - Lessons Learned

Wha

t do

we

need

?

design

consequences

High-level enterprise APIs

Architectural focus on

modularity

Runtime dynamic module

framework

Right now, OSGi is the only option

let’s not reinvent the

wheel

Page 9: Building Modular Cloud Applications in Java - Lessons Learned

OSGi is the de-facto standard module system for Java

OSGi != modularity

What about Jigsaw?

Page 10: Building Modular Cloud Applications in Java - Lessons Learned

OSGi is the de-facto standard module system for Java

OSGi != modularity

What about Jigsaw?

remember!Modularity is

an architectural principle

Page 11: Building Modular Cloud Applications in Java - Lessons Learned

OSGi is the de-facto standard module system for Java

OSGi != modularity

What about Jigsaw?

remember!Modularity is

an architectural principle

Modularity does not come for free with a

framework

Page 12: Building Modular Cloud Applications in Java - Lessons Learned

demo

Page 13: Building Modular Cloud Applications in Java - Lessons Learned

Profiles Rest

Profiles API

Profiles Service

MongoDB

Progress Rest

Progress API

Progress Service

MongoDB

Curriculum API

Curriculum Service

MongoDB

... Rest

... API

... Service

modularity

in action...

Page 14: Building Modular Cloud Applications in Java - Lessons Learned

Back to the cloud...

Page 15: Building Modular Cloud Applications in Java - Lessons Learned

HTML 5 + JavaScript

RESTful services

OSGi services

Mongo

Apache Felix

S3

Typical architectureRequirements:Modern web appUI mostly offloaded to clients or devicesDocument driven interactionIntegration via REST APIWeb scale data storeMulti-tenantElasticity

Page 16: Building Modular Cloud Applications in Java - Lessons Learned

HTML 5 + JavaScript

RESTful services

OSGi services

Mongo

Apache Felix

Amdatu

S3

Typical architecture

Let’s Add AMDATU to our stack

Architectural focus on modularityRuntime dynamic

servicesHigh level API

Page 17: Building Modular Cloud Applications in Java - Lessons Learned

AuthBlob storesMongoDBMulti-tenancyOpenSocialSearchRemote ServicesRESTTemplateWeb...

Components

Page 18: Building Modular Cloud Applications in Java - Lessons Learned

What about deployment?

Page 19: Building Modular Cloud Applications in Java - Lessons Learned

PaaS Offerings out there:

Not good:

Proprietary platformVendor lock-inWhite list / black listOS LimitationsNo support for modular runtime

Page 20: Building Modular Cloud Applications in Java - Lessons Learned

Solution: roll our own PaaS

Modular PaaS:

IaaS image

OSGi runtime

Deployment/provisioning

PaaS Building blocks

Pro:

freedom

Con:

no vendor support

Amazon EC2

Apache Felix

Apache ACE

Amdatu

Page 21: Building Modular Cloud Applications in Java - Lessons Learned

Deployment

Load

Load Balancer

PulseOn nodePulseOn node

PulseOn node

School A

MongoMongo

Mongo

Load

Load Balancer

PulseOn nodePulseOn node

PulseOn node

School B

MongoMongo

Mongo

Page 22: Building Modular Cloud Applications in Java - Lessons Learned

Availability zones

Page 23: Building Modular Cloud Applications in Java - Lessons Learned

Horizontal scaling requires stateless nodes

HTML5 clients need less server side state

Any state should go to some kind of store

Horizontal scalability

Page 24: Building Modular Cloud Applications in Java - Lessons Learned

Auto scaling

Considerable higher loads during school hours

Enoughcapacity

Without paying for idle servers

at night...

Page 25: Building Modular Cloud Applications in Java - Lessons Learned

Load Balancer small node

Cluster per school

Always use a load balancer because we don’t want downtime during scaling

Page 26: Building Modular Cloud Applications in Java - Lessons Learned

Early morning...

Load Balancer small node

Page 27: Building Modular Cloud Applications in Java - Lessons Learned

Early morning...

Load Balancer small node

large node

large node

Page 28: Building Modular Cloud Applications in Java - Lessons Learned

End of the day...

Load Balancer small node

large node

large node

Page 29: Building Modular Cloud Applications in Java - Lessons Learned

End of the day...

Load Balancer small node

Page 30: Building Modular Cloud Applications in Java - Lessons Learned

But how do we install

our software on a node?

Page 31: Building Modular Cloud Applications in Java - Lessons Learned

Some numbers

190bundles

in a deployment

120PulseOn

bundles

Page 32: Building Modular Cloud Applications in Java - Lessons Learned

Provisioning servers

Page 33: Building Modular Cloud Applications in Java - Lessons Learned
Page 34: Building Modular Cloud Applications in Java - Lessons Learned

Provisioning servers

Node

AWS Auto Scaling

1. Start Load Balancer

Apache ACE

2. register

3. register

4. provisiondeployment

package

Page 35: Building Modular Cloud Applications in Java - Lessons Learned

./as-­‐create-­‐launch-­‐config  demo            -­‐-­‐image-­‐id  ami-­‐0ee8e07a            -­‐-­‐instance-­‐type  m1.small            -­‐-­‐region  eu-­‐west-­‐1            -­‐-­‐group  sg-­‐ce1420ba            -­‐-­‐user-­‐data-­‐file  userdata.txt

./as-­‐create-­‐auto-­‐scaling-­‐group  demo          -­‐-­‐launch-­‐configuration  demo          -­‐-­‐min-­‐size  1          -­‐-­‐max-­‐size  1          -­‐-­‐availability-­‐zones  eu-­‐west-­‐1a          -­‐-­‐load-­‐balancers  demo          -­‐-­‐tag  "k=Name,v=demo,p=true"

Page 36: Building Modular Cloud Applications in Java - Lessons Learned

Or by UI configuration...

Page 37: Building Modular Cloud Applications in Java - Lessons Learned

Provisioning servers

Nodes are completely disposable

Automated cluster recovery

Nodes do not require maintenance

No “big” container

Page 38: Building Modular Cloud Applications in Java - Lessons Learned

Developer Tools

Page 39: Building Modular Cloud Applications in Java - Lessons Learned

Educational system focussed on personalized learning

Used in high schools in the Netherlands

Expand to other countries in the near future

Development tool stack

IDE with fast turn arounds

Version Control

Continuous Integration Server

Issue tracker

WIKI

what do we need?

Page 40: Building Modular Cloud Applications in Java - Lessons Learned

Continuous integration

All BndTools projects support

headless builds

Build on git push

Measure test coverage

(both unit and integration tests)

Page 41: Building Modular Cloud Applications in Java - Lessons Learned

Wrap up

Page 42: Building Modular Cloud Applications in Java - Lessons Learned

what have we learned?Modularity is the ultimate agile toolModularity is no longer difficult (BndTools / Amdatu)Stateless architecture is the only scalable wayCloud deployments made easy with a provisioning server

Page 43: Building Modular Cloud Applications in Java - Lessons Learned

Shameless self-promotion...

Our book

Building Modular Cloud

Applications in Java

Published by O’Reilly

Due: end of summer this year

under construction

Page 44: Building Modular Cloud Applications in Java - Lessons Learned
Page 45: Building Modular Cloud Applications in Java - Lessons Learned
Page 46: Building Modular Cloud Applications in Java - Lessons Learned

Want to try this yourself?

Tomorrow: 10 AM - 12.30

Hands-on Lab: Building Modular Cloud Applications in Java

Venue: Hotel Wyspiański

ul.Westerplatte 15

31-033 Kraków

Page 47: Building Modular Cloud Applications in Java - Lessons Learned

Cloud provisioning

http://ace.apache.org/

Eclipse OSGi pluginhttp://bndtools.org/

That’s ushttp://luminis.eu/

Bert [email protected]

@BertErtman

Cloud OSGi services

http://www.amdatu.org/

Amdatu

Paul [email protected]

@pbakker

Page 48: Building Modular Cloud Applications in Java - Lessons Learned

TakkGrazie

Thankyou

Obrigado

MahaloDankeDank U

Merci

Gracias