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

scalability performance
SMART_READER_LITE
LIVE PREVIEW

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,


slide-1
SLIDE 1

1

Scalability + Performance

a choose your own adventure game hosted by James Cox

1 Tuesday, 1 April 2008

slide-2
SLIDE 2

2

Begin Your Adventure... MySQL Caching Art & Planning Hosting & Deployment Testing The End Ruby & Rails

2 Tuesday, 1 April 2008

slide-3
SLIDE 3

3

OH NOES!

IZ DIS BROKE?

3 Tuesday, 1 April 2008

slide-4
SLIDE 4

4

Scalability is an artform

“EVERYTHING takes time. No amount of super fast assembler based multiplexed evented code will get around that” “If you can’t make the computer fast, trick the people to think it’s fast”

“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. “

4 Tuesday, 1 April 2008

slide-5
SLIDE 5

5

Scalability is an artform

There are no easy answers. ... except maybe this: measure, refactor.

measure, refactor.

measure, refactor.

5 Tuesday, 1 April 2008

slide-6
SLIDE 6

6

Scalability is an artform

Planning helps!

back to the map

6 Tuesday, 1 April 2008

slide-7
SLIDE 7

mysql> \s Threads: 3, Questions: 10,171,505, Slow queries: 334, Opens: 224, Flush tables: 1, Open tables: 106 Queries per second (average): 277.1 Uptime: 10 hours 11 min 47 sec

7

mysql> \s Threads: 3, Questions: 10,171,505, Slow queries: 334, Opens: 224, Flush tables: 1, Open tables: 106 Queries per second (average): 277.1 Uptime: 10 hours 11 min 47 sec

MySQL: Built To Perform

7 Tuesday, 1 April 2008

slide-8
SLIDE 8

Ditch the query cache. It doesn’t help you like you think. Become best friends with the various table engines - InnoDB, MyISAM, NBD, etc. Watch the process list. Hawk like. Know which queries hurt..

8

Ditch the query cache. It doesn’t help you like you think. Become best friends with the various table engines - InnoDB, MyISAM, NBD, etc. Watch the process list. Hawk like. Know which queries hurt..

MySQL: Built To Perform

8 Tuesday, 1 April 2008

slide-9
SLIDE 9

Some key variables to tune: max_allowed_packet & key_buffer_size (keeps your index quicksort from chunking) Consider ditching ActiveRecord

9

Some key variables to tune: max_allowed_packet & key_buffer_size (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

MySQL: Built To Perform

back to the map

9 Tuesday, 1 April 2008

slide-10
SLIDE 10

This really defines 80/20. There are few scenarios which are truly uncacheable. Memcached is the defacto tool, and cache_fu is the best way in.

10

This really defines 80/20. There are few scenarios which are truly uncacheable. Memcached is the defacto tool, and cache_fu is the best way in.

Caching: how to fix nearly everything

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

  • n

j r u b y

10 Tuesday, 1 April 2008

slide-11
SLIDE 11

be wary of over-reliance on memcache. Facebook runs over 200gb of memcache - twitter consumes about 40gb.

11

be wary of over-reliance on memcache. Facebook runs over 200gb of memcache - twitter consumes about 40gb.

Caching: how to fix nearly everything

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

slide-12
SLIDE 12

File I/O lets you down almost all the time. NFS is not as bad as it used to be.

12

File I/O lets you down almost all the time. NFS is not as bad as it used to be.

Caching: how to fix nearly everything

back to the map

Consider offloading to s3 - it’s not as expensive as you think. Consider offloading to s3 - it’s not as expensive as you think.

  • r, if you have money, buy a blade

center, SAN or NAS.

  • r, if you have money, buy a blade

center, SAN or NAS.

12 Tuesday, 1 April 2008

slide-13
SLIDE 13

Going alone? That’s ok. Here’s a rough guide...

13

Going alone? That’s ok. Here’s a rough guide...

Deployment: get it out there for real

web: nginx, thin, rack app: mongrel, glassfish, swiftiply db: MySQL, SDB, PostgreSQL

web/proxy + static (2) app layer (4) data stores (2)

13 Tuesday, 1 April 2008

slide-14
SLIDE 14

14

Deployment: get it out there for real

back to the map

Got cash? Make it someone else’s problem.

14 Tuesday, 1 April 2008

slide-15
SLIDE 15

Don’t be afraid to improve it But follow edge if you do.

15

Don’t be afraid to improve it But follow edge if you do.

Rails: can be monkey patched

15 Tuesday, 1 April 2008

slide-16
SLIDE 16

ActiveRecord: Take only what you need. :select, :limit, :offset

16

ActiveRecord: Take only what you need. :select, :limit, :offset

Rails: can be monkey patched

Eagerly associate with :include => :association Eagerly associate with :include => :association @var ||= Model.find(...)

16 Tuesday, 1 April 2008

slide-17
SLIDE 17

Views & Controllers: Use HTML helpers sparingly (url_for, etc)

17

Views & Controllers: Use HTML helpers sparingly (url_for, etc)

Rails: can be monkey patched

Consider template optimization Consider template optimization Know how your rendering engine works.

17 Tuesday, 1 April 2008

slide-18
SLIDE 18

Meta programming monkey patching

18

Meta programming monkey patching Class String def new_behavior ... end end

Ruby: can be monkey patched too

back to the map

Don’t forget constants and class variables Don’t forget constants and class variables

18 Tuesday, 1 April 2008

slide-19
SLIDE 19

Be sure that your performance is what you think it is. Measure: response times, concurrent reqs & server load.

19

Be sure that your performance is what you think it is. Measure: response times, concurrent reqs & server load.

Testing: verify your performance

back to the map

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.

19 Tuesday, 1 April 2008

slide-20
SLIDE 20

need more? email james@smokeclouds.com will code for trips to cool places. :)

20

need more? email james@smokeclouds.com will code for trips to cool places. :)

The end: thanks for not sleeping

back to the map

colophon: font: vag rounded, metabook art: iStockPhoto, ryan putnam + spotblind

interactive deck at http://media.imaj.es/scale/ interactive deck at http://media.imaj.es/scale/

20 Tuesday, 1 April 2008