cloud computing lecture #7 introduction to ajax jimmy lin the ischool university of maryland...
Post on 21-Dec-2015
214 views
TRANSCRIPT
Cloud Computing Lecture #7
Introduction to Ajax
Jimmy LinThe iSchoolUniversity of Maryland
Wednesday, October 15, 2008
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United StatesSee http://creativecommons.org/licenses/by-nc-sa/3.0/us/ for details
Material adopted from slides by Ian Graham: http://www.iangraham.org/talks/
The iSchoolUniversity of Maryland
What is Cloud Computing?
1. Web-scale problems
2. Large data centers
3. Different models of computing
4. Highly-interactive Web applications
Source: Wikipedia
The iSchoolUniversity of Maryland
Ajax Asynchronous JavaScript and XML: an approach for
building interactive Web applications
Ajax refers to a number of technologies: XHTML/CSS for presentation XML for data exchange (or JSON) XMLHttpRequest object for asynchronous communication JavaScript to tie everything together
From “old-school” Web applications to Ajax…
The iSchoolUniversity of Maryland
“Old-School” Web Applications
server-side systems
backend database
browser
Inte
rfac
e
Webserver
HTTP request
HTTP response
1
user does something
2
browser sends request to server
3
server generates Web page as a response to the request
4
data is returned in response to the request
5
browser replaces view with data sent from server
The iSchoolUniversity of Maryland
Characteristics User-driven: Things only happen when the user does
something (e.g., clicks on a link or button)
Views defined by URLs: You can bookmark something and come back to it; use the forward/backward button
Simple user interaction model: Not that many things you can do in browser
Synchronous Interaction: System responses are synchronized with user-driven events
The iSchoolUniversity of Maryland
Synchronous Interactions
browser
server-side
Time
user activity user activity user activity
server processing server processing
Re
qu
est
Re
qu
est
Re
spo
ns
e
Re
spo
ns
e
browser server-side systemsHTTP request
HTTP response
12
45 3
1
2
3
4
5
LAMP
Linux
Apache
MySQL
PHP/Python/Perl
So what do you run on the server side?
The iSchoolUniversity of Maryland
From “Old-School” to Ajax
browser
Inte
rfac
e request
response
Ajax intermediates between the interface and the server.
server-side systems
backend database
Webserver
data management
Ajax“engine”
interaction management
The iSchoolUniversity of Maryland
Inside the Browser
browser
HTML / CSSdata
HTML / CSSdata
other data(e.g. images)
other data(e.g. images)
Inte
rfac
e
Ren
der
ing
En
gin
e
HTTP request
HTTP response
The iSchoolUniversity of Maryland
Enter JavaScript
browser
HTML / CSSdata
HTML / CSSdata
other data(e.g. images)
other data(e.g. images)
Inte
rfac
e
Ren
der
ing
En
gin
e
HTTP request
HTTP response
JavaScript Engine
JavaScriptcode
JavaScriptcode
The iSchoolUniversity of Maryland
Enter Ajax
browser
HTML / CSSdata
HTML / CSSdata
other data(e.g. images)
other data(e.g. images)
Inte
rfac
e
Ren
der
ing
En
gin
e
HTTP request
HTTP response
JavaScript Engine
XMLdata
XMLdata
JavaScriptcode
JavaScriptcode
XMLHttpRequest
HTTP request
The iSchoolUniversity of Maryland
From Synchronous Interactions…
browser
server-side
Time
user activity user activity user activity
server processing server processing
Re
qu
est
Re
qu
est
Re
spo
ns
e
Re
spo
ns
e
The iSchoolUniversity of Maryland
To asynchronous Interactions
browser
server-side
Time
user activity
server processing server processing
Re
qu
est
Re
qu
est
Re
spo
ns
e
Re
spo
ns
e
client-side processing
The iSchoolUniversity of Maryland
Components of an Ajax Interaction
1. A client event occurs (captured by JavaScript event handlers)
2. An XMLHttpRequest object is created and configured
3. An asynchronous request is made to the server via the XMLHttpRequest object
4. Server processes request and returns data, executing a callback in the XMLHttpRequest object
5. The HTML DOM is updated based on response data
The iSchoolUniversity of Maryland
DOM Document Object Model: platform- and language-
independent way to represent XML Adopts a tree-based representation W3C standard, supported by modern browsers
JavaScript uses DOM to manipulate content To process user events To process server responses (via XMLHttpRequest)
The iSchoolUniversity of Maryland
Ajax: Things to watch out for! Hype
Best thing since sliced bread?
Application development/maintenance cost Brower incompatibilities Many different approaches and tools For many things, lack of agreed-on best practices
Behavior is not ‘Web-like’ Standard things often don’t work correctly (e.g., browser ‘back’
button, bookmarks) Usability issues for users with disabilities
Security issues Whole new class of cross-site scripting (XSS) exploits
The iSchoolUniversity of Maryland
Making your life easier… Dojo: really cool set of interface widgets
http://www.dojotoolkit.org/
Direct Web Remoting: RPC library for calling server-side Java from client-side JavaScript.http://directwebremoting.org/
jQuery: supports chaining of expressions for more concise code.http://jquery.com/
Prototype: provides support for more traditional object-oriented programminghttp://www.prototypejs.org/
The iSchoolUniversity of Maryland
Learning Ajax Bewildering options:
PHP vs. Python vs. Perl vs. ASP vs. JSP … XML vs. JSON Countless toolkits, frameworks, libraries, etc.
Amazing amount of information online: Numerous Web tutorials Learn by example Learn by building
The iSchoolUniversity of Maryland
The next frontier?
server-side systems
MySQL
browser
Inte
rfac
e
Apache
HTTP request
HTTP response
Hadoop cluster
HDFSMapReduce
Interactive Web applications
Backend batch processing
Source: Technology Review (July/August, 2008)
Database layer: 800 eight-core Linux servers running MySQL (40 TB user data)
Caching servers: 15 million requests per second, 95% handled by memcache (15 TB of RAM)