delivering mobile apps that perform

61
Delivering Mobile Apps that Perform As simple as that or not! Team leader of Mobile Services OutSystems Rúben Gonçalves

Upload: ruben-goncalves

Post on 15-Apr-2017

91 views

Category:

Technology


7 download

TRANSCRIPT

Page 1: Delivering Mobile Apps That Perform

Delivering Mobile Apps that Perform

As simple as that or not!

Team leader of Mobile ServicesOutSystems

Rúben Gonçalves

Page 2: Delivering Mobile Apps That Perform

NextStep 2013

Page 3: Delivering Mobile Apps That Perform

NextStep 2013

Page 4: Delivering Mobile Apps That Perform

What happen since then?

You’ve built tons of mobile apps!

Page 5: Delivering Mobile Apps That Perform

Major Pains?

1. Different form factors2. UI of the applicationa3. Performance aaaaaa

Page 6: Delivering Mobile Apps That Perform

BAD PERFORMANCE

“The app is slow…”“It takes forever to load…”

“In the desktop is much faster…”

Page 7: Delivering Mobile Apps That Perform

WHY?

Why is the app slow?What and how can it be improved?

Page 8: Delivering Mobile Apps That Perform

Performance HurdlesServer

Code behind Servers configs Native shell Web app

Device

3G

Hybrid appe.g. OutSystems Now

Infrastructure

Page 9: Delivering Mobile Apps That Perform

Performance HurdlesServer

Code behind Servers configs Native shell Web app

Device

3G

Infrastructure

Page 10: Delivering Mobile Apps That Perform

Integrations

Synchronous integrations

Deadly sin!

BetterBad

Page 11: Delivering Mobile Apps That Perform

CacheMuch BetterBetterBad

Page 12: Delivering Mobile Apps That Perform

PreparationBad Better

Page 13: Delivering Mobile Apps That Perform

PreparationBad Better

List_LateLoadRichWidgets

Page 14: Delivering Mobile Apps That Perform

Design for (perceived) performance

Load information

already available

Load remaining asynchronously

Perceived Performancehow quickly a software feature appears to perform its task

Page 15: Delivering Mobile Apps That Perform

Code behind

• Use Asynchronous integrations• Use cache in the application• Avoid Long and complex preparations• Design for perceived performance

Obtain data later

Make them easier to load

Page 16: Delivering Mobile Apps That Perform

Performance HurdlesServer

Code behind Servers configs Native shell Web app

Device

3G

Infrastructure

Page 17: Delivering Mobile Apps That Perform

Cache-controlEnables the server to specify which components are cacheable.

First load

2.66sFirst load

1.0 MB

Page 18: Delivering Mobile Apps That Perform

Subsequent loads

458msSubsequent loads

13.1KB

Cache-controlEnables the server to specify which components are cacheable.

78x smaller

5.8x faster

Page 19: Delivering Mobile Apps That Perform

HTTP compressionServer compresses the data before sent it to the client

Source description: wikipedia

11.4 KB

4.2x smaller

47.9 KB

Page 20: Delivering Mobile Apps That Perform

Redirects - HTTP 30xWhy avoid it? Pure waste of time!

Ajax call to screen action

Redirect

Page 21: Delivering Mobile Apps That Perform

Domain sharding“Technique for splitting resources across multiple domains (…) browsers are able to download more resources simultaneously”

Tricking the browser!

os.com

static1.os.com

static2.os.com

per domain

HTTP/2 will make domain sharding obsolete

Page 22: Delivering Mobile Apps That Perform

Server configs

• Enable HTTP compression• Enable Cache-control• Avoid Redirects - HTTP 302• Avoid domain sharding

Must haves!

Page 23: Delivering Mobile Apps That Perform

Performance HurdlesServer

Code behind Servers configs Native shell Web app

DeviceInfrastructure

3G

Page 24: Delivering Mobile Apps That Perform

LatencyTime interval between the request and the response

Source definition: wikipedia

Mobile50 – 550ms

350 ms

Desktop20 – 150ms

80ms

Bandwidth can always be

increased but latency cannot be decreased

function of the electrical characteristics of the circuit

Source: dslreports

Page 25: Delivering Mobile Apps That Perform

Cloud Server locationRule of thumb: pick a region closer to the users• Lower network latency• Quick response time• Higher bandwidth

www.cloudping.info

Page 26: Delivering Mobile Apps That Perform

CDN“web servers distributed across multiple locations to deliver content more efficiently to users”

“95,000 CDN servers in 72 countries”

Source definition: developer yahoo Source image and comment: volusion

How to use?• DNS points to Akamai servers• The Platform automatically adds

suffixes

Page 27: Delivering Mobile Apps That Perform

Infrastructure

• Latency can be high on mobile• Choose cloud server region based on user location• Use CDNs if necessary

3G

Page 28: Delivering Mobile Apps That Perform

Performance HurdlesServer

Code behind Servers configs Native shell Web app

DeviceInfrastructure

3G

Page 29: Delivering Mobile Apps That Perform

Cache-control

• Native Webview cache not active by default

• OutSystems Now already has it implemented

Page 30: Delivering Mobile Apps That Perform

Bundle resources

• Embed static resources• E.g. IMGs, Fonts

21s 4s

WITHOUT ADD-ON WITH ADD-ON

22s 4s

iPhone 5

Android 4.4

3G connection

5xfaster

5xfaster

9s 3s

16s 3s

Loading time

3xfaster

5xfaster

