Planning forperformanceFor web developer, open discussion                Tin@Beijing Open Party
Teachers do not have to   be stronger thanthemselves? Already do  not have as good as        teacher
AgendaBasic programming practiceHardware platformSoftware platformSystem essentialsOptimizationsLoad Balancing
Basic practicesUse proper SCM CVS SVN Mercurial Git
Basic practicesUse a auto-build system Shell scrips Make Ant, Nant Rake
Basic practicesUse a Continues Integration tool So first you need a lot of tests Add auto test, compile job as daily task ...
Basic practicesUse a issue tracker Trac (only svn) Bugzilla, Mantis Bug Tracker Jira Mingle BugFree
Voice from twitterBe sure to test! Be sure to earlier test! Be sureto earlier test! Otherwise, youre dead.Any part test.Pe...
Basic practicesLifecycle control  Develop -> Test -> DeployRelease management  Trunk, Branch, Tag  Milestone, Release cand...
Basic practicesUse Agile methodologies XP practices   TDD   Pair programming Scrum Hybrid agile
Hardware platformUse economical hardware CPU and Memory Disk and disk I/O (Raid) NIC Power and fan 1U 2U 3U 4U ?
Hardware platformBrand Dell, IBM, HP, Lenovo, Asus? Service qualityHardware redundancy Part redundancy Availability and Le...
Network & hostingVPS, 虚拟主机Co-Located Hardware (colo), 主机托管 Bandwidth, Duel lines, air-condition Geo-locationSelf-HostingHo...
Software platformUse pre-compiled OS and softwareChoose a OS CentOS, Redhat, Suse Freebsd Solaris no ubuntu server (from n...
Software platformChoose a language (scriptiing language isbetter) PHP Python Perl Ruby Java Many many many... but not c...
Software platformChoose a database ( or data provider) Mysql Posgresql Big table implementation?
Now, let’s go
System essentialsWeb server Apache Lighthttpd Nginx Tux, Cherokee, Lightspeed Tomcat, Jetty Mongrel, Thin
System essentialsDifferent deployment style (python/ruby) Apache + mod_python (mod_rails, passenger) Fastcgi, SCGI, CGI Pr...
System essentialsMonitoring your system web server logs   Webalizer, Report Magic   Beacon (seperate static file server tr...
System essentialsMonitoring your system Monit (RubyWorks use runit)   Monitoring process status   Auto restart your import...
System essentials Munin & Nagios continues   Munin has server and nodes, it generate   sites to report the statistics of y...
Systemsystem ( Protect your              essentialsManagement is important than tools)   SSH brute attack protection      ...
System essentialsSNA (Share Nothing Architecture) (This isrelative term) All static file and rsync Database centric SNA Me...
System essentialsMake your modules independent Layers, packages Easy to replace module Easy to deploy Easy to profile and ...
Optimizations dynamic content Split your static content and server  Use lightweight web server to server static  contents ...
OptimizationsCaching  Optimize your code (lazy evaluate, cache  result)  Cache and asynchronous update (cron  update)  Tar...
OptimizationsCaching Better client side caching   Use expired header: max-age, expired   E-tag? (Not recommended, IE doesn...
OptimizationsSQL optimizations Add index (especially the column in where closure) De-normalized SQL   Useful redundancy (u...
OptimizationsChoose proper database store engine Mysql: MyISAM? InnoDB? BDB? Heap?Accelerator PHP: APC, Zend Optimizer, XC...
But most important thing:Find out the bottle neckbefore you start tooptimize yourapplication.
Next,  Scaling,If time is enough
What is scaling?Three basics, 简单特性 : 能够使用率的提高 , Useable capacity increasing 能够容纳数据集提高, Data capacity increasing 系统可维护, Mai...
Scaling, 2 waysVertical Scaling  Upgrade your hardware system    More CPU, memory ....Horizontal Scaling  Buy more same ha...
Scaling-Load Balancing DNS-GSLB Use DNS’s round-robin algorithm randomize IP result   xBayDNS Can’t deal with failure (TTL...
Scaling-Load BalancingHardware LB Citrix: Netscalers, Foundry: ServerIron, F5 (4- 7) ExpensiveSoftware LB Perlbal (4), Pou...
Scaling-Load BalancingLayer2, Layer4 and Layer7 LB Layer 2: Link aggregation, provide redundancy and fault tolerance, impr...
Scaling-Load BalancingHuge Scale LB GSLB -> DNS round robin Virtual IP -> L4 or L7 LB (SNAT) Example   Level 1 LB use GSLB...
Scaling-Proxy CacheReverse proxy Squid   Use http head method to validate content   Use memory to cache content - light sp...
Scaling-DatabaseScaling MySQL MySQL replication/duplication (Failure, Lag)   Master/Slave   Tree replication Data partitio...
Scaling-File System Single Disk (Array) Raid 1, Raid 0, Raid5 Partition table type (GPT, MBR) Partition Format (ext2, ext3...
Scaling-File SystemSharingHardware based sharing NAS (previous page)NFS - most simple way to share FSSamba - almost same w...
We are coming a long way, baby
Thanks!
Upcoming SlideShare
Loading in …5
×

Planning for-high-performance-web-application

1,928 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,928
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Planning for-high-performance-web-application

  1. 1. Planning forperformanceFor web developer, open discussion Tin@Beijing Open Party
  2. 2. Teachers do not have to be stronger thanthemselves? Already do not have as good as teacher
  3. 3. AgendaBasic programming practiceHardware platformSoftware platformSystem essentialsOptimizationsLoad Balancing
  4. 4. Basic practicesUse proper SCM CVS SVN Mercurial Git
  5. 5. Basic practicesUse a auto-build system Shell scrips Make Ant, Nant Rake
  6. 6. Basic practicesUse a Continues Integration tool So first you need a lot of tests Add auto test, compile job as daily task Use CI tools to monitor health of your code base CruiseControl, Luntbuild, Continnum, Hudson Cruise, Teamcity, Banboo Use cc-tray, cc-menu desktop widget
  7. 7. Basic practicesUse a issue tracker Trac (only svn) Bugzilla, Mantis Bug Tracker Jira Mingle BugFree
  8. 8. Voice from twitterBe sure to test! Be sure to earlier test! Be sureto earlier test! Otherwise, youre dead.Any part test.Performance testing to be handed over to theuser to do. As makes sense. So to do well log.
  9. 9. Basic practicesLifecycle control Develop -> Test -> DeployRelease management Trunk, Branch, Tag Milestone, Release candicate
  10. 10. Basic practicesUse Agile methodologies XP practices TDD Pair programming Scrum Hybrid agile
  11. 11. Hardware platformUse economical hardware CPU and Memory Disk and disk I/O (Raid) NIC Power and fan 1U 2U 3U 4U ?
  12. 12. Hardware platformBrand Dell, IBM, HP, Lenovo, Asus? Service qualityHardware redundancy Part redundancy Availability and Lead Time (critical parts) Capacity redundancy Future plan?
  13. 13. Network & hostingVPS, 虚拟主机Co-Located Hardware (colo), 主机托管 Bandwidth, Duel lines, air-condition Geo-locationSelf-HostingHow to choose network hardware(switch/router)? Cisco, Huaway, Foundry
  14. 14. Software platformUse pre-compiled OS and softwareChoose a OS CentOS, Redhat, Suse Freebsd Solaris no ubuntu server (from nicholas ding)
  15. 15. Software platformChoose a language (scriptiing language isbetter) PHP Python Perl Ruby Java Many many many... but not c...
  16. 16. Software platformChoose a database ( or data provider) Mysql Posgresql Big table implementation?
  17. 17. Now, let’s go
  18. 18. System essentialsWeb server Apache Lighthttpd Nginx Tux, Cherokee, Lightspeed Tomcat, Jetty Mongrel, Thin
  19. 19. System essentialsDifferent deployment style (python/ruby) Apache + mod_python (mod_rails, passenger) Fastcgi, SCGI, CGI Proxy (Load balancing) + Multi-server instance thread? process?
  20. 20. System essentialsMonitoring your system web server logs Webalizer, Report Magic Beacon (seperate static file server tracker) error log analysis AWStats & Google Analytics
  21. 21. System essentialsMonitoring your system Monit (RubyWorks use runit) Monitoring process status Auto restart your important process Better than cron for monitoring Munin & Nagios Distributed monitoring all of your system Administrator’s eyes, developers friends
  22. 22. System essentials Munin & Nagios continues Munin has server and nodes, it generate sites to report the statistics of your server (in interval) Munin and Nagios and integrate Mem usage, CPU, process, disk usage Service: HTTP, SMTP, POP3, NNTP, Ping Hardware temperature and other datas Network statistics Custom scrips (plugins): db related, user number
  23. 23. Systemsystem ( Protect your essentialsManagement is important than tools) SSH brute attack protection ssh key login blockhost (scripts + pf/iptables) Audit: SELinux... Firewall (port block and audit) Use safe OS? (Netbsd, freebsd) Network safety (but no hardware firewall for websites)
  24. 24. System essentialsSNA (Share Nothing Architecture) (This isrelative term) All static file and rsync Database centric SNA Memcached + db-persistence Server hash, cluster, partition Amazon/Blogger/Cragslist/Facebook/Google /LiveJournal/Slashdot/Wikipedia/Yahoo/YouT ubeSession sticky
  25. 25. System essentialsMake your modules independent Layers, packages Easy to replace module Easy to deploy Easy to profile and make improves
  26. 26. Optimizations dynamic content Split your static content and server Use lightweight web server to server static contents Use different domain to different server Caching Memcached Query result, domain objects, sessions Page tiles, template tiles Everything that you need
  27. 27. OptimizationsCaching Optimize your code (lazy evaluate, cache result) Cache and asynchronous update (cron update) Target, the hit rate of 90% or more ! Target 90%+ But cache invalidation is a critical problem! Asynchronous messaging make sure cache validate No blocking!
  28. 28. OptimizationsCaching Better client side caching Use expired header: max-age, expired E-tag? (Not recommended, IE doesn’t support it) Use HEAD method and 301 to detect changes (for squid or other proxy scenarios) Compress (contact js, css)
  29. 29. OptimizationsSQL optimizations Add index (especially the column in where closure) De-normalized SQL Useful redundancy (use duplication avoid join) Don’t relay on ORM. No matter Data- mapper/Active Record/Unit Of Work Don’t use full-text search Use seperate search engine module (lucene)
  30. 30. OptimizationsChoose proper database store engine Mysql: MyISAM? InnoDB? BDB? Heap?Accelerator PHP: APC, Zend Optimizer, XCache, eAccelerator, ionCube PHP Accelerator, Turck MMCache Python: psyco Ruby: Joyent accelerator
  31. 31. But most important thing:Find out the bottle neckbefore you start tooptimize yourapplication.
  32. 32. Next, Scaling,If time is enough
  33. 33. What is scaling?Three basics, 简单特性 : 能够使用率的提高 , Useable capacity increasing 能够容纳数据集提高, Data capacity increasing 系统可维护, Maintainable
  34. 34. Scaling, 2 waysVertical Scaling Upgrade your hardware system More CPU, memory ....Horizontal Scaling Buy more same hardware, deploy more server instance Distributed your system But this way need you modify your code (generally)
  35. 35. Scaling-Load Balancing DNS-GSLB Use DNS’s round-robin algorithm randomize IP result xBayDNS Can’t deal with failure (TTL) Hard to do accurate managementCDN content delivery network transparent service provide by some company expansive, and not suitable for dynamic content
  36. 36. Scaling-Load BalancingHardware LB Citrix: Netscalers, Foundry: ServerIron, F5 (4- 7) ExpensiveSoftware LB Perlbal (4), Pound (7) LVS (4)
  37. 37. Scaling-Load BalancingLayer2, Layer4 and Layer7 LB Layer 2: Link aggregation, provide redundancy and fault tolerance, improve access speed Layer 4: round-robin on TCP (with port info) Layer 7 Session sticky enalbed Easy to write complicate hash logic Good for Squid (Squid cluster enabled)
  38. 38. Scaling-Load BalancingHuge Scale LB GSLB -> DNS round robin Virtual IP -> L4 or L7 LB (SNAT) Example Level 1 LB use GSLB give geo-located DNS result VIP is dispatched by F5 F5 -> Squid, reverse proxy Squid delegate real dynamic or static server
  39. 39. Scaling-Proxy CacheReverse proxy Squid Use http head method to validate content Use memory to cache content - light speed Mature, fast, industry standard
  40. 40. Scaling-DatabaseScaling MySQL MySQL replication/duplication (Failure, Lag) Master/Slave Tree replication Data partition MySQL proxy Data shard
  41. 41. Scaling-File System Single Disk (Array) Raid 1, Raid 0, Raid5 Partition table type (GPT, MBR) Partition Format (ext2, ext3, resierfs, XFS, ZFS)Cluster Single Disk has limitation, but Cluster has no limit NetApp Filer (NAS - Network-attached storage) Many many choices
  42. 42. Scaling-File SystemSharingHardware based sharing NAS (previous page)NFS - most simple way to share FSSamba - almost same with NFS, nice to tryMogileFS (for web, no cursor based randomaccess)GFS, Hadoop FS (chunk based)
  43. 43. We are coming a long way, baby
  44. 44. Thanks!

×