Frontend 'vs' Backend Getting the Right Mix

56
FRONTEND 'VS' BACKEND GETTING THE RIGHT MIX Created by / / Bob Paulin @bobpaulin [email protected]

description

Modern website architectures are typically composed of 2 parts: frontend and backend. Building out frontend and backend components requires diverse skill sets and often have competing interests when it comes to developer productivity and site performance. This talk will discuss some ways Java frameworks deal with these issues as well as benefits and tradeoffs. The talk will include combine demos with cutting edge frontend frameworks (Handlebarsjs, CoffeeScript, Less) and popular Java backends (Spring, Apache CXF). Bio: Bob Paulin is an independent consultant that has been developing on Java for the past 10 years. Bob is focuses on Business Enablement and Web Centric Applications. He’s presented in the past at CJUG on Apache Sling and is currently helping his clients perform modular development/design, automation for continuous delivery, and build forward leaning web applications. When not coding, Bob enjoys coaching football and spending time with his with his wife and 3 kids.

Transcript of Frontend 'vs' Backend Getting the Right Mix

Page 1: Frontend 'vs' Backend   Getting the Right Mix

FRONTEND 'VS' BACKENDGETTING THE RIGHT MIX

Created by / / Bob Paulin @bobpaulin [email protected]

Page 2: Frontend 'vs' Backend   Getting the Right Mix

ABOUT MEIndependent ConsultantBusiness EnablementWeb Centric

Page 3: Frontend 'vs' Backend   Getting the Right Mix

A LONG TIME AGO I CREATED "FACEBOOK"College students love seeing pictures of their friends doingstupid things at partiesPhotoshop can be used to make funny pictures even morefunnyDo not host anything on your school's web property

Page 4: Frontend 'vs' Backend   Getting the Right Mix

WHAT THIS TALK IS NOTDeep Dive into web frameworksTHE answer on which architecture is better

Page 5: Frontend 'vs' Backend   Getting the Right Mix

WHAT THIS TALK ISUsing Frontend and Backend frameworks togetherHow developers work togetherAdvantages and disadvantages of architecturesSome empirical data on architecture performance

Page 6: Frontend 'vs' Backend   Getting the Right Mix

HOW DID WE GET HERE?ComplexityCorporate CultureDeveloper Aptitudes

Page 7: Frontend 'vs' Backend   Getting the Right Mix

BACKEND DEVELOPER

Page 8: Frontend 'vs' Backend   Getting the Right Mix

TYPICAL BACKEND DEVELOPERS

Focus on the server sideData Storage and RetrievalSystem ArchitectureAvailabilityDoes it work?

Page 9: Frontend 'vs' Backend   Getting the Right Mix

FRONTEND DEVELOPER

Page 10: Frontend 'vs' Backend   Getting the Right Mix

TYPICAL FRONTEND DEVELOPERS

Client/Browser focusedInformation ArchitectureCloser to creative/designDoes it look right?

Page 11: Frontend 'vs' Backend   Getting the Right Mix

DOES THIS MODEL ACTUALLY WORK?

Page 12: Frontend 'vs' Backend   Getting the Right Mix

CHALLENGES WITH FRONTEND/BACKENDTEAMS

Page 13: Frontend 'vs' Backend   Getting the Right Mix

COMPETING REQUIREMENTS

Page 14: Frontend 'vs' Backend   Getting the Right Mix

FREQUENT HANDOFFS

Page 15: Frontend 'vs' Backend   Getting the Right Mix

FRAMEWORKS OFTEN COUPLE FRONTEND ANDBACKEND TECHNOLOGIES

Page 16: Frontend 'vs' Backend   Getting the Right Mix

ANOTHER WAY TO THINK ABOUT THE PROBLEM...AN AMERICAN FOOTBALL ANALOGY

Page 17: Frontend 'vs' Backend   Getting the Right Mix

FRONTEND DEVELOPERS = OFFENSIVE BACKS

Page 18: Frontend 'vs' Backend   Getting the Right Mix

FRONTEND DEVELOPERS = OFFENSIVE BACKSScore Points with CustomersWork is highly visibleCan be limited by poor play at other positionsOften get the biggest share of blame when things go wrongand praise when things go right

Page 19: Frontend 'vs' Backend   Getting the Right Mix

BACKEND DEVELOPERS = OFFENSIVE LINE

Page 20: Frontend 'vs' Backend   Getting the Right Mix

BACKEND DEVELOPERS = OFFENSIVE LINEEnable other positions to do great workWork is not usually visibleMistakes often have a cascading effectGenerally only get blamed when things go wrong. Whenthings go right .... well things are just suppose to work all thetime right?

Page 21: Frontend 'vs' Backend   Getting the Right Mix

OK ENOUGH ABOUT YOUR PEOPLE PROBLEMSLETS LOOK AT SOME CODE ALREADY!

Page 22: Frontend 'vs' Backend   Getting the Right Mix

3 DIFFERENT APPROACHES TO THE SAME WEBSITE

REQUIREMENTS - A BOOK REVIEW SITE

Allow users to select keyword preferencesAllow users to view and post review comments about aspecific bookShould use responsive design. Because, well, that's the hotnew thing right?

Page 23: Frontend 'vs' Backend   Getting the Right Mix

A BACKEND RECIPESpring MVCSpring DataMongoDBApache TomcatApache Http ServerJSPTwitter BootstrapWRO4JAmazon Cloudfront (CDN)

