SlideShare une entreprise Scribd logo
1  sur  192
Télécharger pour lire hors ligne
Scaling a Rails Application
   from the Bottom Up
      Jason Ho man PhD, CTO, Joyent
             Rails Conf 2007
          Thursday, May 17, 2007
Today’s schedule
830am
                              I
                 50
                             II
 920am
 930am
                             III
                 50
                             IV
 1020am
 1030am
                             V
                 50
1130am                       VI
Hi, I’m Jason
What did they get me into?




5/2003                  9/2005
            5/2004
         “it” started
6 Acts

I. Introduction and foundational items
II. Where do I put stu ?
III. What stu ?
IV. What do I run on this stu ?
V. What are the patterns of deployment?
VI. Lessons learned
What I’ll tell you about


‣   What we’ve done
‣   Why we’ve done it
‣   How we’re doing it
‣   Our way of thinking
Simple
Standard
  Open
Fundamental Limits
Fundamental Limits

‣   Money
Fundamental Limits

‣   Money
‣   Time
Fundamental Limits

‣   Money
‣   Time
‣   People
Fundamental Limits

‣   Money
‣   Time
‣   People
‣   Experience
Fundamental Limits

‣   Money
‣   Time
‣   People
‣   Experience
‣   Power (which limits memory and CPU)
Fundamental Limits

‣   Money
‣   Time
‣   People
‣   Experience
‣   Power (which limits memory and CPU)
‣   Bandwidth
Some of Joyent’s
Introduction and
Foundational Items
I get asked lots of questions
‣   “I have yet to find any examples of websites
    that have heavy tra c and stream media that
    run from a Ruby on Rails platform, can you
    suggest any sites that will demonstrate that the
    ruby platform is stable and reliable enough to
    use on a commercial level?”
‣   “We are concerned about the long-term viability
    of Ruby on Rails as a development language
    and environment.”
‣   “How easily can a ruby site be converted to
    another language? (If for any reason we were
    forced to abandon ruby at some point in the
    future or I can’t find someone to work with our
    code?).”
‣   “My company has some concerns on whether
    or not Ruby on Rails is the right platform to
    deploy on if we have a very large scale app.”
‣   What is a “scalable” application?
‣   What are some hardware layouts?

‣   Where do you get the hardware?
‣   How do you pay for it?
‣   Where do you put it?
‣   Who runs it?

‣   How do you watch it?
‣   What do you need relative to an application?
‣   What are the commonalities of scalable web architectures?
‣   What are the unique bottlenecks for Ruby on Rails applications?
‣   What's the best way to start so you can make sure everything scales?

‣   What are the common mistakes?
But are these really Ruby or Rails
            specific ?
They have to do with designing
  and then running scalable
   “internet” applications
But the road to a top site on the
    internet is not from one
           interation
Let’s break that down


‣   Designing
‣   Running
‣   Scalable
‣   “Internet” applications
Scalable means?
A Sysadmin’s view

‣   Ruby on Rails is simply one part
‣   Developers have to understand Rails
    horizontally (of course, otherwise they couldn’t
    write the application)
‣   Developers ideally understand the vertical stack
‣   It can get complicated fast and it’s easy to
    overengineer
What do you do with
 1000s of physical machines?
    100s of TB of storage?
In 4 facilities on 2 continents?
Is this a “Rails” issue?
No, I’m afraid not.
This has been done before.

 The same big questions.
Let’s take the “connector”
“Logical” servers for the connector
 1) Jumpstart/PXE Boot
 2) Monitoring
 3) Auditing
 4) Logging
 5) Provisioning and configuration management
 6) DHCP/LDAP for server identification/authentication and control (at dual for failover)
 7) DNS: DNS cache and resolver, and a (private) DNS system (4x + 2; 2+ sites)
 8) DNS MySQL (4x + 2, dual masters with slaves per DNS node, innodb tables)
 9) SPAM filtering servers (files to NFS store and tracking to postgresql)
 10) SPAM database setup (postgresql)
 11) SPAM NFS store
 12) SMTP proxies and gateways out
 13) SMTP proxies and gateways in (delivery to clusters to Maildir over NFS)
 14) Mail stores
 15) IMAP proxy servers
 16) IMAP servers
 17) User LDAP servers
 18) User long running processes
 19) User postgresql DB servers
 20) User web servers
 21) User application servers
 22) User File Storage (NFS)
 23) Joyent Organization Provisioning/Customer panel servers (web, app, database)
 24) iSCSI storage systems
 25) Chat servers
 26) Load balancer/proxies/static caches
 ...
Guess which is “Rails”?
Ease of management is on a log scale

‣   10
‣   100
‣   1,000
‣   10,000
‣   100,000
‣   1,000,000
Amps, Volts and Watts

‣   110V and 208V
‣   15, 20, 30, 60 amp
‣   $25 per amp for 208V power
‣   20 amps X 208V = 4160 watts
‣   80% safely usable = 3328 watts
A $5000 Dell 1850 costs $1850 to
       power over a 3 year lifespan

‣   440watts x 24 hours/day x 1 kw/1000 watts =
    10.56 kwh/day
‣   10.56 kwh/day x $0.16/kwh = $1.69/day
‣   $1.69/day x 365 days/year = 616.85/year
How many servers fit in a 100kw?


‣   100 kilowatts to power and 100 kilowatts to cool
‣   At 250-400 watts each
‣   250 - 400 servers
Other common limiting factors
Where do I put stuff?
   What stuff?
Physical considerations
‣   Space
‣   Power
‣   Network connection
‣   Cables cables cables
‣   Routers and switches
‣   Servers
‣   Storage
The 10% rule

‣   Google’s earning release:
‣   quot;Other cost of revenues, which is comprised
    primarily of data center operational expenses,
    as well as credit card processing charges,
    increased to $307 million, or 10% of revenues,
    in the fourth quarter of 2006, compared to
    $223 million, or 8% of revenues, in the third
    quarter.quot;
The 10% rule


‣   A common rule of thumb I tell people is to
    target their performance goals in application
    design and coding so that their infrastructure
    (not including people) is ≤10% of an application’s
    revenue.
The 10% rule
‣   Meaning if you’re making $1.2 million dollars a
    year o of an online application, then you
    should be in area of spending $120,000/year or
    $10,000/month on servers, storage and
    bandwidth.
‣   And from the other way around, if you’re
    spending $10,000 a month on these same
    things, then you know where to push your
    revenue to.
Or maybe this is just a cost.
    It used to be for me.
A joyent.net node (-ish)
Whatever you do


‣   Keep it simple
‣   Standardize, Standardize, Standardize
‣   Try and use open technologies
Some of my rules
‣   Virtualization, virtualization, virtualization
‣   Separating hardware components
‣   Keep the hardware setup simple
‣   Things should add up
‣   Configuration management and distributed
    control
‣   Pool and split
‣   Understand what each component can do as a
    maximum and a minimum
Pairing physical resources with
logical needs while keeping the
       smallest footprint
You either build or you buy it
Or you buy all of it from someone
               else
Then You Build
“Buying”
(by the way)
   means
“using Rails”
     too
What’s the cost breakpoints?


‣   Including people costs
‣   It’s generally cheaper at the $20,000-$30,000/
    month spending to do it in-house. *Assuming
    you or at least one of your guys knows what
    they’re doing.
But what if I buy all my stuff from
        someone else?
Our story
The Planet
Cee-Kay
KISS

  One kind of
  Console server
  Switch
  Server
  CPU
  RAM
  Storage
  Disc
  Operating system
  Interconnect
  Power plug
  Power strip
Our Choices
Our Choices
Console server => Lantronix
‣
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC

‣RAM => 2GB DIMMS
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC

‣RAM => 2GB DIMMS

