SlideShare a Scribd company logo
my.opera.com scalability v1
         Italian Perl Workshop ~ Pisa 2008
               cosimo streppone   <cosimo@cpan.org>
IPW2008 - my.opera.com scalability
IPW2008 - my.opera.com scalability
Scalability
   ==
Performance
Scalability
    !=
Performance
Scalability
    ==
memcached?
Scalability
   !=
memcached
My Opera Community
             http://my.opera.com


        blogs                          shoutbox
Opera browser promotion
                         photo albums
     RSS-Atom feeds
                                        slideshows
                      custom designs
Public APIs
          xml/json             forums
2001
2003
2005
2006
IPW2008 - my.opera.com scalability
2008
my.opera.com

small (un)known web sites
Users (k)
                                                                2.500 *




                                                        1.640 IPW2008



                                                 887

                                          430
                            257 205
        1     10     50
2000   2001   2002   2003   2004   2005   2006   2007    2008    2009
Users (k)
                              Servers

                                                               2.500 *

                                                                IPW2008
                                                        1.640



                                                 887

                                          430
                            257 205
        1     10     50
2000   2001   2002   2003   2004   2005   2006   2007   2008    2009
Users (k)
                              Servers
                              Dyn req/s




                                                               2.500*

                                                        1.640

                                                 887
                            257 205 430
        1     10     50
2000   2001   2002   2003   2004   2005   2006   2007   2008    2009
proxy errors
the zen way to
indefinite scaling
Start



                   Y
 Does it run?

                       Does it   N
         N             scale?
 No problem...
                                 Identify and fix
Wait and restart       Y           bottlenecks




                       End
/* recommendations */


  server-side statistics

  good stress testing tools
IPW2008 - my.opera.com scalability
shared-nothing
  architecture
  (“zero tolerance for sharing”)
lvs +
        lw httpd



        mod_perl
.....
        backends



        nfs server
        disk cache
        users store
lvs +
        lw httpd



        mod_perl
.....
        backends



        nfs server
        disk cache
        users store
lvs +
        lw httpd



        mod_perl
.....
        backends



        nfs server
        disk cache
        users store
... not so easy ...
dev.opera.com
articles cache
(or “don't guess, profile!”)
/* problem */


       1 function
(XWA::Quote2Dev::Quote)

   ~95%   req time
/* solution */
     Start



                   Y   Great. Serve
  In Cache?            from cache.

          N

Query DB, etc...          Done!


Put it in cache
  this time!
/* solution */

      Yes, that simple!

      Profiling is key.

           try:
m{^ Devel:: .* Prof .*}x
IPW2008 - my.opera.com scalability
static avatars
(or “put your http servers at work”)
IPW2008 - my.opera.com scalability
/* problem */

   a single forum page
            ~~
        50 avatars

(crappy CGI backend requests)
IPW2008 - my.opera.com scalability
new storage subsystem
          pools, servers
  fault tolerance, redundancy

      webdav, http, ftp,
      scp, mogilefs?, ...
user uploads use case
# Create resource object for avatar
my $res = MyOpera::Storage::Resource::Avatar->new(
    owner => '{userid}',
    content => '{binary data}',
);


# Main storage subsystem handle
my $storage = MyOpera::Storage->new();


# Upload on pools of servers all at once
my $ok = $storage->upload($res);
resources
                   (user uploads, binary blobs, ...)




              pools, servers




                                 URLs
http://static.myopera.com/pool1/avatars/a4/754/a1b2c3d4e5f6.../<userid>_o.png
http://static.myopera.com/pool1/avatars/a4/754/a1b2c3d4e5f6.../<userid>_t.jpg
http://static.myopera.com/pool1/avatars/a4/754/a1b2c3d4e5f6.../<userid>_m.jpg
http://static.myopera.com/pool1/avatars/a4/754/a1b2c3d4e5f6.../<userid>_l.jpg
/* results */


saved ~500k backend req/day

    browser cache used!
dogpile effect
(or the cache “storms”)
/* problem */


very high load spikes
  on DB, backends
/* cause */


many concurrent clients
build same cached items
/* solution */


cache contention algorithm

      NFS-resistant
  optimistic file locking
/* solution */

    ideas taken from
HTML::Mason, Django, ...

 patched File::NFSLock
/* further ideas */

 LOCK_SPIN_TIME


distributed cache
  on backends
Opera releases
/* problem */


 10-30x normal load

handling of peak load?
/* try 1 */


 load-balanced
database profiles
/* try 2 */



url hot-list
/* solution? */


no solution this time,
        sorry.
/* further ideas */


   Amazon EC2 ?
Akamai CDN services?
        ... ?
soft counters
     (didn't work as expected, in progress...)




sacrifice speed for concurrency
         (mysql's myisam locks all table on update)
/* future directions */

         database   partitioning?
   modperl backend optimization?
threading sucks in mp2. debian anyone?
           improve memory sharing?
        sysadmin-level optimizations?
take-aways


find your PKIs
take-aways


always compare
before and after
take-aways


stress testing in your
    release cycle
take-aways


have fun!
   ;-)
?questions?
IPW2008 - my.opera.com scalability
thanks!

More Related Content

IPW2008 - my.opera.com scalability