Top Banner
Lessons learned from a large scale Java web app Paul Bakker
44
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lessons learned from a large scale OSGi web app

Lessons learned from a large scale Java web app

Paul Bakker

Page 2: Lessons learned from a large scale OSGi web app

Paul Bakker@pbakker

Page 3: Lessons learned from a large scale OSGi web app

Agenda

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

Page 4: Lessons learned from a large scale OSGi web app

Ask whenever you want!

Page 5: Lessons learned from a large scale OSGi web app

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 6: Lessons learned from a large scale OSGi web app

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

Amdatu

Page 7: Lessons learned from a large scale OSGi web app

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

Components

Page 8: Lessons learned from a large scale OSGi web app

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 9: Lessons learned from a large scale OSGi web app

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 10: Lessons learned from a large scale OSGi web app

A service should only

do one single thing

Page 11: Lessons learned from a large scale OSGi web app

Services are the (reusable) building

blocks of our application

Page 12: Lessons learned from a large scale OSGi web app

Benefits of a services based architecture

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

Page 13: Lessons learned from a large scale OSGi web app

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

Page 14: Lessons learned from a large scale OSGi web app

OSGi Services

vs

Micro Services

http://paulonjava.blogspot.nl/2014/04/micro-services-vs-osgi-services.html

Page 15: Lessons learned from a large scale OSGi web app

Profiles Rest

Profiles API

Profiles Service

Progress Rest

Progress API

Progress Service

MongoDB

Curriculum API

Curriculum Service

MongoDB MongoDB

services

in OSGi

Page 16: Lessons learned from a large scale OSGi web app

Profiles Rest

Profiles API

Profiles Service

Progress Rest

Progress API

Progress Service

MongoDB

Curriculum API

Curriculum Service

MongoDB MongoDB

Micro

Services

REST

REST

Page 17: Lessons learned from a large scale OSGi web app

Benefits of OSGi

services

Modular architecture!

No remoting

overhead Much simpler

DevOps

Benefits of Micro Services

Modular architecture! Teams can own a service

Page 18: Lessons learned from a large scale OSGi web app

Data Storage

Page 19: Lessons learned from a large scale OSGi web app

Semantic data store

(triple store)

MySQL (with JPA)

MongoDB

NowBeginning

Page 20: Lessons learned from a large scale OSGi web app

Relational databases

in a modular system

A part of data should be owned by 1 service

How to set boundaries in a relational world!?

Page 21: Lessons learned from a large scale OSGi web app

Relational databases

in the modern web

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

Page 22: Lessons learned from a large scale OSGi web app

MongoDB: our database of choice

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

Page 23: Lessons learned from a large scale OSGi web app

Code example: MongoDB with Amdatu

Amdatu Mongo Service

Setup Object Mapper

Execute query

Page 24: Lessons learned from a large scale OSGi web app

Release & Deployment

Page 25: Lessons learned from a large scale OSGi web app

Autoscaling

Launch group

Target

Target

Target

Load balancer

Page 26: Lessons learned from a large scale OSGi web app

Binaries

Build Binaries Repository

Page 27: Lessons learned from a large scale OSGi web app

Deployment

Software distribution framework

Manages the installation and upgrade

of bundles, configuration, etc. to

heterogenous targets

Page 28: Lessons learned from a large scale OSGi web app

Deployment

Load

Load Balancer

TargetTarget

Target

School

Load

Load Balancer

TargetTarget

Target

Content backend

Repository

Apache ACE

CI Build Server

Page 30: Lessons learned from a large scale OSGi web app
Page 31: Lessons learned from a large scale OSGi web app

Unit testing OSGi codeis trivial

But what if we wantmore?

Page 32: Lessons learned from a large scale OSGi web app

Code we want to test

Page 33: Lessons learned from a large scale OSGi web app

Integration testing turnsout to be trivial as well!

Configure and inject service

Junit style asserts

Page 34: Lessons learned from a large scale OSGi web app

Run tests from Bndtools

Page 35: Lessons learned from a large scale OSGi web app

Frontend frameworks

Page 36: Lessons learned from a large scale OSGi web app

jQuery Pros

Can do a lot with not much code

Lot of

helpful

plugins

available

Easy to get

started

Page 37: Lessons learned from a large scale OSGi web app

jQuery

Hard to

maintain

Cons

Hard to test

Page 38: Lessons learned from a large scale OSGi web app

AngularJS

Page 39: Lessons learned from a large scale OSGi web app

AngularJS Pros

Designed towards

consuming REST data

Well

structured

No guessing in htmlTestable

Page 40: Lessons learned from a large scale OSGi web app

TypeScript Pros

Well

structured

Code completion

compile time checks

Page 41: Lessons learned from a large scale OSGi web app

TypeScript Cons

Well

structured

Slow-ish

Need to have a

definition to work

Page 42: Lessons learned from a large scale OSGi web app

A modular architecture gives us:

Maintainability

Extensibility

Freedom to change

Wrap up

Page 43: Lessons learned from a large scale OSGi web app

But what if I want

Spring

EJB

…?

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