Computer Science E-75 Building Dynamic Websites Harvard Extension School http://www.cs75.net/

Lecture 12: Scalability David J. Malan [email protected] 0

Recommended Reading „

„

„

„

„

Building Scalable Websites by Henderson High Performance MySQL by Zawodny and Balling MySQL Clustering by Davis and Fisk Scalable Internet Architectures by Schlossnagle ...

1

Vertical Scaling „

CPU …

„

Disk … …

„ „

cores, L2 Cache, ... PATA, SATA, SAS, ... RAID

RAM ...

2

Horizontal Scaling

Image from wikimedia.org.

3

PHP Acceleration „ „ „

Code Optimization Opcode Caching ...

4

PHP Accelerators „

„

„

„

„

Alternative PHP Cache (APC) http://pecl.php.net/package/APC eAccelerator http://eaccelerator.net/ XCache http://xcache.lighttpd.net/ Zend Platform http://www.zend.com/en/products/platform/ ...

5

Load Balancing at Layer 4

Image from Building Scalable Websites.

6

Load Balancing with BIND www www www www

IN IN IN IN

A A A A

64.131.79.131 64.131.79.132 64.131.79.133 64.131.79.134

7

Load Balancing at Layer 7

Image from Building Scalable Websites.

8

Sticky Sessions „ „

Layer-7 Load Balancing? Shared Storage? FC, iSCSI, NFS, etc.

„

Cookies?

9

Load Balancers „

Software … … … … … …

„

LVS Perlbal Pirhana Pound Ultra Monkey ...

Hardware … … … …

Cisco Citrix F5 ...

10

Caching „ „ „ „

.html MySQL Query Cache memcached ...

11

.html

12

MySQL Query Cache query_cache_type = 1

http://dev.mysql.com/doc/refman/5.0/en/query-cache.html

13

memcached $memcache = memcache_connect(HOST, PORT); $user = memcache_get($memcache, $id); if (is_null($user)) { mysql_connect(HOST, USER, PASS); mysql_select_db(DB); $result = mysql_query("SELECT * FROM users WHERE id=$id"); $user = mysql_fetch_object($result, User); memcache_set($memcache, $user->id, $user); }

http://www.danga.com/memcached/ http://us2.php.net/memcache

14

MySQL

Image from High Performance MySQL.

15

MySQL

Excerpted from http://dev.mysql.com/tech-resources/articles/storage-engine/part_3.html.

16

Replication: Master-Slave

Excerpted from High Performance MySQL.

17

Replication: Master-Master

Excerpted from High Performance MySQL.

18

Load Balancing + Replication

Excerpted from High Performance MySQL.

19

... + Partitioning

Excerpted from High Performance MySQL.

20

High Availability

Excerpted from High Performance MySQL.

21

Computer Science E-75 Building Dynamic Websites Harvard Extension School http://www.cs75.net/

Lecture 12: Scalability David J. Malan [email protected] 22

Computer Science E-75 - Building Dynamic Websites

Page 2 ... 11. Caching. ▫ .html. ▫ MySQL Query Cache. ▫ memcached. ▫ . ... query_cache_type = 1 http://dev.mysql.com/doc/refman/5.0/en/query-cache.html ...

483KB Sizes 8 Downloads 228 Views

Recommend Documents

Computer Science E-75 - Building Dynamic Websites
Table adapted from http://www.webcheatsheet.com/php/regular_expressions.php. Page 4. 3. A Dynamic Website. Page 5. 4. OOP.

Computer Science E-75 - Building Dynamic Websites
Computer Science E-75. Building Dynamic Websites. Harvard Extension School http://www.cs75.net/. Lecture 5: SQL. David J. Malan [email protected] ...

Computer Science E-75 - Building Dynamic Websites
Computer Science E-75. Building Dynamic Websites. Harvard Extension School http://www.cs75.net/. Lecture 10: Ajax, Continued. David J. Malan.

Computer Science E-75 - Building Dynamic Websites
21. Debuggers. ▫ FireBug https://addons.mozilla.org/en-US/firefox/addon/1843. ▫ JavaScript Debugger https://addons.mozilla.org/en-US/firefox/addon/216 ...

Computer Science E-75 - Building Dynamic Websites
Page 2. 1. Grades. Page 3 ... Page 4. 3. Relational Databases. Page 5 ... 10. Lunch http://www.rebeccascafe.com/wraps_sandwiches_boston_catering.html.

