performance optimisation - scaling a hobby project to serious business
DESCRIPTION
We can not always start a new project from scratch and choose the right architecture and framework to guarantee scalability and performance, sometimes we have to deal with existing and grown systems. Here I'll show you our findings when we analyzed spelix.at, a web based system for cave management. The hotspots that we identified can be found in various systems all over the world.TRANSCRIPT
1 1
Performance op,miza,on: scaling a hobby project to serious business SPELIX.AT
web based cave management
Let me take you onto a short journey …
3 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
… into a world below us …
4 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
… full of mystery …
5 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
… full of surprise …
6 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
… full of secrets …
7 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
A world to be discovered
8 COMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
To be explored
9 9
our history in digital cave management
• 1989: first PC version: survey data analysis, simple list generator
• 1996: database version based on MS Access: master data, tour reports, extended lists, data export
• challenge: mulM user capability
• Import / export files distributed via email / disc
• MySQL database on webserver ODBC client/server connecMons
• Originally intended for 1 (our) caving club (Linz) • IntegraMon of the HallstaX club • 2006: consideraMons within the caver’s associaMon in Austria to use a web database as the base for the Austrian cave directory
10 10
Spelix 1.0
• 2008: Web frontend • HTML / JavaScript • Server: LAMP
11 11
Spelix 2.0
• Map based UI (Google Maps API) • Extended funMonality • Trip reporMng • Survey data editor
12 12
a growing community
• Established as the Austrian cave directory
• Most clubs in Austria have accounts (2012: 120)
• Inquiry from Germany to use Spelix for “Schwäbische Alb”
• Workshops, trainings
• Special feature requests • Changing workflows • More and more user complaints
• Complaints regarding performance
• More developers !!!
Time for a new major version ?
13 13
Analyzing Spelix 2.0
Performance ! Are we able to
onboard more users ?
14 14
From the user’s perspec,ve
So what does that mean in detail ?
15 15
networking
• Create container files for CSS and JS • Use sprites for icons
HTTP Redirects
16 16
Java Script
• showCave is the hotspot in Java Script
17 17
server contribu,on
• ‘getcaves’ is our server side hotspot
18 18
Server side transac,on details
• Always load complete list of cave groups
• Always load complete list of caves for selected group
• => lack of data caching
19 19
digging into getCaves…
Time to check the database !
20 20
Database execu,on plan
Review and tune database views !
21 21
What about single record pages ?
22 22
Hotspot tour reports
23 23
Considera,ons for a new version
• Improve user experience measures • Scale system for extended user community
• Flexible data structure • MulMmedia integraMon
• Mobile environment
• Development environment
• Google API V2 disconMnued
24 24
Spelix 3
• New map window (Leaflet API) • Map based logic
• Mobile capability
• Local data storage • Restructured database • GPS integraMon • Enhanced document management
25 25
First impression
• Looks beXer • Network: sMll too many roundtrips (css, js, images) • JavaScript: well, there is a lot to do on the page…
26 26
User experience
Let’s roll up our sleeves…
27 27
Session cache
• select * from sys2: read user preferences from DB
• Store record in $_SESSION
28 28
Start page execu,on plan
29 29
Usage of external libraries
Method invocations for /
Method invocations including Spyc
30 30
AJAX calls from main page
• /katgrp/browse: 784.59ms • /cave/browse/gis/$/katgrp/1626: 779.92ms
• /katgrp/get/$/1626: 762.25ms££
31 31
/katgrp/browse
32 32
/cave/browse/gis/$/katgrp/1626
33 33
/katgrp/get/$/1626
34 34
Back to /cave/browse/gis/$/katgrp/1626
35 35
Sessions in PHP
• session_start() locks the file where session data are stored
• Released when script ends • Use session_write_close() to unlock the file before execuMng slower code
• Or create your own save handler with session_set_save_handler()
36 36
Looks beWer now…
37 37
But …
• Cave groups are currently not held in LocalStorage L • However – what is the server doing ?
38 38
/katgrp/browse server side execu,on
And again it’s Mme to check the database !
39 39
From the DB perspec,ve
40 40
We’re geXng there…
• Cave groups are sMll not held in LocalStorage L • But this does not get worse with more data
41 41
Monitoring the system
42 42
Monitoring ac,vity
43 43
User ac,ons
44 44
Cave group access
45 45
Cave access
46 46
A cave informa,on system ready for the future
47 47
allowing us to do what we actually want to do…
48 48
to document our work…
49 49
to visualize our results …
50 50
and leaving us ,me for other important du,es aZer returning from the cave…
51 51
More Informa,on, free products
• [email protected] • @HZeitlhofer
• dynaTrace Enterprise – Full End-‐to-‐End Visibility in your PHP, Java, .NET Apps – Sign up for a 15 Days Free Trial on hXp://compuwareapm.com
• dynaTrace AJAX Edi=on – Browser DiagnosMcs for IE + FF – Free Download @ hXp://ajax.dynatrace.com
• Blog: hXp://apmblog.compuware.com
• Caving in Austria: hXp://www.hoehlenforschung.at
52 © 2011 Compuware Corporation — All Rights Reserved © 2011 Compuware Corporation — All Rights Reserved
52
ParMcipate in Compuware APM Discussion Forums apmcommunity.compuware.com
Like us on Facebook facebook.com/CompuwareAPM
Join our LinkedIn group Compuware APM User Group
Follow us on TwiWer twiXer.com/CompuwareAPM
Read our Blog hXp://apmblog.compuware.com
Watch our Videos & product Demos youtube.com/Compuware
www.compuware.com/APM
Thank You
53 © 2011 Compuware Corporation — All Rights Reserved © 2011 Compuware Corporation — All Rights Reserved
53