Architecture of a Modern Web App - SpringOne India

29
Architecture of a Modern Web App Jeremy Grelle, SpringSource Staff Engineer Github / Twitter: @jeremyg484 1 Thursday, December 13, 12

description

 

Transcript of Architecture of a Modern Web App - SpringOne India

Page 1: Architecture of a Modern Web App - SpringOne India

Architecture of a Modern Web AppJeremy Grelle, SpringSource Staff Engineer

Github / Twitter: @jeremyg484

1Thursday, December 13, 12

Page 2: Architecture of a Modern Web App - SpringOne India

Overview

• Where we’ve been• Where we’re going• How we’ll get there• Questions

2Thursday, December 13, 12

Page 3: Architecture of a Modern Web App - SpringOne India

In the beginning...

• Sites were static HTML Pros:• low computational overhead• highly cacheable• highly indexable

Cons:• hard (easy?) to update• no personalization• usually poor UI

3Thursday, December 13, 12

Page 4: Architecture of a Modern Web App - SpringOne India

Let there be CGI

• Introduced dynamic generated pages

Pros:• dynamic!• selectively cacheable• highly indexable• personalizable

Cons:• “high” computational overhead• hard to create• usually poor UI

4Thursday, December 13, 12

Page 5: Architecture of a Modern Web App - SpringOne India

LiveScript JavaScript

• Dynamic pages• Lightweight alternative to applets• Mostly used for simple scripting

–basic form validation–popup ads–comet cursor trails

Pros:• enhanced usability, maybe• reduced trips to the server

Cons:• abuses annoyed users• business logic often implemented

twice: client and server

5http://en.wikipedia.org/wiki/File:Pop-up_ads.jpg

Thursday, December 13, 12

Page 6: Architecture of a Modern Web App - SpringOne India

AJAX - Web 2.0

• Google Maps sparked Web 2.0• GMail

– required JavaScript

Pros:• killer UI• more responsive apps

Cons:• difficult to cache• impossible to index• required JavaScript

6Thursday, December 13, 12

Page 7: Architecture of a Modern Web App - SpringOne India

Unobtrusive JavaScript

• No JavaScript, no problem• Provide features for user agents

that support them– fall back to basic HTML

Pros:• wider compatibility• just as rich UI• just as responsive

Cons:• higher development costs• requires thoughtful engineering

7Thursday, December 13, 12

Page 8: Architecture of a Modern Web App - SpringOne India

Client Side Applications

• Business logic lives on the client• Resources and permanent state

stored on the server• Application state stored on client

Pros:• reduce server workloads• application is highly cacheable• extremely rich UI

Cons:• content not indexable• requires JavaScript• often requires a ‘modern’ browser

8Thursday, December 13, 12

Page 9: Architecture of a Modern Web App - SpringOne India

Overview

• Where we’ve been• Where we’re going• How we’ll get there• Questions

9Thursday, December 13, 12

Page 10: Architecture of a Modern Web App - SpringOne India

From: server-side appsTo: smart clients and services

10Thursday, December 13, 12

Page 11: Architecture of a Modern Web App - SpringOne India

Client

Server

ViewGeneration Controllers

Service Layer

RepositoriesChannels RDBMS

CRUD

ApplicationServer

Browser

Browser-based

HTML Rendering

(progressive

enhancement)

HTML HTTP

Thursday, December 13, 12

Page 12: Architecture of a Modern Web App - SpringOne India

Client

Server

Service Layer

RepositoriesChannels RDBMS

CRUD

Browser app orembedded in native

HTML5 & JS Engine

ControllersDOM

Client-side modelweb stg

Thursday, December 13, 12

Page 13: Architecture of a Modern Web App - SpringOne India

Client

Server

Service Layer

RepositoriesChannels RDBMS

CRUD

Browser app orembedded in native

JSON HTTP & websockets

HTML5 & JS Engine

ControllersDOM

Client-side modelweb stg

Thursday, December 13, 12

Page 14: Architecture of a Modern Web App - SpringOne India

Client

Server

Service Layer

RepositoriesChannels RDBMS

CRUD

Browser app orembedded in native

