Scaling web-applications

1,533 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,533
On SlideShare
0
From Embeds
0
Number of Embeds
144
Actions
Shares
0
Downloads
30
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Scaling web-applications

  1. 1. Scaling Web Applications
  2. 2. Scaling Web Applications Mihai Oaida Senior Web Developer @ www.imobiliare.ro Student , Politehnica Timișoara Web technologies instructor www.tehnologii-web.ro Mihai Oaida <mihai.oaida@gmail.com> 00
  3. 3. Scaling Web Applications We will talk about ... Facts Theory + Myths Architecture Static content Dynamic content Caching Mihai Oaida <mihai.oaida@gmail.com> 01
  4. 4. Scaling Web Applications Web application facts Mostly stateless Very read intensive ( > 90% ) Not so dynamic Can be fine grained Highly scalable, if designed to :) Mihai Oaida <mihai.oaida@gmail.com> 02
  5. 5. Scaling Web Applications Hardware facts Limited context switching Limited opened files Very limited random IO Limited sequential IO Limited RAM Mihai Oaida <mihai.oaida@gmail.com> 03
  6. 6. Scaling Web Applications Scalability vs Performance Scalability how many Performance how fast Scalability + Performance how many and how fast Mihai Oaida <mihai.oaida@gmail.com> 04
  7. 7. Scaling Web Applications Vertical vs Horizontal Vertical Scaling Bigger server 2X capacity != 2x price Horizontal Scaling More identical servers 2X capacity ≈ 2x price Mihai Oaida <mihai.oaida@gmail.com> 05
  8. 8. Scaling Web Applications Benchmarking and Profiling Benchmarking How fast a page loads, under certain conditions Profiling In a page execution, how much time each component consumes Mihai Oaida <mihai.oaida@gmail.com> 06
  9. 9. Scaling Web Applications Benchmarking and Profiling Benchmarking Page / site performance? Page / site scalability ? Profiling What is the bottleneck? Mihai Oaida <mihai.oaida@gmail.com> 07
  10. 10. Scaling Web Applications Benchmarking and Profiling Prepare tests Expect results Run repeatable tests Analyse data Interpret data correctly !!! Mihai Oaida <mihai.oaida@gmail.com> 08
  11. 11. Scaling Web Applications Architecture Web server – dynamic, static content Database server Caching server + load balancer + network equipment Mihai Oaida <mihai.oaida@gmail.com> 09
  12. 12. Scaling Web Applications Static content - HTTP optimization Use Expires and Last-Modified headers Use sprites for images Merge css files Merge js files Use compression – gzip Use multiple subdomains img1.tehnologii-web.ro img2.tehnologii-web.ro Mihai Oaida <mihai.oaida@gmail.com> 10
  13. 13. Scaling Web Applications Static content - Server Use dedicated server(s) just for static Use asynchronous web servers Lighthttpd, nginx Or, Just use a CDN ( Content delivery network ) Mihai Oaida <mihai.oaida@gmail.com> 11
  14. 14. Scaling Web Applications Dynamic content Usually web servers are not the bottleneck Code optimization Use less RAM and less CPU good performance!= good scalability For PHP Opcode cache : xCache, apc, eAccelarator Mihai Oaida <mihai.oaida@gmail.com> 12
  15. 15. Scaling Web Applications Dynamic content Dynamic = 0.x% static + 0.y% dynamic ? Can real-time data have a 5 minute delay ? Batch writes Pre-cache Mihai Oaida <mihai.oaida@gmail.com> 13
  16. 16. Scaling Web Applications Database - general Choose an open-source one that has proven to scale: MySQL :) Use Master – Slave architecture Write on master(s) Read from slaves Mihai Oaida <mihai.oaida@gmail.com> 14
  17. 17. Scaling Web Applications Database Don't run on the default configuration key_buffer, query cache, sort buffer, etc All need tuning as data changes Mihai Oaida <mihai.oaida@gmail.com> 15
  18. 18. Scaling Web Applications Database Use indexes – don't index everything Create very selective indexes, high cardinality Join tables very carefully Denormalize Mihai Oaida <mihai.oaida@gmail.com> 16
  19. 19. Scaling Web Applications Database Optimize queries Use DESCRIBE command Activate slow query log and monitor it! Mihai Oaida <mihai.oaida@gmail.com> 17
  20. 20. Scaling Web Applications Cache - Memcache Asynchronous server No authentication Key value database In memory Very scalable Has api in many languages Small limitations Mihai Oaida <mihai.oaida@gmail.com> 18
  21. 21. Scaling Web Applications Conclusions There is no secret recipe, no easy solution It is very application specific To scale you need not only the right tools but the right thinking! Mihai Oaida <mihai.oaida@gmail.com> 19
  22. 22. Scaling Web Applications Questions? Mihai Oaida <mihai.oaida@gmail.com> 20

×