‣Storage => Sun Fire X4500 and NetApp FAS filters
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC

‣RAM => 2GB DIMMS

‣Storage => Sun Fire X4500 and NetApp FAS filters

‣Disc => 500GB SATA and 73GB/146GB SAS
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC

‣RAM => 2GB DIMMS

‣Storage => Sun Fire X4500 and NetApp FAS filters

‣Disc => 500GB SATA and 73GB/146GB SAS

‣Operating system => Solaris Nevada (“11”)
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC

‣RAM => 2GB DIMMS

‣Storage => Sun Fire X4500 and NetApp FAS filters

‣Disc => 500GB SATA and 73GB/146GB SAS

‣Operating system => Solaris Nevada (“11”)

‣Interconnect => gigabit with cat6 cables
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC

‣RAM => 2GB DIMMS

‣Storage => Sun Fire X4500 and NetApp FAS filters

‣Disc => 500GB SATA and 73GB/146GB SAS

‣Operating system => Solaris Nevada (“11”)

‣Interconnect => gigabit with cat6 cables

‣Power plug => 208V, L6-20R (the “wall”), IEC320-C14 to IEC320-

C13 (server to PDU)
Our Choices
 Console server => Lantronix
‣

‣Switch => 48 port all gigabit (Force10 E300s)

‣Server => Sun Fire AMDs (X4100,X4600), T1000s

‣CPU => Opteron 285 and T1 SPARC

‣RAM => 2GB DIMMS

‣Storage => Sun Fire X4500 and NetApp FAS filters

‣Disc => 500GB SATA and 73GB/146GB SAS

‣Operating system => Solaris Nevada (“11”)

‣Interconnect => gigabit with cat6 cables

‣Power plug => 208V, L6-20R (the “wall”), IEC320-C14 to IEC320-

C13 (server to PDU)
‣Power strip => APC 208V, 20x
I/O
* Flat network                      Storage
* Physically segregated




        Remote             Public   Interconnects
Cabling standard


                    3’ cat6
         Public network
         Private interconnects
         Storage
         Storage
         ALOM => console servers
         Switch interconnects and mesh
Our “SAN”
                              RAIDZ2


                              RAIDZ2


                              RAIDZ2



RAIDZ2+1                      RAIDZ2



                              RAIDZ2
             Patent backups
Our “SAN”
                                                    RAIDZ2


                                                    RAIDZ2


                                                    RAIDZ2



RAIDZ2+1                                            RAIDZ2



                                                    RAIDZ2
                                   Patent backups




 ‣   Think of it as a distributed RAID6+1
Our “SAN”
                                                    RAIDZ2


                                                    RAIDZ2


                                                    RAIDZ2



RAIDZ2+1                                            RAIDZ2



                                                    RAIDZ2
                                   Patent backups




 ‣   Think of it as a distributed RAID6+1
 ‣   Dual switched
Our “SAN”
                                                   RAIDZ2


                                                   RAIDZ2


                                                   RAIDZ2



RAIDZ2+1                                           RAIDZ2



                                                   RAIDZ2
                                  Patent backups




 ‣   Think of it as a distributed RAID6+1
 ‣   Dual switched
 ‣   Able to turn o half of your storage units
Our “SAN”
                                                   RAIDZ2


                                                   RAIDZ2


                                                   RAIDZ2



RAIDZ2+1                                           RAIDZ2



                                                   RAIDZ2
                                  Patent backups




 ‣   Think of it as a distributed RAID6+1
 ‣   Dual switched
 ‣   Able to turn o half of your storage units
 ‣   You end up having data stripped across 44, 88, 132, 196 drives
Vendors


‣   Networking: Dell, HP, Force10, Cisco, Foundry
‣   Servers: Dell, HP, Sun
‣   Storage: Dell, HP, Sun, NetApp, Nexsan
Servers


‣   Dell: 1850 and 2850 models
‣   HP: DL320s
‣   Sun: X2100 and X4100
Storage?


‣   Lots of local drives
‣   DAS trays (trays that do their own RAID)
‣   iSCSI (stay away from fiber)
‣   RAID6 and RAID10
Leverage



‣   Pick a vendor and get as much as you can from
    that single vendor
Some comments


‣   Dell => direct, aggressive, helpful and they
    resell a lot of stu
‣   HP => might be direct, likely reseller
‣   Sun => you go through a reseller
Why we started with Dells

‣   Responsive
‣   They put us in touch with di erent leasing
    companies and arrangements
‣   They shipped
‣   We were a Dell/EMC shop (even with Solaris
    running on them)
Why we ended up using Sun
‣   The rails (literally the rack rails)
‣   RAS
‣   Hot-swappable components
‣   Energy e cient
‣   True ALOM/iLOM that works with console
‣   Often cheapest per CPU, per GB RAM
‣   Often cheapest in TCO
‣   We’re on Solaris (there’s some assurances
    there)
Lease if you can

‣   Generally it’s about 10-50% down
‣   And can be “ok” interest rate wise: 8-18%
‣   Do FMV where you turn over the systems at
    year 2
‣   How do you do it? Demonstrate that you have
    the cash overwise and push your vendor.
So what’s a typical lease payment?


‣   $10,000 system
‣   $1000 down, $400/month (10% down, 4%/mo)
Designing around power
So you want to colo?
You’re going to be small potatoes
Try and go local
Typical power they’ll allow

‣   Dual 15 amp, 110V
‣   Dual 20 amp, 110V
‣   Dual 20 amp, 208V (rare in non-cage setups)
‣   $250/month for each 15/20 amp, 110V plug
‣   $500/month for 20amp, 208V plug
Typical Costs

‣   $500-750 for the rack
‣   $500-$1000 for power per rack
‣   $1000 bandwidth commit (10 Mbps x $100,
    applies to all racks)
‣   $4000 for systems (20x $200/mo)/rack
Comparison

‣   Total $6500 for 20 systems in a rack on a lease.
‣   “2850s” at The Planet or Rackspace:
    $900-1200 each ($18,000 - $24,000/month)
‣   DIY: does require a more involved human or
    two of them (that could use up the di erence; a
    great sysadmin/racker is $100K+)
What do you run on it?
The Key
What are the patterns of
     deployment?
   Lessons learned
Ruby
‣   I like that Ruby is process-based
‣   I actually don’t think it should ever be threaded
‣   I think it should focus on being as asynchronous
    and event-based on a per process basis
‣   I think it should be loosely coupled
‣   What does a “VM” do then: it manages LWPs
‣   This is erlang versus java
So how do you run a rails process?


‣   FCGI
‣   Mongrel (event-driven)
‣   JRuby in Glassfish
How we do Mongrel
‣   16GB RAM, 4 AMD CPU machines
‣   4 virtual “containers” on them
‣   Each container: 10 mongrels (so 10 per CPU)
How do you scale processes?


‣   Run more and more of them
‣   They should add up
Add up how and where?


‣   Add up in the front
‣   Add up in the back
‣   Add up linearly
Horizontally scaling across processes


 ‣   In the front: load balancers capable of it
 ‣   In the back: database middleware and message
     buses
BIG-IPs
‣   http://f5.com/
The real wins with BIG-IPs


‣   The only thing I’ve seen horizontally scale
    across a couple thousand mongrels
‣   Layer 7 and iRules (separate controllers)
‣   Full packet inspection
when HTTP_REQUEST {
   if { [HTTP::uri] contains quot;svnquot; } {
      pool devror_svn
   } else {
      pool devror_trac
  }
}
when HTTP_REQUEST {
  if { [HTTP::host] contains quot;wwwquot;} {

    if { [HTTP::uri] contains quot;?quot; } {
          HTTP::redirect quot;http://twitter.com[HTTP::path]?[HTTP::query]quot;
       } else {
          HTTP::redirect quot;http://twitter.com[HTTP::path]quot;
       }
}
}
when HTTP_REQUEST {
  # Don't allow data to be chunked
  if { [HTTP::version] eq quot;1.1quot; } {
      if { [HTTP::header is_keepalive] } {
         HTTP::header replace quot;Connectionquot; quot;Keep-Alivequot;
      }
      HTTP::version quot;1.0quot;
   }
}