Computer Science E-75 - Building Dynamic Websites
Computer Science E-75. Building Dynamic Websites. Harvard Extension School http://www.cs75.net/. Lecture 10: Ajax, Continued. David J. Malan.

Computer Science E-75 - Building Dynamic Websites
Table adapted from http://www.webcheatsheet.com/php/regular_expressions.php. Page 4. 3. A Dynamic Website. Page 5. 4. OOP.

Computer Science E-75 - Building Dynamic Websites
START TRANSACTION;. UPDATE account SET balance = balance - 1000 WHERE number = 2;. UPDATE account SET balance = balance + 1000 WHERE number = 1;. SELECT balance FROM account WHERE number = 2;. # suppose account #2 has a negative balance! ROLLBACK;. E

Computer Science E-75 - Building Dynamic Websites
6. Properties. ▫ onreadystatechange. ▫. readyState. □ 0 (unitialized). □ 1 (open). □ 2 (sent). □ 3 (receiving). □ 4 (loaded). ▫. responseBody. ▫. responseText. ▫. responseXML. ▫ status. □ 200 (OK). □ 404 (Not Found). □ 500

Computer Science E-75 - Building Dynamic Websites
12. CSV. Image from finance.yahoo.com. Page 14. 13. Computer Science E-75. Building Dynamic Websites. Harvard Extension School http://www.cs75.net/.

Computer Science E-75 - Building Dynamic Websites
0. Computer Science E-75. Building Dynamic Websites. Harvard Extension School http://www.cs75.net/. Lecture 6: SQL, Continued. David J. Malan [email protected] ...

Specification - Building Dynamic Websites
Sep 28, 2009 - HTML, XHTML, and CSS: Your visual blueprint for designing effective Web .... At least one of your pages must include at least one mailto: link.

Syllabus - Building Dynamic Websites
Dec 21, 2009 - JavaScript and PHP, how to configure Apache and MySQL, how to ... Prior programming experience (in any language) and familiarity with ...

JavaScript - Building Dynamic Websites
put cursor in username field if empty if (document.forms.login.username.value == ""). { document.forms.login.username.focus(); document.forms.login.username.value = document.forms.login.username.value;. } // else put cursor in password field else. {

Specification - Building Dynamic Websites
Sep 28, 2009 - All work that you do toward fulfillment of this course's expectations must be your own unless collaboration is explicitly allowed (e.g., by some ...

Notes - Building Dynamic Websites
case "PHP": header("Location: http://us.php.net/results.php?q=" . $_GET["q"]); break; case "MySQL": header("Location: http://search.mysql.com/search?q=" . ... purpose is to whisk the user away, in which case there shouldn't be any time left to ... de

Notes - Building Dynamic Websites
MySQL PHP) framework as well as employing Ajax. Ajax is the fantastic .... language which will empower you to create dynamic websites. Soon after, we'll hit ...

Notes - Building Dynamic Websites
these projects and on average you will require about 10 hours over the course of those three .... 1America is the best. Just ask this guy. 5 .... One of the advantages of doing our own web hosting is that we have root access over the server.

Notes - Building Dynamic Websites
in the semester when we work with databases that forgetting to escape user input can be a serious security concern. • We resorted .... Register for Frosh IMs. .

Syllabus - Building Dynamic Websites
Dec 21, 2009 - Today's websites are increasingly dynamic. Pages are no longer static HTML files but instead generated by scripts and database calls.

JavaScript - Building Dynamic Websites
if (document.forms.login.username.value == "") ... document.forms.login.password.focus(); ... 19. Quirks http://www.quirksmode.org/js/contents.html ...

Project 1 - Building Dynamic Websites
Oct 19, 2009 - All work that you do toward fulfillment of this course's expectations must be your own unless collaboration is explicitly allowed (e.g., by some ...

Project 1 - Building Dynamic Websites
Oct 19, 2009 - or other students' solutions to Project 1, Project 2, or Project 3 to .... After all, you don't want a phone call every ... That way, too, the folks at.

Project 1: PizzaML - Building Dynamic Websites
Oct 19, 2009 - shared in the course's virtual classroom) or lifting material from a book, magazine, ... Design. To what extent is your code written well (i.e., clearly, ... The bulletin board is actually PHP-based software called SMF that we download