Page 24: Frontend 'vs' Backend   Getting the Right Mix

DESIGNCache Google Api Response for Books and Book SearchConsolidate and minify CSS and JS using WRO4JPage turn between Homepage and ReviewsPage can't be cached but static resources can

Page 25: Frontend 'vs' Backend   Getting the Right Mix

CODESpring MVC ControllerSpring Data ServicesWRO4J Config

Page 26: Frontend 'vs' Backend   Getting the Right Mix

ARCHITECTURE

Page 27: Frontend 'vs' Backend   Getting the Right Mix

A FRONTEND RECIPEBrunchChaplinJSCoffeeScriptHandlebarsNode.jsApache CXFSpring DataMongoDBApache TomcatApache Http ServerTwitter BootstrapAmazon Cloudfront (CDN)

Page 28: Frontend 'vs' Backend   Getting the Right Mix

DESIGNAll Services are done through AJAXApache CXF Provides RestfulServices(Consumers/Producers) JAX-RSSingle Page Application Behavior via ChaplinNode.js but only for Brunch CompilationAll pages and frontend code cachedSome Data Services Cached: Volatile vs Static

Page 29: Frontend 'vs' Backend   Getting the Right Mix

CODEindex.html - Look Ma, only 16 lines of server side html!Chaplin ControllerChaplin ViewsChaplin ModelsHandlebars TemplatesApache CXF JAX-RS

Page 30: Frontend 'vs' Backend   Getting the Right Mix

INDEX.HTML<!doctype html><!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <!--<![endif]--><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Frontend Home Page</title> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="/frontend-web/stylesheets/app.css"> <script src="/frontend-web/javascripts/vendor.js"></script> <script src="/frontend-web/javascripts/app.js"></script> <script> </script></head><body></body></html>

require('initialize');

Page 31: Frontend 'vs' Backend   Getting the Right Mix

ARCHITECTURE

Page 32: Frontend 'vs' Backend   Getting the Right Mix

A MIXED RECIPEFRONTEND TECH

BackboneCoffeeScriptHandlebarsTwitter Bootstrap

BACKEND TECH

Spring MVCHandlebars.javaWRO4JApache CXFSpring DataMongoDBApache TomcatApache Http ServerAmazon Cloudfront (CDN)

Page 33: Frontend 'vs' Backend   Getting the Right Mix

DESIGNSome Services are done through AJAX others on ServersideApache CXF Provides RestfulServices(Consumers/Producers) JAX-RSPage turn between Homepage and ReviewsPage can't be cached but static and service resources canPage actions do not require page turnsTemplates are shared between frontend and backendBook Searches are cached with data URIs

Page 34: Frontend 'vs' Backend   Getting the Right Mix

CODECached ControllerWRO4JBackbone Views

Page 35: Frontend 'vs' Backend   Getting the Right Mix

ARCHITECTURE

Page 36: Frontend 'vs' Backend   Getting the Right Mix

TEST DESIGNWeb Page Test

Browser - Current Chrome

Location - Virgina

Click events tested locally using Chrome Developer Tools

Page 37: Frontend 'vs' Backend   Getting the Right Mix

TEST SCRIPT1. Homepage View2. Add a New Book Preference3. Open a Review4. Add A Comment

Page 38: Frontend 'vs' Backend   Getting the Right Mix
Page 39: Frontend 'vs' Backend   Getting the Right Mix

BACKEND HOMEPAGE WATERFALL

Page 40: Frontend 'vs' Backend   Getting the Right Mix

FRONTEND HOMEPAGE WATERFALL

Page 41: Frontend 'vs' Backend   Getting the Right Mix

MIXED HOMEPAGE WATERFALL

Page 42: Frontend 'vs' Backend   Getting the Right Mix
Page 43: Frontend 'vs' Backend   Getting the Right Mix
Page 44: Frontend 'vs' Backend   Getting the Right Mix

BACKEND REVIEW WATERFALL

Page 45: Frontend 'vs' Backend   Getting the Right Mix

FRONTEND REVIEW WATERFALL

Page 46: Frontend 'vs' Backend   Getting the Right Mix

MIXED REVIEW WATERFALL

Page 47: Frontend 'vs' Backend   Getting the Right Mix
Page 48: Frontend 'vs' Backend   Getting the Right Mix
Page 49: Frontend 'vs' Backend   Getting the Right Mix
Page 50: Frontend 'vs' Backend   Getting the Right Mix

DISCUSSIONWhat does this data tell us?What does it not tell us?Which is most scalable?Variations between Browsers

Page 51: Frontend 'vs' Backend   Getting the Right Mix

CONCLUSIONS

Page 52: Frontend 'vs' Backend   Getting the Right Mix

BACKEND SUMMARYMost consistant load timesBetter performance with static dataLess requestsFull page loads for incremental changes can prevent optimalperformanceData is embedded within the page so it can't be separatedinto different TTLDynamic content within the JSP prevents pages from beingcached. Increases traffic to the origin

Page 53: Frontend 'vs' Backend   Getting the Right Mix

FRONTEND SUMMARYRequests handled independently. Enables fine grain cachingEliminates page turns to refesh data modelSignificant caching opportunities at the edgeGenerates more requestsHigher memory and CPU consumption on the client end

Page 54: Frontend 'vs' Backend   Getting the Right Mix

MIXED SUMMARYAllows the most flexibility in how information is loadedCode reuse at the template levelEliminates some page turns related to data updatesPerformance suffers when both page and services arevolatile (non-cachable)