Top Banner
COMP9321 Web Application Engineering Improving Performance 1 COMP9321, 16s1, Week 10 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442 Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 10
72

COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Aug 11, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

COMP9321 Web Application Engineering

Improving Performance

1 COMP9321, 16s1, Week 10

http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442

Dr. Basem Suleiman

Service Oriented Computing Group, CSE, UNSW Australia

Semester 1, 2016, Week 10

Page 2: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Review…

Performance

2 COMP9321, 16s1, Week 10

Page 3: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Performance

3 COMP9321, 16s1, Week 10

Page 4: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scalability

4 COMP9321, 16s1, Week 10

Page 5: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Why does performance and scalability matter ?

5 COMP9321, 16s1, Week 10

Page 6: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations

(Network)

6 COMP9321, 16s1, Week 10

Page 7: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations - Network

7 COMP9321, 16s1, Week 10

http://www.cs.cornell.edu/courses/cs519

Page 8: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations - Network

8 COMP9321, 16s1, Week 10

https://devcentral.f5.com

Page 9: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations - Network

9 COMP9321, 16s1, Week 10

By Kanoha - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=7868809

Content Delivery (or Distribution) Network (CDN): an interconnected series of

servers that cache, store, and distribute web content to end-users simultaneously

based on their proximity (geographical distribution)

Single server distribution CDN scheme of distribution

Page 10: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations - Network

10 COMP9321, 16s1, Week 10

http://www.cdnreviews.com/what-is-cdn/

Content Delivery (or Distribution) Network (CDN): an interconnected series of

servers that cache, store, and distribute web content to end-users simultaneously

based on their proximity (geographical distribution)

Page 11: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations

(Servers)

11 COMP9321, 16s1, Week 10

Page 12: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations - Server

12 COMP9321, 16s1, Week 10

Page 13: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations - Server

13 COMP9321, 16s1, Week 10

Page 14: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Architectural Considerations - Server

14 COMP9321, 16s1, Week 10

Page 15: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

General Techniques for Improving

Performance and Scalability

15 COMP9321, 16s1, Week 10

Page 16: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

General Techniques for Improving Performance and Scalability

16 COMP9321, 16s1, Week 10

1. Caching and Replication

2. Parallelism

3. Redundancy

4. Asynchrony

5. Resource Pooling

Page 17: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

General Techniques for Improving Performance and Scalability

17 COMP9321, 16s1, Week 10

1. Caching and Replication

Page 18: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

General Techniques for Improving Performance and Scalability

18 COMP9321, 16s1, Week 10

2. Parallelism

More on implementing multi-thread applications in Java https://docs.oracle.com/javase/tutorial/collections/streams/parallelism.html

Page 19: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

General Techniques for Improving Performance and Scalability

19 COMP9321, 16s1, Week 10

3. Redundancy

Page 20: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

General Techniques for Improving Performance and Scalability

20 COMP9321, 16s1, Week 10

4. Asynchrony

Page 21: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

General Techniques for Improving Performance and Scalability

21 COMP9321, 16s1, Week 10

5. Resource Pooling

Page 22: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

22 COMP9321, 16s1, Week 10

Page 23: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

23 COMP9321, 16s1, Week 10

Page 24: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

24 COMP9321, 16s1, Week 10

Page 25: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

25 COMP9321, 16s1, Week 10

Page 26: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

26 COMP9321, 16s1, Week 10

Page 27: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

27 COMP9321, 16s1, Week 10

Page 28: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

28 COMP9321, 16s1, Week 10

Page 29: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

29 COMP9321, 16s1, Week 10

AJAX = Asynchronous JavaScript and XML

• Update a web page without reloading the page

• Request data from a server - after the page has loaded

• Receive data from a server - after the page has loaded

• Send data to a server - in the background

Page 30: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Performance using HTTP features

30 COMP9321, 16s1, Week 10

Page 31: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

31 COMP9321, 16s1, Week 10

Page 32: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

32 COMP9321, 16s1, Week 10

Page 33: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

33 COMP9321, 16s1, Week 10

Page 34: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

34 COMP9321, 16s1, Week 10

Page 35: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

35 COMP9321, 16s1, Week 10

Page 36: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

36 COMP9321, 16s1, Week 10

Page 37: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

37 COMP9321, 16s1, Week 10

Page 38: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

38 COMP9321, 16s1, Week 10

Page 39: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

