lessons learned from a large scale osgii web app - p bakker & j de vreede

45
Lessons learned from a large scale OSGi web app Jago de Vreede Paul Bakker

Upload: mfrancis

Post on 11-May-2015

931 views

Category:

Technology


1 download

DESCRIPTION

Building a large scale, cloud hosted, multi device product that changes the way students are taught in high schools, turns out to be not entirely trivial. We have been building PulseOn for the last two years. We faced many technical challenges, and have tried many different technologies. Some ideas turned out to be extremely helpful, some other ideas that looked promising turned out to be bad practices. In this talk we will discuss what we have learned about building modular, scalable web applications. We will go into different areas of the technology stack, from storage and (nosql) databases to a modular RESTful backend and a multi device HTML5 based frontend. We will also go into the cloud, and discuss topics such as auto scaling and failover. We will discuss what works and what doesn’t, and hopefully help other to make the right decisions. Some topics that we will touch upon: - Modular architecture with OSGi - Failing at linked data and semantic databases - Using MongoDB from OSGi - Release process and semantic versioning - Continuous deployment - JavaScript frameworks Bios: Paul Bakker Paul is a software architect for Luminis Technologies and the author of “Building Modular Cloud Apps With OSGi”. He believes that modularity and the cloud are the two main challenges we have to deal with to bring technology to the next level, and is working on making this possible for mainstream software development. Today he is working on educational software focussed on personalised learning for high school students in the Netherlands. Paul is an active contributor on open source projects such as Amdatu, Apache ACE and BndTools. He has a background as a trainer on Java related technology and is a regular speaker on conferences such as JavaOne, Devoxx and JFokus. Jago de Vreede Jago is a software engineer at Luminis Technologies, as a software engineer he has seen a broad-spectrum of projects and he has been working on a large OSGi project for the last year. His work is not exclusive to java development but also does front-end development, and the integration between these. Performance tuning and optimizations are also part of his work.

TRANSCRIPT

Page 1: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Lessons learned from a large scale OSGi web app

Jago de Vreede Paul Bakker

Page 2: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Paul Bakker@pbakker

Page 3: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Jago de Vreede

Page 4: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Agenda !

High level architecture Modular architecture Modularity with OSGi Cloud deployments with Apache ACE Frontend frameworks

Page 5: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Ask whenever you want!

Page 6: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

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 7: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Cloud provisioning

http://ace.apache.org/

bndtools Eclipse OSGi plugin http://bndtools.org/

Eclipse http://eclipse.org/ Source control

Tools

Stash, Jira, Bamboo http://atlassian.com/

WebStorm http://jetbrains.com/

webstorm/

Page 8: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

HTML 5 + JavaScript

RESTful services

OSGi services

Mongo

Apache Felix

S3

High level architectureRequirements:

!Agile and modular Modern web app UI mostly offloaded to clients or devices Integration via REST API Horizontally scalable

A m d a t u

Page 9: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Auth Blob stores MongoDB Multi-tenancy OpenSocial Search Remote Services REST Template Web ...

Components

Page 10: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Load

Load Balancer

PulseOn PulseOn

PulseOn

School B

MongoMongo

Mongo

Deployment

Load

Load Balancer

PulseOn PulseOn

PulseOn

School A

MongoMongo

Mongo

Load

Load Balancer

DAMSDAMS

DAMS

Content backend

MongoMongo

Mongo

Page 11: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Profiles Rest

Profiles API

Profiles Service

MongoDB

Progress Rest

Progress API

Progress Service

MongoDB

Curriculum API

Curriculum Service

MongoDB

... Rest

... API

... Service

services

all the way down

Page 12: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

A service should only

do one single thing

Page 13: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Services are the (reusable) building

blocks of our application

Page 14: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Benefits of a services based architecture

!

Small services are easy to maintain Small services are composable Services are easily testable

Page 15: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Packaging services Services are packaged in small bundles Related bundles may be generated from a single Bndtools project

Page 16: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Data Storage

Page 17: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Semantic data store (triple store)

MySQL (with JPA)

MongoDB

NowBeginning

Page 18: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Relational databasesin a modular system

A part of data should be owned by 1 service

How to set boundaries in a relational world!?

Page 19: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Relational databasesin the modern web

!

ORM is REALLY difficult to get right Relational databases don’t scale well

Page 20: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

MongoDB: our database of choice

!

Object Mapping trivial Easy to scale Powerful aggregation/map-reduce framework

Page 21: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Code example: MongoDB with Amdatu

Amdatu Mongo Service

Setup Object Mapper

Execute query

Page 22: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Release & Deployment

Page 23: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Binaries

Release to release repo

Release to

release OBR

Page 24: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

JavaScript minification

closure compiler

deterministic? => fixed March 3, 2014

Baseline OBR Release OBR

CI Build Server

Page 25: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Deployment

Software distribution framework

Manages the installation and upgrade

of bundles, configuration, etc. to

heterogenous targets

Page 26: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Load

Load Balancer

PulseOn PulseOn

PulseOn

School B

MongoMongo

Mongo

Deployment

Load

Load Balancer

PulseOn PulseOn

PulseOn

School A

MongoMongo

Mongo

Load

Load Balancer

DAMSDAMS

DAMS

Content backend

MongoMongo

Mongo

Page 27: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Deployment

Load

Load Balancer

PulseOn PulseOn

PulseOn

School

Load

Load Balancer

DAMSDAMS

DAMS

Content backend

Page 28: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Deployment

Load

Load Balancer

TargetTarget

Target

School

Load

Load Balancer

TargetTarget

Target

Content backend

Release OBR

Apache ACE

Baseline OBR

CI Build Server

Page 30: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede
Page 31: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Unit testing OSGi codeis trivial

But what if we wantmore?

Page 32: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Integration testing turnsout to be trivial as well!

Automated dependency injection of

service

Setup Config Admin

Junit style asserts

Page 33: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Frontend frameworks

Page 34: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

jQuery Pros

Can do a lot with not much code

Lot of helpful

plugins

available

Easy to get started

Page 35: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

jQuery

Hard to maintain

Cons

Hard to test

Page 36: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Backbone.js Pros

Designed towards

consuming REST data

Well structured

Page 37: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Backbone.js Cons

Hard to maintain

A LOT OF CODE!!

Testable

Page 38: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

AngularJS

Page 39: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

AngularJS Pros

Designed towards

consuming REST data

Well structured

No guessing in htmlTestable

Page 40: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

TypeScript Pros

Well structured

Code completion

compile time checks

Page 41: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

TypeScript Cons

Well structured

Slow-ish

Need to have a

definition to work

Page 42: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

!

A modular architecture gives us:!

Maintainability

Extensibility

Freedom to change

Wrap up

Page 43: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

But what if I want

Spring

EJB

Hibernate?

Just don’t… You really don’t need to.

Page 44: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Cloud provisioning

http://ace.apache.org/

Eclipse OSGi plugin http://bndtools.org/

That’s us http://luminis-technologies.com

Cloud OSGi services

http://www.amdatu.org/

Amdatu

Paul Bakker [email protected]

@pbakker

Jago de Vreede [email protected]

Page 45: Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede

Learn more? !

Friday 10.20 - 12.50 or 14.45 - 17.15 !

Tutorial “Developing modular cloud applications with OSGi”