JSON HTTP & websockets

HTML5 & JS Engine

ControllersDOM

Client-side model

events& notifications

web stg

Thursday, December 13, 12

Page 15: Architecture of a Modern Web App - SpringOne India

Client

Cloud/PaaS

Service Layer

RepositoriesChannels RDBMS

CRUD

Browser app orembedded in native

JSON HTTP & websockets

HTML5 & JS Engine

ControllersDOM

Client-side model

events& notifications

web stg

Thursday, December 13, 12

Page 16: Architecture of a Modern Web App - SpringOne India

Client

Cloud/PaaSRepositoriesChannels RDBMS

CRUD

Browser app orembedded in native

JSON HTTP & websockets

HTML5 & JS Engine

ControllersDOM

Client-side model

events& notifications

web stg

Service Service Servicebusiness / domain services

Thursday, December 13, 12

Page 17: Architecture of a Modern Web App - SpringOne India

Client

PaaSCRUD

RepositoriesChannels RDBMS

Browser app orembedded in native

JSON HTTP & websockets

HTML5 & JS Engine

ControllersDOM

Client-side model

events& notifications

web stg

Service Service Servicebusiness / domain services

Thursday, December 13, 12

Page 18: Architecture of a Modern Web App - SpringOne India

Client

PaaS

Browser app orembedded in native

JSON HTTP & websockets

HTML5 & JS Engine

ControllersDOM

Client-side model

events& notifications

web stg

Service Service Servicebusiness / domain services

Thursday, December 13, 12

Page 19: Architecture of a Modern Web App - SpringOne India

events& notifications

Client

PaaS

Browser app orembedded in native

JSON HTTP & websockets

HTML5 & JS Engine

ControllersDOM

Client-side modelweb stg

Service Service Servicebusiness / domain services

Service Service Service platform services,web APIs

SQL NoSQL Other

Thursday, December 13, 12

Page 20: Architecture of a Modern Web App - SpringOne India

HTML5(& native)

PaaS

JSON HTTP & websockets

HTML5 & JS Engine

events&

notifications

Applications

Services

Thursday, December 13, 12

Page 21: Architecture of a Modern Web App - SpringOne India

Overview

• Where we’ve been• Where we’re going• How we’ll get there• Questions

17Thursday, December 13, 12

Page 22: Architecture of a Modern Web App - SpringOne India

Simplify Views

• Simple template can render on the client or server– JSP, et al will never render client side

• Avoid imperative logic• Lot of conditions may indicate the model is poorly structured

• Can the model be cleanly serialized?

18Thursday, December 13, 12

Page 23: Architecture of a Modern Web App - SpringOne India

Client side code as a first class citizen

• Apply design patterns• Modularize• Unit test• Enforce code quality

• See “IoC + JavaScript” coming up next.

19Thursday, December 13, 12

Page 25: Architecture of a Modern Web App - SpringOne India

Think Messaging

• Web Sockets are message based• Web Workers are message based• DOM Events are message based

• Web vs Integration is a false dichotomy

• See “Going Async - Practical Patterns for Push-Enabled Applications” coming soon to SpringSource YouTube channel.

21Thursday, December 13, 12

Page 27: Architecture of a Modern Web App - SpringOne India

Client vs Server

• The definitions of “back-end” and “front-end” are shifting– front-end != client, back-end != server

• Embrace both sides

• Specialize in client/server integration

23Thursday, December 13, 12

Page 28: Architecture of a Modern Web App - SpringOne India

Frameworks

• New frameworks are emerging– not quite prime time– watch this space

• Frameworks will not solve all your issues– sorry

24Thursday, December 13, 12

Page 29: Architecture of a Modern Web App - SpringOne India

Resources

• s2js - http://www.github.com/s2js

• cujo.js - http://www.cujojs.com

• scripted - https://github.com/scripted-editor/scripted

• SockJS - http://www.sockjs.org

• Monty Hall REST API - https://github.com/acolyer/monty-hall

• Monty Hall Client - https://github.com/five-eleven/monty-hall-ui

• Messaging Demo - https://github.com/jeremyg484/s12gx-push-service/

25Thursday, December 13, 12