when HTTP_RESPONSE {
  # Only check responses that are a text content type
  # (text/html, text/xml, text/plain, etc).
  if { [HTTP::header quot;Content-Typequot;] starts_with quot;text/quot; } {
    # Get the content length so we can request the data to be
    # processed in the HTTP_RESPONSE_DATA event.
    if { [HTTP::header exists quot;Content-Lengthquot;] } {
      set content_length [HTTP::header quot;Content-Lengthquot;]
    } else {
      set content_length 4294967295
    }
    if { $content_length > 0 } {
       HTTP::collect $content_length
    }
  }
}

when HTTP_RESPONSE_DATA {
  # Find ALL the possible credit card numbers in one pass
  set card_indices [regexp -all -inline -indices {(?:3[4|7]d{13})|(?:4d{15})|(?:
5[1-5]d{14})|(?:6011d{12})} [HTTP::payload]]
# Calculate MOD10
        for { set i 0 } { $i < $card_len } { incr i } {
           set c [string index $card_number $i]
           if {($i & 1) == $double} {
              if {[incr c $c] >= 10} {incr c -9}
           }
           incr chksum $c
        }

        # Determine Card Type
        switch [string index $card_number 0] {
           3 { set type AmericanExpress }
           4 { set type Visa }
           5 { set type MasterCard }
           6 { set type Discover }
           default { set type Unknown }
        }

        # If valid card number, then mask out numbers with X's
        if { ($chksum % 10) == 0 } {
           set isCard valid
           HTTP::payload replace $card_start $card_len [string repeat quot;Xquot; $card_len]
        }

        # Log Results
        log local0. quot;Found $isCard $type CC# $card_numberquot;
    }
}
Layer7
Each controller has their own app
                 servers

‣   http://jason.joyent.net/mail
‣   http://jason.joyent.net/lists
‣   http://jason.joyent.net/calendar
‣   http://jason.joyent.net/login
The partitioning and federation
       then possible ...
Free software LB alternatives


‣   That I also like and think will get you far


‣   HA-Proxy
‣   Varnish (especially if you’re on a Linux)
My preferred web server + LB proxy


‣   Nginx
‣   Static assets with solaris event ports as the
    engine
Maybe a RDMS isn’t the only thing


‣   Memcache (in memory and easy)
‣   LDAP
‣   J-EAI (message bus with an in-memory db)
‣   File system
memcached
‣   http://www.danga.com/memcached/
J-EAI

‣   XMPP-Jabber message bus for XML (atom)
‣   Erlang-based
‣   Cluster-ready and very scalable
‣   Lots of connectors: SMTP, JDBC
‣   App <-> Bus <-> Database
LDAP

‣   Hierarchical database
‣   Great for parent-child modeled data
‣   We use for all authentication, user databases,
    DNS ...
‣   Basically as much as we can
Why?
The multi-master replication is
amazing when you’ve been living
 in MySQL and PostgreSQL lands
Sina

‣   “With over 230 million registered users, over 42
    million long-term paid users for special services,
    and over 450 million peak daily hits, Sina is one
    of the largest Web portals and a leading online
    media and value-added information service
    provider in China.”
‣   12 Sun Fire T1000 servers running Solaris 10
    and the Sun Java System Directory Server.
Pay attention to how you store
           your files
A story
Hashed directory structures

‣   Never more than 10K files / subdirs in a single
    directory (I aim for a max of 4K or so..)
‣   Keep it simple to implement / remember
‣   Don't get carried away and nest too deeply, that
    can hurt performance too
A couple of approaches
The 16x256
‣   Pre-create 16 top level dirs, 256 subdirs each
    which gives you 4096 quot;bucketsquot;.
‣   Keeping to the 10K per bucket rule, that's 4M
    quot;thingsquot; you can put into this structure. Go to
    256 x 256 if you're big and/or want to keep the
    number of things in the buckets lower.
‣   How do you decide where to put stu ?
‣   Pick randomly from 1 to 16 and from 1 to 256.
    Store path in the profile. What's it look like:
    userid=76340

    fspath=/data/12/245/76340/file1,file2,etc..

‣   You get nice even distribution, but the downside
    is that you can't quot;computequot; the directory path
    from the thing's ID.
The Hasher
‣   Idea is to compute the FS path from something
    you already know.

‣   Big plus is that anything you write that needs to
    access the FS doesn't need to look up the path
    in a database.

‣   Dubious value since you probably had to look
    the object/thing you're doing this for in the
    database anyways.. but you get the idea...
‣   Example: Use the userid to form the multi-level
    quot;hashquot; into the filesystem. Take for example the
    first two digits as your top level directory, the
    second two as the subdirectories. So sticking
    with our userid above we'd get a path like:

‣   /data/76/34/76340
‣   Downside is you can end up building stupid
    logic around the thing to handle low ids (where
    does user quot;46quot; go?) or end up padding stu , all
    of which is ugly.
‣   A fancier alternative to this is using something
    like a MD5 hash (which you probably also
    already have for sessions) and that works well,
    is easy to implements, tends to give you better
    distribution quot;for freequot;, and looks sexy to boot:

    # echo quot;76340quot; | md5


    e7ceb3e68b9095be49948d849b44181f


    gives us:


    /data/e7/ceb/76340
Downsides of the MD5-style


‣   Distribution is still unpredictable
‣   Watch your crypt()-style implementation cause it
    might output characters you need to escape!
‣   You can't compute it in your head
But
‣   The attractiveness of using some sort of
    computed hash will mostly depend on what sort
    of ID structure you already have, or or planning
    to use.

‣   Some are very friendly to simple hashing, some
    are not.

‣   So think “friendly”
Jamis does something like this
‣   http://www.37signals.com/svn/archives2/
    id_partitioning.php
DNS
‣   Don’t forget about it.

‣   Always surprising how little people know about
    DNS servers

‣   Federation by DNS is an easy way to split your
    customers into pods.
dns1# uname -a


FreeBSD dns1.textdrive.com 5.3-RELEASE FreeBSD 5.3-
RELEASE #0: Fri Nov 5 04:19:18 UTC 2004
root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/
GENERIC i386


dns1# cd /usr/ports/dns/powerdns


dns1# make config


dns1# make install
dns1# head /usr/local/etc/pdns.conf


# MySQL


launch=gmysql


gmysql-host=127.0.0.1


gmysql-dbname=dns


gmysql-user=dns


gmysql-password=blahblahblahboo
CREATE TABLE records (
CREATE TABLE domains (
                                                id int(11) NOT NULL auto_increment,
  id int(11) NOT NULL auto_increment,
                                                domain_id int(11) default NULL,
  name varchar(255) NOT NULL default '',
                                                name varchar(255) default NULL,
  master varchar(20) default NULL,
                                                type varchar(6) default NULL,
  last_check int(11) default NULL,
                                                content varchar(255) default NULL,
  type varchar(6) NOT NULL default '',
                                                ttl int(11) default NULL,
  notified_serial int(11) default NULL,
                                                prio int(11) default NULL,
  account varchar(40) default NULL,
                                                change_date int(11) default NULL,
  PRIMARY KEY (id),
                                                PRIMARY KEY (id),
  UNIQUE KEY name_index (name)
                                                KEY rec_name_index (name),
) TYPE=InnoDB;
                                                KEY nametype_index (name,type),
                                                KEY domain_id (domain_id)
                                              ) TYPE=InnoDB;




      CREATE TABLE zones (
        id int(11) NOT NULL auto_increment,
        domain_id int(11) NOT NULL default '0',
        owner int(11) NOT NULL default '0',
        comment text,
        PRIMARY KEY (id)
      ) TYPE=MyISAM;
