• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Beyond 'gem install MySQL’ in Ruby
 

Beyond 'gem install MySQL’ in Ruby

on

  • 20,988 views

There is much more to MySQL performance in Ruby than ‘gem install mysql’ and syntactic optimizations. Whether you are running Ruby MRI (C version), or JRuby (JVM), or any other Ruby VM, and are ...

There is much more to MySQL performance in Ruby than ‘gem install mysql’ and syntactic optimizations. Whether you are running Ruby MRI (C version), or JRuby (JVM), or any other Ruby VM, and are looking to optimize your performance architecture (response times or throughput), the architecture and the MySQL driver you choose (yes, there is more than one!) have significant influence on the outcome. Different VM’s expose different behaviors: native threads vs. green threads, a global interpreter lock (GIL) vs. no lock, and result in dramatically different behaviors under load.

In this talk we will look under the hood of the most popular Ruby VM’s and evaluate a number of alternative drivers (mysql gem, mysqlplus, evented-mysql, and others), which can help you significantly improve the performance and throughput of your Ruby+MySQL application.

Statistics

Views

Total Views
20,988
Views on SlideShare
12,870
Embed Views
8,118

Actions

Likes
19
Downloads
104
Comments
2

36 Embeds 8,118

http://www.igvita.com 7738
http://www.slideshare.net 156
http://teamco-anthill.blogspot.com 75
https://www.igvita.com 33
http://bgror.com 12
http://static.slidesharecdn.com 11
http://www.igvita.com.sharedcopy.com 11
http://coderwall.com 8
http://localhost 8
http://teamco-anthill.blogspot.fr 7
http://teamco-anthill.blogspot.co.uk 7
http://lanyrd.com 6
http://teamco-anthill.blogspot.in 4
http://teamco-anthill.blogspot.jp 3
http://teamco-anthill.blogspot.ru 3
http://teamco-anthill.blogspot.com.es 3
http://translate.googleusercontent.com 3
http://feeds.igvita.com 3
http://teamco-anthill.blogspot.de 3
http://webcache.googleusercontent.com 3
http://teamco-anthill.blogspot.pt 2
http://teamco-anthill.blogspot.it 2
http://www.techgig.com 2
http://teamco-anthill.blogspot.com.au 2
http://www.lmodules.com 2
http://teamco-anthill.blogspot.ie 1
http://teamco-anthill.blogspot.hu 1
http://teamco-anthill.blogspot.cz 1
http://teamco-anthill.blogspot.co.il 1
https://twitter.com 1
http://teamco-anthill.blogspot.ch 1
http://teamco-anthill.blogspot.be 1
http://teamco-anthill.blogspot.com.br 1
http://teamco-anthill.blogspot.ca 1
http://apps.matharvard.ca 1
http://teamco-anthill.blogspot.tw 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Useful insights and available options
    Are you sure you want to
    Your message goes here
    Processing…
  • Blog post: http://www.igvita.com/2010/04/15/non-blocking-activerecord-rails/

    Original PPTX: http://github.com/igrigorik/presentations/tree/master/2010-MySQLConf/

    (Slideshare seems to break the whitespace in code examples (doh))
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • To understand what's going on, we need to take a closer look at the Ruby runtime. Whenever you launch a Ruby application, an instance of a Ruby interpreter is launched to parse your code, build an AST tree, and then execute the application you've requested - thankfully, all of this is transparent to the user. However, as part of this runtime, the interpreter also instantiates an instance of a Global Interpreter Lock (or more affectionately known as GIL), which is the culprit of our lack of concurrency:
  • Thread non-blocking region in Ruby 1.9With right driver architecture can block OS thread but VM will continue
  • rb_thread_select() on the mysql connection's file descriptor, effectively putting that thread in a WAIT_SELECT and letting other threads run until the query's results are available.
  • https://gist.github.com/raw/61762/4d0ba698aa868a7dbd04678c0fa37a7a60201dbf/gistfile1.txt
  • rb_thread_select() on the mysql connection's file descriptor, effectively putting that thread in a WAIT_SELECT and letting other threads run until the query's results are available.
  • While jruby is able to take advantage of Java's native threading, if you are running Rails ver < 2.2 which is not thread-safe, and thus cannot benefit from it. Glassfish provides a jruby runtime pool to allow servicing of multiple concurrent requests. Each runtime runs a single instance of Rails, and requests are handed off to whichever one happens to be available at the time of the request.The dynamic pool will maintain itself with the minimum number of runtimes possible to allow consistent, fast runtime access for the requesting application between its min and max. It also may take an initial number of runtimes, but that value is not used after pool creation in any way.
  • The reactor design pattern is a concurrent programming pattern for handling service requests delivered concurrently to a service handler by one or more inputs. The service handler then demultiplexes the incoming requests and dispatches them synchronously to the associated request handlers.
  • coroutines
  • coroutines
  • coroutines
  • coroutines
  • coroutines
  • coroutines

Beyond 'gem install MySQL’ in Ruby Beyond 'gem install MySQL’ in Ruby Presentation Transcript