scalability performance
play

Scalability + Performance a choose your own adventure game hosted - PowerPoint PPT Presentation

Scalability + Performance a choose your own adventure game hosted by James Cox 1 Tuesday, 1 April 2008 1 Begin Your Adventure... Art & The End Planning Hosting & Deployment Ruby & Rails Caching Testing MySQL 2 Tuesday,


  1. Scalability + Performance a choose your own adventure game hosted by James Cox 1 Tuesday, 1 April 2008 1

  2. Begin Your Adventure... Art & The End Planning Hosting & Deployment Ruby & Rails Caching Testing MySQL 2 Tuesday, 1 April 2008 2

  3. OH NOES! IZ DIS BROKE? 3 Tuesday, 1 April 2008 3

  4. Scalability is an artform “EVERYTHING takes time. No amount of super fast assembler based multiplexed evented code will get around that” “I'm not saying don't try to make it fast. What I'm saying is first thing programmers do is they run off with faulty statistics to "tune" their system, completely ignoring the fact that many times a simple redesign (or complex improvement) can just eliminate the problem entirely. “ “If you can’t make the computer fast, trick the people to think it’s fast” 4 Tuesday, 1 April 2008 4

  5. Scalability is an artform There are no easy answers. ... except maybe this: measure, refactor. measure, refactor. measure, refactor. 5 Tuesday, 1 April 2008 5

  6. Scalability is an artform Planning helps! back to the map 6 Tuesday, 1 April 2008 6

  7. MySQL: Built To Perform mysql> \s mysql> \s Threads: 3, Questions: 10,171,505, Slow queries: 334, Threads: 3, Questions: 10,171,505, Slow queries: 334, Opens: 224, Flush tables: 1, Open tables: 106 Opens: 224, Flush tables: 1, Open tables: 106 Queries per second (average): 277.1 Queries per second (average): 277.1 Uptime: 10 hours 11 min 47 sec Uptime: 10 hours 11 min 47 sec 7 Tuesday, 1 April 2008 7

  8. MySQL: Built To Perform Ditch the query cache. It doesn’t help you like you think. Ditch the query cache. It doesn’t help you like you think. Become best friends with the various table engines - Become best friends with the various table engines - InnoDB, MyISAM, NBD, etc. InnoDB, MyISAM, NBD, etc. Watch the process list. Hawk like. Watch the process list. Hawk like. Know which queries hurt.. Know which queries hurt.. 8 Tuesday, 1 April 2008 8

  9. MySQL: Built To Perform Some key variables to tune: Some key variables to tune: max_allowed_packet & key_buffer_size max_allowed_packet & key_buffer_size (keeps your index quicksort from chunking) (keeps your index quicksort from chunking) Care about wait_timeout , net_write_timeout , net_read_timeout and max_connections if you use networked db servers Consider ditching ActiveRecord Consider ditching ActiveRecord back to the map 9 Tuesday, 1 April 2008 9

  10. Caching: how to fi x nearly everything This really defines 80/20. This really defines 80/20. There are few scenarios which are truly uncacheable. There are few scenarios which are truly uncacheable. Memcached is the defacto tool, and cache_fu is the Memcached is the defacto tool, and cache_fu is the best way in. best way in. memcache is your friend... memcache is your friend... ... learn to love it like it loves you. ... learn to love it like it loves you. :) e x c e p t o n j r u b y 10 Tuesday, 1 April 2008 10

  11. Caching: how to fi x nearly everything be wary of over-reliance on memcache. be wary of over-reliance on memcache. Facebook runs over 200gb of memcache - twitter Facebook runs over 200gb of memcache - twitter consumes about 40gb. consumes about 40gb. restarting your cache is slow.... restarting your cache is slow.... so find ways to mitigate a cold cache. so find ways to mitigate a cold cache. 11 Tuesday, 1 April 2008 11

  12. Caching: how to fi x nearly everything File I/O lets you down almost all the time. File I/O lets you down almost all the time. NFS is not as bad as it used to be. NFS is not as bad as it used to be. Consider offloading to s3 - it’s not as expensive Consider offloading to s3 - it’s not as expensive as you think. as you think. or, if you have money, buy a blade or, if you have money, buy a blade center, SAN or NAS. center, SAN or NAS. back to the map 12 Tuesday, 1 April 2008 12

  13. Deployment: get it out there for real Going alone? That’s ok. Here’s a rough guide... Going alone? That’s ok. Here’s a rough guide... web/proxy + static (2) app layer (4) data stores (2) web: nginx, thin, rack app: mongrel, glassfish, swiftiply db: MySQL, SDB, PostgreSQL 13 Tuesday, 1 April 2008 13

  14. Deployment: get it out there for real Got cash? Make it someone else’s problem. back to the map 14 Tuesday, 1 April 2008 14

  15. Rails: can be monkey patched Don’t be afraid to improve it Don’t be afraid to improve it But follow edge if you do. But follow edge if you do. 15 Tuesday, 1 April 2008 15

  16. Rails: can be monkey patched ActiveRecord: ActiveRecord: Take only what you need. :select, :limit, :offset Take only what you need. :select, :limit, :offset Eagerly associate with :include => :association Eagerly associate with :include => :association @var ||= Model.find(...) 16 Tuesday, 1 April 2008 16

  17. Rails: can be monkey patched Views & Controllers: Views & Controllers: Use HTML helpers sparingly (url_for, etc) Use HTML helpers sparingly (url_for, etc) Consider template optimization Consider template optimization Know how your rendering engine works. 17 Tuesday, 1 April 2008 17

  18. Ruby: can be monkey patched too Meta programming monkey patching Meta programming monkey patching Class String def new_behavior ... end end Don’t forget constants and class variables Don’t forget constants and class variables back to the map 18 Tuesday, 1 April 2008 18

  19. Testing: verify your performance Be sure that your performance is what you think it is. Be sure that your performance is what you think it is. Measure: response times, concurrent reqs & server load. Measure: response times, concurrent reqs & server load. Look for a tight standard deviation in requests. Look for a tight standard deviation in requests. Keep asking users: “What’s Slow?” Keep asking users: “What’s Slow?” tools: httperf, ab, flood, your brain. back to the map 19 Tuesday, 1 April 2008 19

  20. The end: thanks for not sleeping need more? email james@smokeclouds.com need more? email james@smokeclouds.com will code for trips to cool places. :) will code for trips to cool places. :) interactive deck at http://media.imaj.es/scale/ interactive deck at http://media.imaj.es/scale/ colophon: font: vag rounded, metabook art: iStockPhoto, ryan putnam + spotblind back to the map 20 Tuesday, 1 April 2008 20

Recommend


More recommend