WITH ADD-ONWITHOUT ADD-ON

iPhone 5

Android 4.4

Wi-Fi connection

First-time access

Page 31: Delivering Mobile Apps That Perform

Native shell

• Use OutSystems Now• Pre-Bundle static resources - images, fonts…

Cache already active

Page 32: Delivering Mobile Apps That Perform

Performance HurdlesServer

Code behind Servers configs Native shell Web app

DeviceInfrastructure

3G

Page 33: Delivering Mobile Apps That Perform

JavaScriptHow do browsers work?

Scripts are parsed and executed immediately when the parser reaches a <script> tag. The parsing of the document halts until the script has been executed

Source: HTML5 rocks – how browsers work

Do you really need that jQuery plugin?

Do you really need widget?

Run scripts on Load

Page 34: Delivering Mobile Apps That Perform

JavaScript

1,5x 3,9x 9,8x

DELL E6440Chrome 42

237ms

IPhone 6 PlusSafari

360ms

Nokia Lumia 925IE 11

924ms

Samsung Tab4chrome

2312ms

JavaScript in Mobile?• Limited resources - cpu, memory, bandwidth…• Different browsers - different JS engines

Test made on webkit.org

Page 35: Delivering Mobile Apps That Perform

JavaScript

Source: bradshawenterprises

• SlideUp() / SlideDown()• Show() / Hide()• Animate()• …

Animationsin your app

Page 36: Delivering Mobile Apps That Perform

JavaScriptSimple example

Source: bradshawenterprises

Page 37: Delivering Mobile Apps That Perform

JavaScriptjQuery

Source: bradshawenterprises

CSS3

Page 38: Delivering Mobile Apps That Perform

JavaScriptjQuery

Source: bradshawenterprises

CSS3

40 events~9500 events~3s

Page 39: Delivering Mobile Apps That Perform

JavaScript

• Google analytics• Twitter• Facebook• Ads• …

3rd party JavaScripts

PerformanceKillers

Delay page load, event if marked

as async

Why?

Solution?

Page 40: Delivering Mobile Apps That Perform

Web app

• Avoid JavaScript animations• JavaScript runs slower in devices• Run JavaScript after load• Beware JavaScript - your friend or killer

Page 41: Delivering Mobile Apps That Perform

Complex rules

CSS

• [class^="grid-"]• box-shadow• transform

Depends of thenumber elementsto be applied

Minimize the usage of these properties

Page 42: Delivering Mobile Apps That Perform

CSS@Import CSS

CSS

JS

Crucial for rendering@import delays page rendering

HTML

Page 43: Delivering Mobile Apps That Perform

CSSUnused code

Source: Ben Frain

• Add 3000 lines of unused code• Change the colors of links

Remove half

~20% ~40% ~22% ~18% ~18%

Page 44: Delivering Mobile Apps That Perform

CSSImages

25 x 25 px 88 x 100 px

Don’t resize images client-side

Page 45: Delivering Mobile Apps That Perform

Web app

• Avoid complex CSS rules• Avoid @imports• Remove unused CSS• Resize images server side

Page 46: Delivering Mobile Apps That Perform

HTTP requestsThey are bad!

“80% of the end-user response time is spent on the front-end”

“Most of this time is tied up in downloading all the components in the page”

Source: developer yahoo

But a necessary Evil!

Page 47: Delivering Mobile Apps That Perform

HTTP requestsBy far the biggest hurdle

71 requests

~8s to Load

17 CSS25 JS

21 img4 fonts

3G (750 Kbps 100ms RTT)

762 KB downloaded

Your typicalOutSystemsApplication

Page 48: Delivering Mobile Apps That Perform

HTTP requestsThe Platform enables modular code!

+1 css file

+1 JS file

Page 49: Delivering Mobile Apps That Perform

CSS OptimizationThe Platform Amsterdam helps

Source: OutSystems community

Less HTTP Requests

Webblocks CSS aggregation

Page 50: Delivering Mobile Apps That Perform

Web app

• Reduce HTTP requests Avoid CSS in pages Minimize CSS in webblocks Minimize JavaScript in webblocks Beware of Themes inheritance

Page 51: Delivering Mobile Apps That Perform

Platform tipsNotify Widget

Notify

Client Server

w6

w5

LayoutPage

Ajax refresh

Remember Mobile Latency?

w6w5

w4w3

w2w1

~350ms

Page 52: Delivering Mobile Apps That Perform

Platform tips

• Increasingly heavier Ajax Requests• DOM will increase• Memory usage increase

Infinite scroll

Prefer paginationwhen dealing with large amounts of data

Page 53: Delivering Mobile Apps That Perform

Silk UI FrameworkTokyo Theme• CSS optimizations• Light weight JavaScript• Mobile specific widgets

Page 54: Delivering Mobile Apps That Perform

Web app

• Avoid Notify widget• Avoid Infinite scroll pattern• Use Tokyo Theme For mobile apps

Page 55: Delivering Mobile Apps That Perform

TakeawaysTake the whole deck!

Page 56: Delivering Mobile Apps That Perform

Mobile Performanceis easily affected

Page 57: Delivering Mobile Apps That Perform

You won’t get it right at first

Page 58: Delivering Mobile Apps That Perform

Platform Amsterdamis here to help

Page 59: Delivering Mobile Apps That Perform

Thank you!Either clap your hands or throw tomatoes! :)

Page 60: Delivering Mobile Apps That Perform

Questions?But easy ones, please!

Page 61: Delivering Mobile Apps That Perform