mysql> use dna;
ERROR 1044 (42000): Access denied for user 'dns'@'localhost' to database 'dna'
mysql> use dns;
Database changed
mysql> show tables;
+---------------+
| Tables_in_dns |
+---------------+
| domains        |
| records        |
| zones          |
+---------------+
3 rows in set (0.00 sec)
insert into domains (name,type) values ('joyent.com','NATIVE');

insert into records (domain_id, name,type,content,ttl,prio) select id ,'joyent.com', 'SOA',
'dns1.textdrive.com dns.textdrive.com 1086328940 10800 1800 10800 1800', 1800, 0 from domains where
name='joyent.com';

insert into records (domain_id, name,type,content,ttl,prio) select id ,'joyent.com', 'NS',
'dns1.textdrive.com', 120, 0 from domains where name='joyent.com';

insert into records (domain_id, name,type,content,ttl,prio) select id ,'*.joyent.com', 'A', '207.7.108.165'
120, 0 from domains where name='joyent.com';
mysql> SELECT * FROM domains WHERE name = 'joyent.com';
+-------+------------+--------+------------+--------+-----------------+---------+
| id    | name       | master | last_check | type   | notified_serial | account |
+-------+------------+--------+------------+--------+-----------------+---------+
| 15811 | joyent.com | NULL   |       NULL | NATIVE |            NULL | NULL    |
+-------+------------+--------+------------+--------+-----------------+---------+
1 row in set (0.02 sec)

mysql> SELECT * FROM records WHERE domain_id = 15811 G
*************************** 1. row ***************************
         id: 532305
  domain_id: 15811
       name: joyent.com
       type: A
    content: 4.71.165.93
        ttl: 180
       prio: 0
change_date: 1172471659
*************************** 2. row ***************************
         id: 532306
  domain_id: 15811
       name: _xmpp-server._tcp.joyent.com
       type: SRV
    content: 5 5269 jabber.joyent.com
        ttl: 180
       prio: 0
change_date: NULL
*************************** 3. row ***************************
         id: 532307
  domain_id: 15811
       name: _xmpp-client._tcp.joyent.com
       type: SRV
    content: 5 5222 jabber.joyent.com
        ttl: 180
       prio: 0
change_date: NULL
Recap
‣   Use DNS
‣   Great load balancers
‣   Event-driven mongrels
‣   A relational database isn’t the only datastore:
    we use LDAP, J-EAI, file system too
‣   A Rails process should only be doing Rails
‣   Static assets should be coming from static
    servers
‣   Go layer7 where you can: a rails process should
    only be doing one controller
‣   Federate and separate as much as you can

Contenu connexe

Similaire à Scaling a Rails Application from the Bottom Up

Atlassian - Software For Every Team
Atlassian - Software For Every TeamAtlassian - Software For Every Team
Atlassian - Software For Every TeamSven Peters
 
Expecto Performa! The Magic and Reality of Performance Tuning
Expecto Performa! The Magic and Reality of Performance TuningExpecto Performa! The Magic and Reality of Performance Tuning
Expecto Performa! The Magic and Reality of Performance TuningAtlassian
 
