Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or...

39
Concurrency How I Learned to Love the ‘stache Chris Williams ( voodootikigod ) Iterative Designs + NoVA Languages (come and learn, but we don’t offer credit) telnet 10.10.20.99 1337

Transcript of Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or...

Page 1: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

ConcurrencyHow I Learned to Love the ‘stache

Chris Williams (voodootikigod)

Iterative Designs + NoVA Languages (come and learn, but we don’t offer credit)

telnet 10.10.20.99 1337

Page 2: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Warning: YOUR MIND MIGHT BE BLOWN BACKWe cannot be held responsible for the effects of this presentation on your general view of the world

There will be no AJL or BP Pics, if that disappoints you, better leave now because so will the rest of the talk.

Page 3: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

A little poll

Page 4: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

PhD, MS, BS =~ Computer

Page 5: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

I was a “business” major

Page 6: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

eff this guy asking about degrees, I learned about the intertubes on the streets.

Page 7: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Honesty QuestionRails/Ruby/Merb makes me like a

schoolgirl near Michael Phelps?

put ‘em up, don’t be afraid; well unless you are afraid, then sorry for calling you out

Page 8: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Concurrency FW TT WF ?!

“..several computational processes are executing at the same time, and potentially interacting with each other.” - thx wikipedia

Page 9: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

ConcurrencyI get to use every single processor in my computer... or every computer I have access to...

=> game on

Page 10: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Now an example...Notice the two processors,Notice the two processes,Can you guess the results?

Vintage

Page 11: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

So concurrency is as easy as drinking beer with a girl?

Page 12: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Concurrency is hardDon’t just believe this guy... it really is...

Deadlock

Watchdog timers

Timeouts

Synchronization

Locking

Race Conditions

Fault Tolerance

Execution

Spawning

Monitoring

Thrashing

IPC

Page 13: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Concurrent Speak

Threads

Green Threads

Native Threads

Processes

Process

Lightweight Process

Green Process

Page 14: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Sharing is not CaringAt least in the multi-tasking world

Page 15: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Ruby + Concurrency

Page 16: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

What’s on your laptops MRI <= 1.8Green is only good for Stoplights, Limes, and Guacamole

definitely not spandex

Page 17: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

What will be on your laptopsMRI >= 1.9True Native Threading FTW

Fibers

Page 18: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Matz Can’t PatchSong available via Creative Commons

Zed Shaw

Page 19: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Rails on teh Rubyrails --version <= Rails 2.1.0 //get in line

Rails of Tomorrow // no more single threaded

// thx Josh Peek

Page 20: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Aside from being a flashback to CS 304How does this <expletive>ing information apply to anything I, soon to be social networking rockstar code pimp, am doing?

Page 21: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Hosting

Apache/Nginx

Mongrel

Thin

Ebb

Passenger

the new hotness

Glassfish

LOLCATS picture has beenremoved at the request of

maintaining some resemblanceof maturity

-- chris’s wife

ur doing it rong

Page 22: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Magic + Magic = ??

Page 23: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Unicorn???btw shout out to the unicorn centre for keeping the dream alive; without you the internet would just be normal

Page 24: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Fail Whalebut why?

Page 25: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

CONCURRENCYConcurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming problems since we first hooked up one computer to another.

Your objects can’t save you.

Page 26: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Get to the mustache already Lisp will save your programming soul

Concurrent Oriented Programming

+ Functional Programming

-----------------------------------------------------

Page 27: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Scala is another option, FYI

Page 28: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

ErlangMassively Concurrent

Massively Scalable

Crowd ! {main_message, “LISTEN”}

No Variables, No Sharing, No Side Effects

Page 29: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

What are you talking about?Erlang is on the radar with CouchDB, Facebook, IMDB, ejabberd, Amazon, and tonight’s telchat

Page 30: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Fuzedhttp://fuzed.rubyforge.org/

http://github.com/KirinDave/fuzed/tree/master

Rails on Yaws or Ride the Erlang Express

Page 31: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Fuzed on EC2Single command replication and server spin up/spin down.

Fault Tolerant (except when EC2 goes down)

http://jointheconversation.org/2008/06/06/fuzed-and-ec2/

Page 32: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Now is the time, this is the placeThe rise in Multi-core machines

The rise in information processing

The rise in networked computing devicesAll hail skynet

and you are still using only one thread?!??!?!?

Page 33: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Key PointsSo wake up the person next to you, please.

Page 34: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Learn something newThen apply it to what you are doing and teach it someone else

side project

Page 35: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

DRY your knowledgeI am building this cool thing, its round and I am thinking about calling it the wheel, you want to help?

Page 36: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

Stand on GiantsMost times you can see farther than anyone else

Page 37: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

NoVA LanguagesMeeting every Monday

erlang:out event, September 20th 9am - 6pm

Page 38: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

thread death“... for the first time in history, no one is building a much faster sequential processor. If you want your program to run significantly faster, say, to justify the addition of new features, you’re going to have to parallelize your program”

Hennessy and Patterson “Computer Architectures” (4th edition)

Page 39: Concurrency - Amazon S3s3.amazonaws.com/iterativedesigns/Concurrency.pdfCONCURRENCY Concurrency, or more appropriately lack of concurrency, is the reason for nearly all major programming

you ! {code, telchat}http://github.com/voodootikigod/telchat/

make

make run

> telchat:start().