Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Architecture of Stack Overflow - Info Share 2014

The Architecture of Stack Overflow - Info Share 2014

Marco Cecconi

May 22, 2014
Tweet

More Decks by Marco Cecconi

Other Decks in Programming

Transcript

  1. The Architecture Of
    Marco Cecconi
    @sklivvz
    http://sklivvz.com

    View full-size slide

  2. Sizing up the problem

    View full-size slide

  3. *source: Quantcast, Alexa
    #55 network for traffic*

    View full-size slide

  4. #55 network for traffic*
    …and #13 in Poland!?
    *source: Quantcast, Alexa
    much successful
    very traffic
    dziękuję

    View full-size slide

  5. 520,523,008 pageviews in the last 30 days*
    *source: Quantcast

    View full-size slide

  6. So, how big is our datacenter?

    View full-size slide

  7. web servers
    load balancers
    redis
    search
    database
    http(s)
    http
    rest
    http
    protobuf
    sql
    sql
    protobuf
    tag engine

    View full-size slide

  8. We are still scaling up!

    View full-size slide

  9. Our development cycle

    View full-size slide

  10. BATCAVE
    Code-build-test cycle
    running on home machine
    feature requests

    View full-size slide

  11. BATCAVE DEV.SO
    Test on the real servers
    git push

    View full-size slide

  12. BATCAVE DEV.SO
    META.SE
    1-click deploy
    Users test on
    meta.stackexchange.com
    (“baking”)
    git push

    View full-size slide

  13. BATCAVE DEV.SO
    META.SE
    1-click deploy
    HALP!
    git revert
    git push

    View full-size slide

  14. BATCAVE DEV.SO
    NETWORK META.SE
    1-click deploy
    git push
    1-click
    deploy
    It’s live! Tons of users use it…

    View full-size slide

  15. BATCAVE DEV.SO
    NETWORK META.SE
    1-click deploy
    git push
    1-click
    deploy
    …and
    provide new
    feature requests

    View full-size slide

  16. Move fast and break things*
    * Not the home page or question page :-)

    View full-size slide

  17. Move fast and break things*
    * Not the home page or question page :-)

    View full-size slide

  18. Network Level Caches (CDN, etc.)
    Server Level Cache (HttpRuntime.Cache)
    Site Level Cache (Redis)
    SQL Server Database Cache (384 gigs of RAM!)
    Solid State Disk

    View full-size slide

  19. Too Many Allocations
    This is really the most basic thing that can go wrong.
    Too Many Pointers
    If you create a data structure that is a large mesh of pointers
    you'll have two problems. First, there will be a lot of object
    writes […] and, secondly, when it comes time to collect that
    data structure, you will make the garbage collector follow all
    those pointers and if necessary change them all as things
    move around. […] But if you create such a structure on a
    transitory basis, […], then you will pay the cost much more
    often.
    http://msdn.microsoft.com/en-us/library/ms973837.aspx#dotnetgcbasics_topic2

    View full-size slide

  20. Too Many Allocations
    This is really the most basic thing that can go wrong.
    Too Many Pointers
    If you create a data structure that is a large mesh of pointers
    you'll have two problems. First, there will be a lot of object
    writes […] and, secondly, when it comes time to collect that
    data structure, you will make the garbage collector follow all
    those pointers and if necessary change them all as things
    move around. […] But if you create such a structure on a
    transitory basis, […], then you will pay the cost much more
    often.
    http://msdn.microsoft.com/en-us/library/ms973837.aspx#dotnetgcbasics_topic2

    View full-size slide

  21. Abuse caching for GC
    performance

    View full-size slide

  22. Too Many Allocations
    This is really the most basic thing that can go wrong.
    Too Many Pointers
    If you create a data structure that is a large mesh of pointers
    you'll have two problems. First, there will be a lot of object
    writes […] and, secondly, when it comes time to collect that
    data structure, you will make the garbage collector follow all
    those pointers and if necessary change them all as things
    move around. […] But if you create such a structure on a
    transitory basis, […], then you will pay the cost much more
    often.
    http://msdn.microsoft.com/en-us/library/ms973837.aspx#dotnetgcbasics_topic2

    View full-size slide

  23. Too Many Allocations
    This is really the most basic thing that can go wrong.
    Too Many Pointers
    If you create a data structure that is a large mesh of pointers
    you'll have two problems. First, there will be a lot of object
    writes […] and, secondly, when it comes time to collect that
    data structure, you will make the garbage collector follow all
    those pointers and if necessary change them all as things
    move around. […] But if you create such a structure on a
    transitory basis, […], then you will pay the cost much more
    often.
    http://msdn.microsoft.com/en-us/library/ms973837.aspx#dotnetgcbasics_topic2

    View full-size slide

  24. IRepository orderRepository =
    container.Resolve>();
    Order order = orderRepository.Get(35);
    This is what you think you are doing…

    View full-size slide

  25. …but if you think about it a bit more…

    View full-size slide

  26. ...this is what you are actually doing!
    IRepository repository =
    new ValidatingOrderRepository (
    new SecurityRepository (
    new LoggingRepository (
    new CachingRepository (
    new NHibernateRepository ()
    )
    )
    )
    );
    Order order = repository.Get(35);

    View full-size slide

  27. We don’t use dependency-
    injection or IoC containers

    View full-size slide

  28. Our source code

    View full-size slide

  29. Few projects :-)

    View full-size slide

  30. Few projects :-) Few lines of code :-)

    View full-size slide

  31. Few projects :-) Few lines of code :-)
    Eeek! very few tests :-S

    View full-size slide

  32. Few projects :-) Few lines of code :-)
    Awesome community to help :-D
    Eeek! very few tests :-S

    View full-size slide

  33. YAGNI*
    * You Ain’t Gonna Need It!

    View full-size slide

  34. Libraries and open source

    View full-size slide

  35. * Source http://bit.ly/1eSLr8Z

    View full-size slide

  36. Wrap code in libraries
    and open source it

    View full-size slide

  37. HIRE “A” PLAYERS

    View full-size slide

  38. TOOLS LEVEL: NINJA

    View full-size slide

  39. • Performance is a feature
    • Always. Be. Shipping.
    • Use your circumstances.
    • Open source your libraries
    • 3 obscenely big monitors.
    KEY TAKEAWAYS

    View full-size slide

  40. $_='Qgul=ar=ftq=pmk:=ftq=mooagzfmzf=puxqyym.=Guhqz=m=eqcgqzoq=ar=
    bduoqe,=IEzgyqdmnxq=ar=uzf=ruzp=ftq=rudef=N=ftmf=egy=fa=lqda,=itq
    dq=N=ue=m=bmdmy.=Ttq=xuef=yustf=zaf=nq=ruzufq=uz=eulq.=Sqzp=kagd=
    eaxgfuaz=fa=ewxuhhl&efmowahqdrxai.oay1';tr/=1m-za-l@&Z/ !a-
    zP@\n/&print;
    Marco Cecconi
    @sklivvz
    http://sklivvz.com

    View full-size slide