[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise Applications[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise ApplicationsDaniel Oh
 
Securing Rails
Securing RailsSecuring Rails
Securing RailsAlex Payne
 
Day 2 General Session Presentations RedisConf
Day 2 General Session Presentations RedisConfDay 2 General Session Presentations RedisConf
Day 2 General Session Presentations RedisConfRedis Labs
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 uploadDebnath Sinha
 
Performance Oriented Design
Performance Oriented DesignPerformance Oriented Design
Performance Oriented DesignRodrigo Campos
 
E g innovations overview
E g innovations overviewE g innovations overview
E g innovations overviewNuno Alves
 
Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...
Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...
Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...jimliddle
 
CloudCrowd - RazorFish Presentation on Building Hybrid Public/Private Cloud
CloudCrowd - RazorFish Presentation on Building Hybrid Public/Private CloudCloudCrowd - RazorFish Presentation on Building Hybrid Public/Private Cloud
CloudCrowd - RazorFish Presentation on Building Hybrid Public/Private CloudNati Shalom
 
Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Griddeimos
 
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmx
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmxMoved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmx
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmxMilen Dyankov
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
SolarWinds Scalability for the Enterprise
SolarWinds Scalability for the EnterpriseSolarWinds Scalability for the Enterprise
SolarWinds Scalability for the EnterpriseSolarWinds
 
What is a Service Mesh and what can it do for your Microservices
What is a Service Mesh and what can it do for your MicroservicesWhat is a Service Mesh and what can it do for your Microservices
What is a Service Mesh and what can it do for your MicroservicesMatt Turner
 
Low latency in java 8 v5
Low latency in java 8 v5Low latency in java 8 v5
Low latency in java 8 v5Peter Lawrey
 
Design for Scale / Surge 2010
Design for Scale / Surge 2010Design for Scale / Surge 2010
Design for Scale / Surge 2010Christopher Brown
 
Castles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App EngineCastles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App Enginecatherinewall
 
Coates bosc2010 clouds-fluff-and-no-substance
Coates bosc2010 clouds-fluff-and-no-substanceCoates bosc2010 clouds-fluff-and-no-substance
Coates bosc2010 clouds-fluff-and-no-substanceBOSC 2010
 
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...John McCaffrey
 

Similaire à Scaling a Rails Application from the Bottom Up (20)

Atlassian - Software For Every Team
Atlassian - Software For Every TeamAtlassian - Software For Every Team
Atlassian - Software For Every Team
 
Expecto Performa! The Magic and Reality of Performance Tuning
Expecto Performa! The Magic and Reality of Performance TuningExpecto Performa! The Magic and Reality of Performance Tuning
Expecto Performa! The Magic and Reality of Performance Tuning
 
[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise Applications[RHFSeoul2017]6 Steps to Transform Enterprise Applications
[RHFSeoul2017]6 Steps to Transform Enterprise Applications
 
Securing Rails
Securing RailsSecuring Rails
Securing Rails
 
Day 2 General Session Presentations RedisConf
Day 2 General Session Presentations RedisConfDay 2 General Session Presentations RedisConf
Day 2 General Session Presentations RedisConf
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 upload
 
Performance Oriented Design
Performance Oriented DesignPerformance Oriented Design
Performance Oriented Design
 
E g innovations overview
E g innovations overviewE g innovations overview
E g innovations overview
 
Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...
Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...
Cloud Crowd - Mandhir Gidda Razorfish " Building a Public / Private Hybrid Cl...
 
CloudCrowd - RazorFish Presentation on Building Hybrid Public/Private Cloud
CloudCrowd - RazorFish Presentation on Building Hybrid Public/Private CloudCloudCrowd - RazorFish Presentation on Building Hybrid Public/Private Cloud
CloudCrowd - RazorFish Presentation on Building Hybrid Public/Private Cloud
 
Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Grid
 
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmx
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmxMoved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmx
Moved to https://slidr.io/azzazzel/web-application-performance-tuning-beyond-xmx
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
SolarWinds Scalability for the Enterprise
SolarWinds Scalability for the EnterpriseSolarWinds Scalability for the Enterprise
SolarWinds Scalability for the Enterprise
 
What is a Service Mesh and what can it do for your Microservices
What is a Service Mesh and what can it do for your MicroservicesWhat is a Service Mesh and what can it do for your Microservices
What is a Service Mesh and what can it do for your Microservices
 
Low latency in java 8 v5
Low latency in java 8 v5Low latency in java 8 v5
Low latency in java 8 v5
 
Design for Scale / Surge 2010
Design for Scale / Surge 2010Design for Scale / Surge 2010
Design for Scale / Surge 2010
 
Castles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App EngineCastles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App Engine
 
Coates bosc2010 clouds-fluff-and-no-substance
Coates bosc2010 clouds-fluff-and-no-substanceCoates bosc2010 clouds-fluff-and-no-substance
Coates bosc2010 clouds-fluff-and-no-substance
 
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
 

Plus de Abhishek Singh

Cobbler Summit - Automated Xen VM Deployment
Cobbler Summit - Automated Xen VM DeploymentCobbler Summit - Automated Xen VM Deployment
Cobbler Summit - Automated Xen VM DeploymentAbhishek Singh
 
Mapreduce - Simplified Data Processing on Large Clusters
Mapreduce - Simplified Data Processing on Large ClustersMapreduce - Simplified Data Processing on Large Clusters
Mapreduce - Simplified Data Processing on Large ClustersAbhishek Singh
 
Web Server Clustering - OSSCAMP
Web Server Clustering - OSSCAMPWeb Server Clustering - OSSCAMP
Web Server Clustering - OSSCAMPAbhishek Singh
 
Happy Independence Day To All Indians
Happy Independence Day To All IndiansHappy Independence Day To All Indians
Happy Independence Day To All IndiansAbhishek Singh
 
Xen_and_Rails_deployment
Xen_and_Rails_deploymentXen_and_Rails_deployment
Xen_and_Rails_deploymentAbhishek Singh
 
India's Smallest Car Ever
India's Smallest Car EverIndia's Smallest Car Ever
India's Smallest Car EverAbhishek Singh
 
Make Over Of An Orange
Make Over Of An OrangeMake Over Of An Orange
Make Over Of An OrangeAbhishek Singh
 
Cute Friendship Quotes
Cute Friendship QuotesCute Friendship Quotes
Cute Friendship QuotesAbhishek Singh
 
Series of Cool Pics Part 3
Series of Cool Pics Part 3Series of Cool Pics Part 3
Series of Cool Pics Part 3Abhishek Singh
 
Series of Cool Pictures Part 2
Series of Cool Pictures Part 2Series of Cool Pictures Part 2
Series of Cool Pictures Part 2Abhishek Singh
 
Series Of Cool Picutres Part 1
Series Of Cool Picutres Part 1Series Of Cool Picutres Part 1
Series Of Cool Picutres Part 1Abhishek Singh
 
Web Intrusion Detection
Web Intrusion Detection Web Intrusion Detection
Web Intrusion Detection Abhishek Singh
 

Plus de Abhishek Singh (20)

Cobbler Summit - Automated Xen VM Deployment
Cobbler Summit - Automated Xen VM DeploymentCobbler Summit - Automated Xen VM Deployment
Cobbler Summit - Automated Xen VM Deployment
 
Mapreduce - Simplified Data Processing on Large Clusters
Mapreduce - Simplified Data Processing on Large ClustersMapreduce - Simplified Data Processing on Large Clusters
Mapreduce - Simplified Data Processing on Large Clusters
 
Web Server Clustering - OSSCAMP
Web Server Clustering - OSSCAMPWeb Server Clustering - OSSCAMP
Web Server Clustering - OSSCAMP
 
Happy Independence Day To All Indians
Happy Independence Day To All IndiansHappy Independence Day To All Indians
Happy Independence Day To All Indians
 
test
testtest
test
 
How to Charm a Woman
How to Charm a WomanHow to Charm a Woman
How to Charm a Woman
 
Xen_and_Rails_deployment
Xen_and_Rails_deploymentXen_and_Rails_deployment
Xen_and_Rails_deployment
 
India's Smallest Car Ever
India's Smallest Car EverIndia's Smallest Car Ever
India's Smallest Car Ever
 
Software BABA
Software BABASoftware BABA
Software BABA
 
Make Over Of An Orange
Make Over Of An OrangeMake Over Of An Orange
Make Over Of An Orange
 
Cute Friendship Quotes
Cute Friendship QuotesCute Friendship Quotes
Cute Friendship Quotes
 
Series of Cool Pics Part 3
Series of Cool Pics Part 3Series of Cool Pics Part 3
Series of Cool Pics Part 3
 
Series of Cool Pictures Part 2
Series of Cool Pictures Part 2Series of Cool Pictures Part 2
Series of Cool Pictures Part 2
 
Name Confusion
Name ConfusionName Confusion
Name Confusion
 
Series Of Cool Picutres Part 1
Series Of Cool Picutres Part 1Series Of Cool Picutres Part 1
Series Of Cool Picutres Part 1
 
KUbuntu
KUbuntuKUbuntu
KUbuntu
 
Monit
MonitMonit
Monit
 
Fun
Fun Fun
Fun
 
Mod Security
Mod SecurityMod Security
Mod Security
 
Web Intrusion Detection
Web Intrusion Detection Web Intrusion Detection
Web Intrusion Detection
 

Dernier

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Dernier (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Scaling a Rails Application from the Bottom Up

  • 1. Scaling a Rails Application from the Bottom Up Jason Ho man PhD, CTO, Joyent Rails Conf 2007 Thursday, May 17, 2007
  • 2. Today’s schedule 830am I 50 II 920am 930am III 50 IV 1020am 1030am V 50 1130am VI
  • 4.
  • 5.
  • 6. What did they get me into? 5/2003 9/2005 5/2004 “it” started
  • 7. 6 Acts I. Introduction and foundational items II. Where do I put stu ? III. What stu ? IV. What do I run on this stu ? V. What are the patterns of deployment? VI. Lessons learned
  • 8. What I’ll tell you about ‣ What we’ve done ‣ Why we’ve done it ‣ How we’re doing it ‣ Our way of thinking
  • 12. Fundamental Limits ‣ Money ‣ Time
  • 13. Fundamental Limits ‣ Money ‣ Time ‣ People
  • 14. Fundamental Limits ‣ Money ‣ Time ‣ People ‣ Experience
  • 15. Fundamental Limits ‣ Money ‣ Time ‣ People ‣ Experience ‣ Power (which limits memory and CPU)
  • 16. Fundamental Limits ‣ Money ‣ Time ‣ People ‣ Experience ‣ Power (which limits memory and CPU) ‣ Bandwidth
  • 19. I get asked lots of questions
  • 20. “I have yet to find any examples of websites that have heavy tra c and stream media that run from a Ruby on Rails platform, can you suggest any sites that will demonstrate that the ruby platform is stable and reliable enough to use on a commercial level?”
  • 21. “We are concerned about the long-term viability of Ruby on Rails as a development language and environment.”
  • 22. “How easily can a ruby site be converted to another language? (If for any reason we were forced to abandon ruby at some point in the future or I can’t find someone to work with our code?).”
  • 23. “My company has some concerns on whether or not Ruby on Rails is the right platform to deploy on if we have a very large scale app.”
  • 24. What is a “scalable” application? ‣ What are some hardware layouts? ‣ Where do you get the hardware? ‣ How do you pay for it? ‣ Where do you put it? ‣ Who runs it? ‣ How do you watch it? ‣ What do you need relative to an application? ‣ What are the commonalities of scalable web architectures? ‣ What are the unique bottlenecks for Ruby on Rails applications? ‣ What's the best way to start so you can make sure everything scales? ‣ What are the common mistakes?
  • 25. But are these really Ruby or Rails specific ?
  • 26. They have to do with designing and then running scalable “internet” applications
  • 27. But the road to a top site on the internet is not from one interation
  • 28. Let’s break that down ‣ Designing ‣ Running ‣ Scalable ‣ “Internet” applications
  • 30. A Sysadmin’s view ‣ Ruby on Rails is simply one part ‣ Developers have to understand Rails horizontally (of course, otherwise they couldn’t write the application) ‣ Developers ideally understand the vertical stack ‣ It can get complicated fast and it’s easy to overengineer
  • 31. What do you do with 1000s of physical machines? 100s of TB of storage? In 4 facilities on 2 continents?
  • 32. Is this a “Rails” issue?
  • 34. This has been done before. The same big questions.
  • 35. Let’s take the “connector”
  • 36. “Logical” servers for the connector 1) Jumpstart/PXE Boot 2) Monitoring 3) Auditing 4) Logging 5) Provisioning and configuration management 6) DHCP/LDAP for server identification/authentication and control (at dual for failover) 7) DNS: DNS cache and resolver, and a (private) DNS system (4x + 2; 2+ sites) 8) DNS MySQL (4x + 2, dual masters with slaves per DNS node, innodb tables) 9) SPAM filtering servers (files to NFS store and tracking to postgresql) 10) SPAM database setup (postgresql) 11) SPAM NFS store 12) SMTP proxies and gateways out 13) SMTP proxies and gateways in (delivery to clusters to Maildir over NFS) 14) Mail stores 15) IMAP proxy servers 16) IMAP servers 17) User LDAP servers 18) User long running processes 19) User postgresql DB servers 20) User web servers 21) User application servers 22) User File Storage (NFS) 23) Joyent Organization Provisioning/Customer panel servers (web, app, database) 24) iSCSI storage systems 25) Chat servers 26) Load balancer/proxies/static caches ...
  • 37. Guess which is “Rails”?
  • 38.
  • 39. Ease of management is on a log scale ‣ 10 ‣ 100 ‣ 1,000 ‣ 10,000 ‣ 100,000 ‣ 1,000,000
  • 40.
  • 41.
  • 42. Amps, Volts and Watts ‣ 110V and 208V ‣ 15, 20, 30, 60 amp ‣ $25 per amp for 208V power ‣ 20 amps X 208V = 4160 watts ‣ 80% safely usable = 3328 watts
  • 43.
  • 44. A $5000 Dell 1850 costs $1850 to power over a 3 year lifespan ‣ 440watts x 24 hours/day x 1 kw/1000 watts = 10.56 kwh/day ‣ 10.56 kwh/day x $0.16/kwh = $1.69/day ‣ $1.69/day x 365 days/year = 616.85/year
  • 45. How many servers fit in a 100kw? ‣ 100 kilowatts to power and 100 kilowatts to cool ‣ At 250-400 watts each ‣ 250 - 400 servers
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52. Where do I put stuff? What stuff?
  • 53. Physical considerations ‣ Space ‣ Power ‣ Network connection ‣ Cables cables cables ‣ Routers and switches ‣ Servers ‣ Storage
  • 54. The 10% rule ‣ Google’s earning release: ‣ quot;Other cost of revenues, which is comprised primarily of data center operational expenses, as well as credit card processing charges, increased to $307 million, or 10% of revenues, in the fourth quarter of 2006, compared to $223 million, or 8% of revenues, in the third quarter.quot;
  • 55. The 10% rule ‣ A common rule of thumb I tell people is to target their performance goals in application design and coding so that their infrastructure (not including people) is ≤10% of an application’s revenue.
  • 56. The 10% rule ‣ Meaning if you’re making $1.2 million dollars a year o of an online application, then you should be in area of spending $120,000/year or $10,000/month on servers, storage and bandwidth. ‣ And from the other way around, if you’re spending $10,000 a month on these same things, then you know where to push your revenue to.
  • 57. Or maybe this is just a cost. It used to be for me.
  • 59. Whatever you do ‣ Keep it simple ‣ Standardize, Standardize, Standardize ‣ Try and use open technologies
  • 60. Some of my rules ‣ Virtualization, virtualization, virtualization ‣ Separating hardware components ‣ Keep the hardware setup simple ‣ Things should add up ‣ Configuration management and distributed control ‣ Pool and split ‣ Understand what each component can do as a maximum and a minimum
  • 61. Pairing physical resources with logical needs while keeping the smallest footprint
  • 62. You either build or you buy it
  • 63. Or you buy all of it from someone else
  • 65. “Buying” (by the way) means “using Rails” too
  • 66. What’s the cost breakpoints? ‣ Including people costs ‣ It’s generally cheaper at the $20,000-$30,000/ month spending to do it in-house. *Assuming you or at least one of your guys knows what they’re doing.
  • 67. But what if I buy all my stuff from someone else?
  • 70.
  • 72. KISS One kind of Console server Switch Server CPU RAM Storage Disc Operating system Interconnect Power plug Power strip
  • 74. Our Choices Console server => Lantronix ‣
  • 75. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s)
  • 76. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s
  • 77. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC
  • 78. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC ‣RAM => 2GB DIMMS
  • 79. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC ‣RAM => 2GB DIMMS ‣Storage => Sun Fire X4500 and NetApp FAS filters
  • 80. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC ‣RAM => 2GB DIMMS ‣Storage => Sun Fire X4500 and NetApp FAS filters ‣Disc => 500GB SATA and 73GB/146GB SAS
  • 81. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC ‣RAM => 2GB DIMMS ‣Storage => Sun Fire X4500 and NetApp FAS filters ‣Disc => 500GB SATA and 73GB/146GB SAS ‣Operating system => Solaris Nevada (“11”)
  • 82. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC ‣RAM => 2GB DIMMS ‣Storage => Sun Fire X4500 and NetApp FAS filters ‣Disc => 500GB SATA and 73GB/146GB SAS ‣Operating system => Solaris Nevada (“11”) ‣Interconnect => gigabit with cat6 cables
  • 83. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC ‣RAM => 2GB DIMMS ‣Storage => Sun Fire X4500 and NetApp FAS filters ‣Disc => 500GB SATA and 73GB/146GB SAS ‣Operating system => Solaris Nevada (“11”) ‣Interconnect => gigabit with cat6 cables ‣Power plug => 208V, L6-20R (the “wall”), IEC320-C14 to IEC320- C13 (server to PDU)
  • 84. Our Choices Console server => Lantronix ‣ ‣Switch => 48 port all gigabit (Force10 E300s) ‣Server => Sun Fire AMDs (X4100,X4600), T1000s ‣CPU => Opteron 285 and T1 SPARC ‣RAM => 2GB DIMMS ‣Storage => Sun Fire X4500 and NetApp FAS filters ‣Disc => 500GB SATA and 73GB/146GB SAS ‣Operating system => Solaris Nevada (“11”) ‣Interconnect => gigabit with cat6 cables ‣Power plug => 208V, L6-20R (the “wall”), IEC320-C14 to IEC320- C13 (server to PDU) ‣Power strip => APC 208V, 20x
  • 85. I/O * Flat network Storage * Physically segregated Remote Public Interconnects
  • 86. Cabling standard 3’ cat6 Public network Private interconnects Storage Storage ALOM => console servers Switch interconnects and mesh
  • 87. Our “SAN” RAIDZ2 RAIDZ2 RAIDZ2 RAIDZ2+1 RAIDZ2 RAIDZ2 Patent backups
  • 88. Our “SAN” RAIDZ2 RAIDZ2 RAIDZ2 RAIDZ2+1 RAIDZ2 RAIDZ2 Patent backups ‣ Think of it as a distributed RAID6+1
  • 89. Our “SAN” RAIDZ2 RAIDZ2 RAIDZ2 RAIDZ2+1 RAIDZ2 RAIDZ2 Patent backups ‣ Think of it as a distributed RAID6+1 ‣ Dual switched
  • 90. Our “SAN” RAIDZ2 RAIDZ2 RAIDZ2 RAIDZ2+1 RAIDZ2 RAIDZ2 Patent backups ‣ Think of it as a distributed RAID6+1 ‣ Dual switched ‣ Able to turn o half of your storage units
  • 91. Our “SAN” RAIDZ2 RAIDZ2 RAIDZ2 RAIDZ2+1 RAIDZ2 RAIDZ2 Patent backups ‣ Think of it as a distributed RAID6+1 ‣ Dual switched ‣ Able to turn o half of your storage units ‣ You end up having data stripped across 44, 88, 132, 196 drives
  • 92.
  • 93.
  • 94. Vendors ‣ Networking: Dell, HP, Force10, Cisco, Foundry ‣ Servers: Dell, HP, Sun ‣ Storage: Dell, HP, Sun, NetApp, Nexsan
  • 95. Servers ‣ Dell: 1850 and 2850 models ‣ HP: DL320s ‣ Sun: X2100 and X4100
  • 96. Storage? ‣ Lots of local drives ‣ DAS trays (trays that do their own RAID) ‣ iSCSI (stay away from fiber) ‣ RAID6 and RAID10
  • 97. Leverage ‣ Pick a vendor and get as much as you can from that single vendor
  • 98. Some comments ‣ Dell => direct, aggressive, helpful and they resell a lot of stu ‣ HP => might be direct, likely reseller ‣ Sun => you go through a reseller
  • 99. Why we started with Dells ‣ Responsive ‣ They put us in touch with di erent leasing companies and arrangements ‣ They shipped ‣ We were a Dell/EMC shop (even with Solaris running on them)
  • 100. Why we ended up using Sun ‣ The rails (literally the rack rails) ‣ RAS ‣ Hot-swappable components ‣ Energy e cient ‣ True ALOM/iLOM that works with console ‣ Often cheapest per CPU, per GB RAM ‣ Often cheapest in TCO ‣ We’re on Solaris (there’s some assurances there)
  • 101.
  • 102.
  • 103. Lease if you can ‣ Generally it’s about 10-50% down ‣ And can be “ok” interest rate wise: 8-18% ‣ Do FMV where you turn over the systems at year 2 ‣ How do you do it? Demonstrate that you have the cash overwise and push your vendor.
  • 104. So what’s a typical lease payment? ‣ $10,000 system ‣ $1000 down, $400/month (10% down, 4%/mo)
  • 106.
  • 107. So you want to colo?
  • 108. You’re going to be small potatoes
  • 109. Try and go local
  • 110.
  • 111. Typical power they’ll allow ‣ Dual 15 amp, 110V ‣ Dual 20 amp, 110V ‣ Dual 20 amp, 208V (rare in non-cage setups) ‣ $250/month for each 15/20 amp, 110V plug ‣ $500/month for 20amp, 208V plug
  • 112.
  • 113. Typical Costs ‣ $500-750 for the rack ‣ $500-$1000 for power per rack ‣ $1000 bandwidth commit (10 Mbps x $100, applies to all racks) ‣ $4000 for systems (20x $200/mo)/rack
  • 114. Comparison ‣ Total $6500 for 20 systems in a rack on a lease. ‣ “2850s” at The Planet or Rackspace: $900-1200 each ($18,000 - $24,000/month) ‣ DIY: does require a more involved human or two of them (that could use up the di erence; a great sysadmin/racker is $100K+)
  • 115. What do you run on it?
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 124. What are the patterns of deployment? Lessons learned
  • 125. Ruby ‣ I like that Ruby is process-based ‣ I actually don’t think it should ever be threaded ‣ I think it should focus on being as asynchronous and event-based on a per process basis ‣ I think it should be loosely coupled ‣ What does a “VM” do then: it manages LWPs ‣ This is erlang versus java
  • 126. So how do you run a rails process? ‣ FCGI ‣ Mongrel (event-driven) ‣ JRuby in Glassfish
  • 127. How we do Mongrel ‣ 16GB RAM, 4 AMD CPU machines ‣ 4 virtual “containers” on them ‣ Each container: 10 mongrels (so 10 per CPU)
  • 128. How do you scale processes? ‣ Run more and more of them ‣ They should add up
  • 129. Add up how and where? ‣ Add up in the front ‣ Add up in the back ‣ Add up linearly
  • 130. Horizontally scaling across processes ‣ In the front: load balancers capable of it ‣ In the back: database middleware and message buses
  • 131. BIG-IPs ‣ http://f5.com/
  • 132. The real wins with BIG-IPs ‣ The only thing I’ve seen horizontally scale across a couple thousand mongrels ‣ Layer 7 and iRules (separate controllers) ‣ Full packet inspection
  • 133.
  • 134.
  • 135.
  • 136. when HTTP_REQUEST { if { [HTTP::uri] contains quot;svnquot; } { pool devror_svn } else { pool devror_trac } }
  • 137. when HTTP_REQUEST { if { [HTTP::host] contains quot;wwwquot;} { if { [HTTP::uri] contains quot;?quot; } { HTTP::redirect quot;http://twitter.com[HTTP::path]?[HTTP::query]quot; } else { HTTP::redirect quot;http://twitter.com[HTTP::path]quot; } } }
  • 138.
  • 139. when HTTP_REQUEST { # Don't allow data to be chunked if { [HTTP::version] eq quot;1.1quot; } { if { [HTTP::header is_keepalive] } { HTTP::header replace quot;Connectionquot; quot;Keep-Alivequot; } HTTP::version quot;1.0quot; } } when HTTP_RESPONSE { # Only check responses that are a text content type # (text/html, text/xml, text/plain, etc). if { [HTTP::header quot;Content-Typequot;] starts_with quot;text/quot; } { # Get the content length so we can request the data to be # processed in the HTTP_RESPONSE_DATA event. if { [HTTP::header exists quot;Content-Lengthquot;] } { set content_length [HTTP::header quot;Content-Lengthquot;] } else { set content_length 4294967295 } if { $content_length > 0 } { HTTP::collect $content_length } } } when HTTP_RESPONSE_DATA { # Find ALL the possible credit card numbers in one pass set card_indices [regexp -all -inline -indices {(?:3[4|7]d{13})|(?:4d{15})|(?: 5[1-5]d{14})|(?:6011d{12})} [HTTP::payload]]
  • 140. # Calculate MOD10 for { set i 0 } { $i < $card_len } { incr i } { set c [string index $card_number $i] if {($i & 1) == $double} { if {[incr c $c] >= 10} {incr c -9} } incr chksum $c } # Determine Card Type switch [string index $card_number 0] { 3 { set type AmericanExpress } 4 { set type Visa } 5 { set type MasterCard } 6 { set type Discover } default { set type Unknown } } # If valid card number, then mask out numbers with X's if { ($chksum % 10) == 0 } { set isCard valid HTTP::payload replace $card_start $card_len [string repeat quot;Xquot; $card_len] } # Log Results log local0. quot;Found $isCard $type CC# $card_numberquot; } }
  • 141. Layer7
  • 142.
  • 143.
  • 144. Each controller has their own app servers ‣ http://jason.joyent.net/mail ‣ http://jason.joyent.net/lists ‣ http://jason.joyent.net/calendar ‣ http://jason.joyent.net/login
  • 145. The partitioning and federation then possible ...
  • 146. Free software LB alternatives ‣ That I also like and think will get you far ‣ HA-Proxy ‣ Varnish (especially if you’re on a Linux)
  • 147. My preferred web server + LB proxy ‣ Nginx ‣ Static assets with solaris event ports as the engine
  • 148.
  • 149. Maybe a RDMS isn’t the only thing ‣ Memcache (in memory and easy) ‣ LDAP ‣ J-EAI (message bus with an in-memory db) ‣ File system
  • 150. memcached ‣ http://www.danga.com/memcached/
  • 151. J-EAI ‣ XMPP-Jabber message bus for XML (atom) ‣ Erlang-based ‣ Cluster-ready and very scalable ‣ Lots of connectors: SMTP, JDBC ‣ App <-> Bus <-> Database
  • 152. LDAP ‣ Hierarchical database ‣ Great for parent-child modeled data ‣ We use for all authentication, user databases, DNS ... ‣ Basically as much as we can
  • 153.
  • 154.
  • 155. Why?
  • 156. The multi-master replication is amazing when you’ve been living in MySQL and PostgreSQL lands
  • 157.
  • 158. Sina ‣ “With over 230 million registered users, over 42 million long-term paid users for special services, and over 450 million peak daily hits, Sina is one of the largest Web portals and a leading online media and value-added information service provider in China.” ‣ 12 Sun Fire T1000 servers running Solaris 10 and the Sun Java System Directory Server.
  • 159.
  • 160. Pay attention to how you store your files
  • 162. Hashed directory structures ‣ Never more than 10K files / subdirs in a single directory (I aim for a max of 4K or so..) ‣ Keep it simple to implement / remember ‣ Don't get carried away and nest too deeply, that can hurt performance too
  • 163. A couple of approaches
  • 165. Pre-create 16 top level dirs, 256 subdirs each which gives you 4096 quot;bucketsquot;. ‣ Keeping to the 10K per bucket rule, that's 4M quot;thingsquot; you can put into this structure. Go to 256 x 256 if you're big and/or want to keep the number of things in the buckets lower.
  • 166. How do you decide where to put stu ? ‣ Pick randomly from 1 to 16 and from 1 to 256. Store path in the profile. What's it look like: userid=76340 fspath=/data/12/245/76340/file1,file2,etc.. ‣ You get nice even distribution, but the downside is that you can't quot;computequot; the directory path from the thing's ID.
  • 168. Idea is to compute the FS path from something you already know. ‣ Big plus is that anything you write that needs to access the FS doesn't need to look up the path in a database. ‣ Dubious value since you probably had to look the object/thing you're doing this for in the database anyways.. but you get the idea...
  • 169. Example: Use the userid to form the multi-level quot;hashquot; into the filesystem. Take for example the first two digits as your top level directory, the second two as the subdirectories. So sticking with our userid above we'd get a path like: ‣ /data/76/34/76340
  • 170. Downside is you can end up building stupid logic around the thing to handle low ids (where does user quot;46quot; go?) or end up padding stu , all of which is ugly.
  • 171. A fancier alternative to this is using something like a MD5 hash (which you probably also already have for sessions) and that works well, is easy to implements, tends to give you better distribution quot;for freequot;, and looks sexy to boot: # echo quot;76340quot; | md5 e7ceb3e68b9095be49948d849b44181f gives us: /data/e7/ceb/76340
  • 172. Downsides of the MD5-style ‣ Distribution is still unpredictable ‣ Watch your crypt()-style implementation cause it might output characters you need to escape! ‣ You can't compute it in your head
  • 173. But ‣ The attractiveness of using some sort of computed hash will mostly depend on what sort of ID structure you already have, or or planning to use. ‣ Some are very friendly to simple hashing, some are not. ‣ So think “friendly”
  • 174. Jamis does something like this ‣ http://www.37signals.com/svn/archives2/ id_partitioning.php
  • 175.
  • 176. DNS
  • 177. Don’t forget about it. ‣ Always surprising how little people know about DNS servers ‣ Federation by DNS is an easy way to split your customers into pods.
  • 178.
  • 179.
  • 180.
  • 181.
  • 182.
  • 183.
  • 184. dns1# uname -a FreeBSD dns1.textdrive.com 5.3-RELEASE FreeBSD 5.3- RELEASE #0: Fri Nov 5 04:19:18 UTC 2004 root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/ GENERIC i386 dns1# cd /usr/ports/dns/powerdns dns1# make config dns1# make install
  • 185.
  • 186. dns1# head /usr/local/etc/pdns.conf # MySQL launch=gmysql gmysql-host=127.0.0.1 gmysql-dbname=dns gmysql-user=dns gmysql-password=blahblahblahboo
  • 187. CREATE TABLE records ( CREATE TABLE domains ( id int(11) NOT NULL auto_increment, id int(11) NOT NULL auto_increment, domain_id int(11) default NULL, name varchar(255) NOT NULL default '', name varchar(255) default NULL, master varchar(20) default NULL, type varchar(6) default NULL, last_check int(11) default NULL, content varchar(255) default NULL, type varchar(6) NOT NULL default '', ttl int(11) default NULL, notified_serial int(11) default NULL, prio int(11) default NULL, account varchar(40) default NULL, change_date int(11) default NULL, PRIMARY KEY (id), PRIMARY KEY (id), UNIQUE KEY name_index (name) KEY rec_name_index (name), ) TYPE=InnoDB; KEY nametype_index (name,type), KEY domain_id (domain_id) ) TYPE=InnoDB; CREATE TABLE zones ( id int(11) NOT NULL auto_increment, domain_id int(11) NOT NULL default '0', owner int(11) NOT NULL default '0', comment text, PRIMARY KEY (id) ) TYPE=MyISAM;
  • 188. mysql> use dna; ERROR 1044 (42000): Access denied for user 'dns'@'localhost' to database 'dna' mysql> use dns; Database changed mysql> show tables; +---------------+ | Tables_in_dns | +---------------+ | domains | | records | | zones | +---------------+ 3 rows in set (0.00 sec)
  • 189. insert into domains (name,type) values ('joyent.com','NATIVE'); insert into records (domain_id, name,type,content,ttl,prio) select id ,'joyent.com', 'SOA', 'dns1.textdrive.com dns.textdrive.com 1086328940 10800 1800 10800 1800', 1800, 0 from domains where name='joyent.com'; insert into records (domain_id, name,type,content,ttl,prio) select id ,'joyent.com', 'NS', 'dns1.textdrive.com', 120, 0 from domains where name='joyent.com'; insert into records (domain_id, name,type,content,ttl,prio) select id ,'*.joyent.com', 'A', '207.7.108.165' 120, 0 from domains where name='joyent.com';
  • 190. mysql> SELECT * FROM domains WHERE name = 'joyent.com'; +-------+------------+--------+------------+--------+-----------------+---------+ | id | name | master | last_check | type | notified_serial | account | +-------+------------+--------+------------+--------+-----------------+---------+ | 15811 | joyent.com | NULL | NULL | NATIVE | NULL | NULL | +-------+------------+--------+------------+--------+-----------------+---------+ 1 row in set (0.02 sec) mysql> SELECT * FROM records WHERE domain_id = 15811 G *************************** 1. row *************************** id: 532305 domain_id: 15811 name: joyent.com type: A content: 4.71.165.93 ttl: 180 prio: 0 change_date: 1172471659 *************************** 2. row *************************** id: 532306 domain_id: 15811 name: _xmpp-server._tcp.joyent.com type: SRV content: 5 5269 jabber.joyent.com ttl: 180 prio: 0 change_date: NULL *************************** 3. row *************************** id: 532307 domain_id: 15811 name: _xmpp-client._tcp.joyent.com type: SRV content: 5 5222 jabber.joyent.com ttl: 180 prio: 0 change_date: NULL
  • 191. Recap
  • 192. Use DNS ‣ Great load balancers ‣ Event-driven mongrels ‣ A relational database isn’t the only datastore: we use LDAP, J-EAI, file system too ‣ A Rails process should only be doing Rails ‣ Static assets should be coming from static servers ‣ Go layer7 where you can: a rails process should only be doing one controller ‣ Federate and separate as much as you can