39 COMP9321, 16s1, Week 10

Page 40: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

40 COMP9321, 16s1, Week 10

JOINT queries

Page 41: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

41 COMP9321, 16s1, Week 10

JOINT queries

Page 42: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

42 COMP9321, 16s1, Week 10

INSERT operation

Page 43: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

43 COMP9321, 16s1, Week 10

INSERT operation

Page 44: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

44 COMP9321, 16s1, Week 10

Page 45: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

45 COMP9321, 16s1, Week 10

Page 46: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Improving Database Access

46 COMP9321, 16s1, Week 10

Page 47: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Characteristics of Scalability

47 COMP9321, 16s1, Week 10

Page 48: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Characteristics of Scalability

48 COMP9321, 16s1, Week 10

Page 49: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Characteristics of Scalability

49 COMP9321, 16s1, Week 10

Page 50: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Characteristics of Scalability

50 COMP9321, 16s1, Week 10

https://blog.twitter.com/2011/twitter-search-is-now-3x-faster

• Inefficiencies Twitter’s former Ruby-on-Rails front-end servers

• The front ends ran a fixed number of single-threaded rails worker

processes, each of which did the following:

• parsed queries

• queried index servers synchronously

• aggregated and rendered results

• The model of synchronous request processing uses Twitter’s CPUs

inefficiently

• Over time, significant technical debt in Ruby code base was accrued,

making it hard to add features and improve the reliability of our search

engine..

Page 51: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Characteristics of Scalability

51 COMP9321, 16s1, Week 10

More details on the case study and the Blender implementation: https://blog.twitter.com/2011/twitter-search-is-now-3x-faster

Blender addresses these issues by:

• Creating a fully asynchronous aggregation service. No thread waits on

network I/O to complete

• Aggregating results from back-end services, for example, the real-time,

top tweet, and geo indices

• Elegantly dealing with dependencies between services. Workflows

automatically handle transitive dependencies between back-end services

Page 52: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling and

Request Load Balancing

52 COMP9321, 16s1, Week 10

Page 53: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

53 COMP9321, 16s1, Week 10

Types of Scaling:

Page 54: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

54 COMP9321, 16s1, Week 10

Types of Scaling:

Page 55: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

55 COMP9321, 16s1, Week 10

Request Load Balancing for Horizontal Scaling

Page 56: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

56 COMP9321, 16s1, Week 10

Request Load Balancing for Horizontal Scaling

Page 57: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

57 COMP9321, 16s1, Week 10

Page 58: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

58 COMP9321, 16s1, Week 10

Page 59: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

59 COMP9321, 16s1, Week 10

Page 60: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

60 COMP9321, 16s1, Week 10

Page 61: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

61 COMP9321, 16s1, Week 10

Page 62: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

62 COMP9321, 16s1, Week 10

Page 63: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

63 COMP9321, 16s1, Week 10

Application-Level Load Balancing with Stateless Logic

Page 64: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

64 COMP9321, 16s1, Week 10

Application-Level Load Balancing with Stateless Logic

Page 65: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

65 COMP9321, 16s1, Week 10

http://www.ibm.com/developerworks/java/library/j-jtp07294/index.html

Application-Level Load Balancing with Stateless Logic

Page 66: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

66 COMP9321, 16s1, Week 10

Scaling Databases - Replication

Page 67: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

67 COMP9321, 16s1, Week 10

Scaling Databases - Replication

Page 68: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

68 COMP9321, 16s1, Week 10

Scaling Databases - Replication

Page 69: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

69 COMP9321, 16s1, Week 10

Scaling Databases - Replication

Page 70: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

Scaling & Request Load Balancing

70 COMP9321, 16s1, Week 10

Scaling Databases - Replication

Page 71: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

References

71 COMP9321, 16s1, Week 10

• Building Scalable and High-performance Java Web Applications by Greg Barish,

Addison Wesley

• Building Scalable Web Sites by Cal Henderson, O’Reilly Books

• Gregor Roth, ”Server load balancing architectures”, JavaWorld, October 2008

• http: //www.javaworld.com/javaworld/jw-10-2008/jw-10-load-balancing-1.html

Page 72: COMP9321 Web Application Engineeringcs9321/16s1/lectures/lec10/Lec-10.pdf · 2016-05-12 · Architectural Considerations - Network COMP9321, 16s1, Week 10 7

72 COMP9321, 16s1, Week 10