SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
The eBay Architecture
Striking a balance between site stability, feature velocity, performance, and cost




                                              .
                                      nc
                                ,I
                              SD Forum 2006

                        ay
               eB

Presented By: Randy Shoup and Dan Pritchett
        Date: November 29, 2006
What we’re up against

• eBay manages …
     – Over 212,000,000 registered users
     – Over 1 Billion photos
                                                                 A sportingis soldsells every 2 seconds
                                                                   An SUV good every 5 minutes
       – eBay users worldwide trade more than $1590




                                                          .
         worth of goods every second




                                                  nc
       – eBay averages over 1 billion page views per
         day
       – At any given time, there are approximately




                                            ,I
         105 million listings on the site
       – eBay stores over 2 Petabytes of data – over


         per month
                                    ay
         200 times the size of the Library of Congress!
       – The eBay platform handles 3 billion API calls
                                                              Over ½ Million pounds of
                                                              Kimchi are sold every year!
                          eB
      • In a dynamic environment
           – 300+ features per quarter
           – We roll 100,000+ lines of code every two weeks

                • In 33 countries, in seven languages, 24x7

                         >26 Billion SQL executions/day!

 2

                                                                                               © 2006 eBay Inc.
eBay’s Exponential Growth

                                                                      105
                                                                    Million
                                                                    Listings




                                          .
                                  nc
                              ,I
                          ay                                         212
                                                                    Million
                                                                    Users
                  eB

Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3

  1998    1999     2000    2001    2002     2003     2004    2005          2006
   4

                                                               © 2006 eBay Inc.
Velocity of eBay -- Software Development Process

                     Feature
                                                                   212M Users




                                                     .
300+ Features




                                             nc
                     Feature               Train                                         99.94%
 Per Quarter




                                       ,I
                     Feature                 100K LOC/Wk              6M LOC

                                ay
  • Our site is our product. We change it incrementally through implementing new features.
                       eB
  • Very predictable development process – trains leave on-time at regular intervals (weekly).
  • Parallel development process with significant output -- 100,000 LOC per release.
  • Always on – over 99.94% available.


                            All while supporting a 24x7 environment
   5

                                                                                       © 2006 eBay Inc.
Systemic Requirements


         Availability
         Reliability
                            Enable seamless growth
      Massive Scalability
          Security




                                      .
                                nc
                            ,I
        Maintainability     Deliver quality functionality at
        Faster Product
           Delivery         ay
                            accelerating rates
                 eB
        Architect for the
             future
                            Enable rapid business innovation
          10X Growth


6

                                                               © 2006 eBay Inc.
Architectural Lessons


• Scale Out, Not Up
    – Horizontal scaling at every tier.
    – Functional decomposition.




                                                  .
                                          nc
• Prefer Asynchronous Integration
    – Minimize availability coupling.




                                        ,I
    – Improve scaling options.

• Virtualize Components
                             ay
    – Reduce physical dependencies.
    – Improve deployment flexibility.
                    eB
• Design for Failure
    – Automated failure detection and notification.
    – “Limp mode” operation of business features.




7

                                                      © 2006 eBay Inc.
Ongoing Platform Evolution…


                                                                     212M
                          Registered Users




                                               .
                                        nc
                                   ,I
     V1
          1998    1999   2000   ay
                                2001    2002   2003   2004    2005    Q3
                                                                     2006
                         eB
                 V2.0       V2.3       V2.4      V2.5

                                                             V3                 V4
eBay architecture versions

 8

                                                                            © 2006 eBay Inc.
V1.0 1995-September 1997


•   Built over a weekend in Pierre Omidyar’s living room in 1995
•   System hardware was made up of parts that could be bought at Fry's
•   Every item was a separate file, generated by a Perl script
•   No search functionality, only category browsing




                                                    .
                                             nc
                                       ,I
                                ay
                       eB

    This system maxed out at 50,000 active items
                                                                  1995   1996   1997   1998   1999   2000   2001   2002   2003   2004   2005



     9

                                                                                                                          © 2006 eBay Inc.
V2.0 September 1997- February 1999

• 3-tiered conceptual architecture (separation of bus/pres and db access tiers)
• 2-tiered physical implementation (no application server)
• C++ Library (eBayISAPI.dll) running on IIS on Windows
• Microsoft index server used for search
• Items migrated from GDBM to an Oracle database on Solaris




                                                     .
                                             nc
                                       ,I
                                ay
                       eB


                                                                    1995   1996   1997   1998   1999   2000   2001   2002   2003   2004   2005




  10

                                                                                                                            © 2006 eBay Inc.
V2.1 February 1999-November 1999


• Servers grouped into pools (small soldiers)
• Resonate used for front end load balancing and failover
• Search functionality moved to the Thunderstone indexing system
• Back-end Oracle database server scaled vertically to a larger machine (Sun E10000)




                                                   .
                                           nc
                                      ,I
                              ay
                      eB


                                                                 1995   1996   1997   1998   1999   2000   2001   2002   2003   2004   2005




  11

                                                                                                                         © 2006 eBay Inc.
V2.3 June 1999-November 1999


• Second Database added for failover
• CGI pools, Listings, Pages, and Search continued to scale horizontally

                                     However …




                                                    .
                                             nc
 By November 1999, the database servers approached their limits of physical growth.




                                       ,I
                               ay
                      eB


  12

                                                                                  © 2006 eBay Inc.
V2.4 November 1999-April 2001

• Database "split" technology.
• Logically partition database into separate instances.
• Horizontal scalability through 2000, but not beyond.




                                                      .
                                              nc
                                        ,I
                                ay
                       eB


  13

                                                          © 2006 eBay Inc.
V2.5 April 2001 – December 2002

• Horizontal scalability through database splits
• Items split by category
• SPOF elimination




                                                        .
                                                   nc
  User Write    User Read                              FEEDBACK                          BATCH JOBS
                                         ACCOUNTS                     ARCHIVE


                                                                                                  BATCH JOBS




                                         ,I
  Bull                                    CATY 1     CATY 2       CATY 3        CATY 4

               Bear
                                 ay      CATY 5      CATY 6       CATY 7         CATY 8
                                                                                                 Tran
                            eB
                                                                                                Scratch
                                         CATY 9     CATY 10       CATY 11       CATY 12




                                  December, 2002
                                 November, 1999
         SUN
        SUN
   14
        A3500
                                                                                                      © 2006 eBay Inc.
Now that we have the Database taken care of….


 • Application Server
      –   Monolithic 2-tier Architecture
      –   3.3 Million Line C++ ISAPI DLL (150MB binary)




                                               .
                                        nc
      –   Hundreds of developers, all working on the same code
      –   Hitting compiler limits on number of methods per class (!!)




                                   ,I
                            ay
                    eB


 15

                                                                        © 2006 eBay Inc.
V3 – Replace C++/ISAPI with Java 2002-present


•     Re-wrote the entire application in J2EE application server framework
     –   Gave us a chance to architect the code for reuse and separation of duties

•     Leveraged the MSXML framework for the presentation layer




                                                   .
                                           nc
     –   Minimizing the development cost for migration

•     Implemented a development kernel as a foundation for programmers




                                     ,I
     –   Allowed for rapid training and deployment of new engineers


                              ay
                     eB


16

                                                                                     © 2006 eBay Inc.
Scaling the Data Tier




                         .
                        nc
                        ,I
                ay
           eB
Scaling the Data Tier: Overview


• Spread the Load
     – Segmentation by function.
     – Horizontal splits within functions.




                                                 .
                                             nc
• Minimize the Work
     – Limit in database work




                                      ,I
• The Tricks to Scaling
     – How to survive without transactions.
                              ay
     – Creating alternate database structures.
                     eB


18

                                                     © 2006 eBay Inc.
Scaling the Data Tier: Functional Segmentation


• Segment databases into functional areas
     –   User hosts
     –   Item hosts




                                                    .
     –   Account hosts




                                            nc
     –   Feedback hosts
     –   Transaction hosts




                                      ,I
     –   And about 70 more functional categories

• Rationale
                              ay
     – Partitions data by different scaling / usage characteristics
                     eB
     – Supports functional decoupling and isolation




19

                                                                      © 2006 eBay Inc.
Scaling the Data Tier: Horizontal Split


• Split databases horizontally by primary access path.
• Different patterns for different use cases




                                                             .
     – Write Master/Read Slaves




                                                      nc
     – Segmentation by data; Two approaches
        • Modulo on a key, typically the primary key.




                                            ,I
             Simple data location if you know the key
             Not so simple if you don’t.
        • Map to data location
                                  ay
             Supports multiple keys.
             Doubles reads required to locate data.
                      eB
             SPOF elimination on map structure is complex.

• Rationale
     – Horizontal scaling of transactional load.
     – Segment business impact on database outage.



20

                                                                 © 2006 eBay Inc.
Scaling the Data Tier: Logical Database Hosts


     • Separate Application notion of a database from physical implementation
     • Databases may be combined and separated with no code changes
     • Reduce cost of creating multiple environments (Dev, QA, …)




                                                               .
                                                    nc
                                             Application Servers




                                                 ,I
            Attributes Catalogs   Rules   CATY            Account   Feedback   Misc   API   SCRATCH
                                          1..N    User



                                      ay
                         eB

                  DB1                                    DB2                                DB3


21

                                                                                                      © 2006 eBay Inc.
Scaling the Data Tier: Minimize DB Resources


• No business logic in database
     – No stored procedures
     – Only very simple triggers (default value population)




                                                   .
                                           nc
• Move CPU-intensive work to applications
     – Referential Integrity




                                     ,I
     – Joins
     – Sorting

                               ay
• Extensive use of prepared statements and bind variables
                     eB


22

                                                              © 2006 eBay Inc.
Scaling the Data Tier: Minimize DB Transactions


• Auto-commit for vast majority of DB writes
• Absolutely no client side transactions
     – Single database transactions managed through anonymous PL/SQL blocks.




                                              .
                                           nc
     – No distributed transactions.
• How do we pull it off?




                                       ,I
     – Careful ordering of DB operations
     – Recovery through

          • Reconciliation batch
          • Failover to async flow
                                   ay
          • Asynchronous recovery events
                       eB
• Rationale
     –   Avoid deadlocks
     –   Avoid coupling availability
     –   Update concurrency
     –   Seamless handling of splits


23

                                                                               © 2006 eBay Inc.
Scaling the Application Tier




                               .
                         nc
                     ,I
                ay
           eB
Scaling the Application Tier – Overview


• Spread the Load
     – Segmentation by function.
     – Horizontal load-balancing within functions.




                                                     .
                                           nc
• Minimize dependencies
     – Between applications




                                     ,I
     – Between functional areas
     – From applications to data tier resources

• Virtualize data access     ay
                    eB


25

                                                         © 2006 eBay Inc.
Scaling the Application Tier – Massively Scaling J2EE


• Step 1 - Throw out most of J2EE
     – eBay scales on servlets and a rewritten connection pool.

• Step 2 – Keep Application Tier Completely Stateless




                                                  .
                                          nc
     – No session state in application tier
     – Transient state maintained in cookie or scratch database




                                    ,I
• Step 3 – Cache Where Possible
     – Cache common metadata across requests, with sophisticated cache refresh
       procedures
                             ay
     – Cache reload from local storage
                    eB
     – Cache request data in ThreadLocal




26

                                                                                 © 2006 eBay Inc.
Scaling the Application Tier – Tiered Application Model


• Strictly partition application into tiers
      •Presentation
      •Business
      •Integration




                                                        .
                                                     nc
                                               XSL
 Presentation Tier




                                                ,I
                                       Command (View)       XML Model
                                        AO/AOF (View)       Building Logic

   Business Tier
                                        ay    BO/BOF        Business Logic
                              eB
  Integration Tier                            DO/DAO        Data Access Layer (DAL)




      27

                                                                             © 2006 eBay Inc.
Scaling the Application Tier – Data Access Layer (DAL)


• What is the DAL?
     – eBay’s internally-developed pure Java OR mapping solution.
     – All CRUD (Create Read Update Delete) operations are performed




                                              .
                                       nc
       through DAL’s abstraction of the data.
     – Enables horizontal scaling of the Data tier without application code




                                  ,I
       changes

• Dynamic Data Routing abstracts application developers from
     – Database splits     ay
     – Logical / Physical Hosts
                   eB
     – Markdown
     – Graceful degradation

• Extensive JDBC Prepared Statements cached by DataSources


28

                                                                              © 2006 eBay Inc.
Scaling the Application Tier – Vertical Code Partitioning


• Partition code into functional areas
     • Application is specific to a single area (Selling, Buying, etc.)
     • Domain contains common business logic across Applications




                                                                                   .
• Restrict inter-dependencies




                                                                     nc
     • Applications depend on Domains, not on other Applications
     • No dependencies among shared Domains




                                                            ,I
             UserApplication SellingApplication BuyingApplication BillingApplication SearchApplication

                                                                                                         Applications
              UserDomain       SellingDomain
                                                ay
                                                 BuyingDomain      BillingDomain       SearchDomain
                                  eB
      PersonalizationDomain            UserValidationDomain                 SharedBillingDomain
                                                                                                          Shared
      SharedBuyingDomain                       myEbayDomain                    SharedSearchDomain
                                                                                                          Domains
                            Core-Domain                                API Domain


      29
                                                LookupDomain
                                                                                                              © 2006 eBay Inc.
Scaling the Application Tier – Functional Segmentation

• Segment functions into separate application pools
     • Minimizes / isolates DB dependencies
     • Allows for parallel development, deployment, and monitoring

                    ViewItem Pool                               SYI Pool




                                                            .
                                                    nc
                    http://cgi.ebay.com …                       http://cgi5.ebay.com …

                                             CGI0                                         CGI5
           Load Balancing
                                                    …                                                 …




                                                    ,I
                                                                                                 IIS WebServers

                           IIS
                                        ay
                                        IIS                        IIS            IIS
                                 eB
                                                                                                  AppServers
          Load Balancing



            AS               AS             AS             AS            AS              AS



  Load Balancing

     30               User                  Acct        Caty1      …          Caty20+
                                                                                                  © 2006 eBay Inc.
Scaling the Application Tier – Platform Decoupling


• Domain Partitioning for Deployment
     – Decouple non-transactional domains from transactional flows
        • Search and billing domains are not required in transaction processing.




                                                       .
        • Fraud domain is required but easier to manage as separate deployment.




                                              nc
     – Integrate with a combination of asynchronous EDA and synchronous SOA
       patterns.




                                        ,I
                                 ay   Transaction
                                       Platform
                     eB

                                                             SOA
                           EDA




                                            EDA




                         Billing          Search            Fraud

31

                                                                                   © 2006 eBay Inc.
Scaling Search




                      .
                  nc
                 ,I
                 ay
          eB
Scaling Search – Overview

• In 2002, eBay search had reached its limits
     – Cost of scaling third-party search engine had become prohibitive
     – 9 hours to update the index
     – Running on largest systems vendor sold – and still not keeping up




                                                           .
                                                 nc
• eBay has unique search requirements
     – Real-time updates
        • Update item on any change (list, bid, sale, etc.)




                                         ,I
        • Users expect changes to be visible immediately
     – Exhaustive recall
                                ay
        • Sellers notice if search results miss any item
        • Search results require data (“histograms”) from every matching item
                      eB
     – Flexible data storage
        • Keywords
        • Structured categories and attributes

• No off-the-shelf product met these needs



33

                                                                                © 2006 eBay Inc.
Scaling Search – Voyager


• Real-time feeder infrastructure
     – Reliable multicast from primary database to search nodes
• Real-time indexing




                                             .
                                      nc
     – Search nodes update index in real time from messages
• In-memory search index




                                 ,I
• Horizontal segmentation
                          ay
     – Search index divided into N slices (“columns”)
     – Each slice is replicated to M instances (“rows”)
                   eB
     – Aggregator parallelizes query over all N slices, load-balances over M
       instances
• Caching
     – Cache results for highly expensive and frequently used queries



34

                                                                           © 2006 eBay Inc.
Scaling Operations




                      .
                     nc
                     ,I
               ay
          eB
Scaling Operations – Code Deployment


• Demanding Requirements
     –   Entire site rolled every 2 weeks
     –   All deployments require staged rollout with immediate rollback if necessary.




                                                     .
     –   More than 100 WAR configurations.




                                             nc
     –   Dependencies exist between pools during some deployment operations.
     –   More than 15,000 instances across eight physical data centers.




                                       ,I
• Rollout Plan
     – Custom application that works from dependencies provided by projects.

                               ay
     – Creates transitive closure of dependencies.
     – Generates rollout plan for Turbo Roller.
                      eB
• Automated Rollout Tool (“Turbo Roller”)
     –   Manages full deployment cycle onto all application servers.
     –   Executes rollout plan.
     –   Built in checkpoints during rollout, including approvals.
     –   Optimized rollback, including full rollback of dependent pools.


37

                                                                                        © 2006 eBay Inc.
Scaling Operations – Monitoring


• Centralized Activity Logging (CAL)
     – Transaction oriented logging per application server
        • Transaction boundary starts at request. Nested transactions supported.




                                                         .
                                                nc
        • Detailed logging of all application activity, especially database and other external
          resources.
        • Application generated information and exceptions can be reported.




                                         ,I
     – Logging streams gathered and broadcast on a message bus.
        • Subscriber to log to files (1.5TB/day)

                                ay
        • Subscriber to capture exceptions and generate operational alerts.
        • Subscriber for real time application state monitoring.
                      eB
     – Extensive Reporting
        • Reports on transactions (page and database) per pool.
        • Relationships between URL’s and external resources.
        • Inverted relationships between databases and pools/URL’s.
        • Data cube reporting on several key metrics available in near real time.



38

                                                                                                 © 2006 eBay Inc.
Recap


        Availability
                           Enabling seamless growth
        Reliability
     Massive Scalability   • Massive Database and Code Scalability




                                        .
         Security




                                  nc
                           Delivering quality functionality at




                             ,I
       Maintainability      accelerating rates
       Faster Product
          Delivery         ay
                           • Further streamline and optimize the eBay
                             development model
                  eB

       Architecting for    Enabling rapid business innovation
          the future
         10X Growth

39

                                                                 © 2006 eBay Inc.

Contenu connexe

Similaire à Ebay架构演变历程

eBay Architecture
eBay Architecture eBay Architecture
eBay Architecture
Tony Ng
 
Randy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural PrinciplesRandy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural Principles
deimos
 
Move SAP to Cloud in 3 Easy Steps
Move SAP to Cloud in 3 Easy StepsMove SAP to Cloud in 3 Easy Steps
Move SAP to Cloud in 3 Easy Steps
AppZero
 
Building a Website to Scale to 100 Million Page Views Per Day and Beyond
Building a Website to Scale to 100 Million Page Views Per Day and Beyond Building a Website to Scale to 100 Million Page Views Per Day and Beyond
Building a Website to Scale to 100 Million Page Views Per Day and Beyond
Trieu Nguyen
 
Premium Website Hosting
Premium Website HostingPremium Website Hosting
Premium Website Hosting
webhostingguy
 
039 keynote mike-culver_-_amazon_web_services
039 keynote mike-culver_-_amazon_web_services039 keynote mike-culver_-_amazon_web_services
039 keynote mike-culver_-_amazon_web_services
GeneXus
 
Composite Applications with SOA, BPEL and Java EE
Composite  Applications with SOA, BPEL and Java EEComposite  Applications with SOA, BPEL and Java EE
Composite Applications with SOA, BPEL and Java EE
Dmitri Shiryaev
 
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
BOSC 2010
 

Similaire à Ebay架构演变历程 (20)

E Bay Sd Forum2006 11 29
E Bay Sd Forum2006 11 29E Bay Sd Forum2006 11 29
E Bay Sd Forum2006 11 29
 
eBay Architecture
eBay Architecture eBay Architecture
eBay Architecture
 
How to Introduce Continuous Delivery
How to Introduce Continuous DeliveryHow to Introduce Continuous Delivery
How to Introduce Continuous Delivery
 
Randy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural PrinciplesRandy Shoup eBays Architectural Principles
Randy Shoup eBays Architectural Principles
 
Pstrong Cybera 29 Sept 2008
Pstrong Cybera 29 Sept 2008Pstrong Cybera 29 Sept 2008
Pstrong Cybera 29 Sept 2008
 
Call to action move to the evolutions
Call to action move to the evolutionsCall to action move to the evolutions
Call to action move to the evolutions
 
Move SAP to Cloud in 3 Easy Steps
Move SAP to Cloud in 3 Easy StepsMove SAP to Cloud in 3 Easy Steps
Move SAP to Cloud in 3 Easy Steps
 
Building a Website to Scale to 100 Million Page Views Per Day and Beyond
Building a Website to Scale to 100 Million Page Views Per Day and Beyond Building a Website to Scale to 100 Million Page Views Per Day and Beyond
Building a Website to Scale to 100 Million Page Views Per Day and Beyond
 
Premium Website Hosting
Premium Website HostingPremium Website Hosting
Premium Website Hosting
 
039 keynote mike-culver_-_amazon_web_services
039 keynote mike-culver_-_amazon_web_services039 keynote mike-culver_-_amazon_web_services
039 keynote mike-culver_-_amazon_web_services
 
Scaling Continuous Integration Practices to Teams with Parallel Development
Scaling Continuous Integration Practices to Teams with Parallel DevelopmentScaling Continuous Integration Practices to Teams with Parallel Development
Scaling Continuous Integration Practices to Teams with Parallel Development
 
Composite Applications with SOA, BPEL and Java EE
Composite  Applications with SOA, BPEL and Java EEComposite  Applications with SOA, BPEL and Java EE
Composite Applications with SOA, BPEL and Java EE
 
JBoss Analyst tour Sept 2003
JBoss Analyst tour Sept 2003JBoss Analyst tour Sept 2003
JBoss Analyst tour Sept 2003
 
Scalable Lifecycle Management via Perforce
Scalable Lifecycle Management via PerforceScalable Lifecycle Management via Perforce
Scalable Lifecycle Management via Perforce
 
The Boundaryless Value-Chain
The Boundaryless Value-ChainThe Boundaryless Value-Chain
The Boundaryless Value-Chain
 
Scaling up to 30M users - The Wix Story
Scaling up to 30M users - The Wix StoryScaling up to 30M users - The Wix Story
Scaling up to 30M users - The Wix Story
 
IBC 2010 press conference
IBC 2010 press conferenceIBC 2010 press conference
IBC 2010 press conference
 
Inside Wordnik's Architecture
Inside Wordnik's ArchitectureInside Wordnik's Architecture
Inside Wordnik's Architecture
 
Lessons Learned From Internal Communities
Lessons Learned From Internal CommunitiesLessons Learned From Internal Communities
Lessons Learned From Internal Communities
 
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
 

Plus de yiditushe

Spring入门纲要
Spring入门纲要Spring入门纲要
Spring入门纲要
yiditushe
 
J Bpm4 1中文用户手册
J Bpm4 1中文用户手册J Bpm4 1中文用户手册
J Bpm4 1中文用户手册
yiditushe
 
性能测试实践2
性能测试实践2性能测试实践2
性能测试实践2
yiditushe
 
性能测试实践1
性能测试实践1性能测试实践1
性能测试实践1
yiditushe
 
性能测试技术
性能测试技术性能测试技术
性能测试技术
yiditushe
 
Load runner测试技术
Load runner测试技术Load runner测试技术
Load runner测试技术
yiditushe
 
J2 ee性能测试
J2 ee性能测试J2 ee性能测试
J2 ee性能测试
yiditushe
 
面向对象的Js培训
面向对象的Js培训面向对象的Js培训
面向对象的Js培训
yiditushe
 
Flex3中文教程
Flex3中文教程Flex3中文教程
Flex3中文教程
yiditushe
 
开放源代码的全文检索Lucene
开放源代码的全文检索Lucene开放源代码的全文检索Lucene
开放源代码的全文检索Lucene
yiditushe
 
基于分词索引的全文检索技术介绍
基于分词索引的全文检索技术介绍基于分词索引的全文检索技术介绍
基于分词索引的全文检索技术介绍
yiditushe
 
Lucene In Action
Lucene In ActionLucene In Action
Lucene In Action
yiditushe
 
Lucene2 4学习笔记1
Lucene2 4学习笔记1Lucene2 4学习笔记1
Lucene2 4学习笔记1
yiditushe
 
Lucene2 4 Demo
Lucene2 4 DemoLucene2 4 Demo
Lucene2 4 Demo
yiditushe
 
Lucene 全文检索实践
Lucene 全文检索实践Lucene 全文检索实践
Lucene 全文检索实践
yiditushe
 
7 面向对象设计原则
7 面向对象设计原则7 面向对象设计原则
7 面向对象设计原则
yiditushe
 
10 团队开发
10  团队开发10  团队开发
10 团队开发
yiditushe
 
9 对象持久化与数据建模
9  对象持久化与数据建模9  对象持久化与数据建模
9 对象持久化与数据建模
yiditushe
 
8 Uml构架建模
8  Uml构架建模8  Uml构架建模
8 Uml构架建模
yiditushe
 
6 架构设计
6  架构设计6  架构设计
6 架构设计
yiditushe
 

Plus de yiditushe (20)

Spring入门纲要
Spring入门纲要Spring入门纲要
Spring入门纲要
 
J Bpm4 1中文用户手册
J Bpm4 1中文用户手册J Bpm4 1中文用户手册
J Bpm4 1中文用户手册
 
性能测试实践2
性能测试实践2性能测试实践2
性能测试实践2
 
性能测试实践1
性能测试实践1性能测试实践1
性能测试实践1
 
性能测试技术
性能测试技术性能测试技术
性能测试技术
 
Load runner测试技术
Load runner测试技术Load runner测试技术
Load runner测试技术
 
J2 ee性能测试
J2 ee性能测试J2 ee性能测试
J2 ee性能测试
 
面向对象的Js培训
面向对象的Js培训面向对象的Js培训
面向对象的Js培训
 
Flex3中文教程
Flex3中文教程Flex3中文教程
Flex3中文教程
 
开放源代码的全文检索Lucene
开放源代码的全文检索Lucene开放源代码的全文检索Lucene
开放源代码的全文检索Lucene
 
基于分词索引的全文检索技术介绍
基于分词索引的全文检索技术介绍基于分词索引的全文检索技术介绍
基于分词索引的全文检索技术介绍
 
Lucene In Action
Lucene In ActionLucene In Action
Lucene In Action
 
Lucene2 4学习笔记1
Lucene2 4学习笔记1Lucene2 4学习笔记1
Lucene2 4学习笔记1
 
Lucene2 4 Demo
Lucene2 4 DemoLucene2 4 Demo
Lucene2 4 Demo
 
Lucene 全文检索实践
Lucene 全文检索实践Lucene 全文检索实践
Lucene 全文检索实践
 
7 面向对象设计原则
7 面向对象设计原则7 面向对象设计原则
7 面向对象设计原则
 
10 团队开发
10  团队开发10  团队开发
10 团队开发
 
9 对象持久化与数据建模
9  对象持久化与数据建模9  对象持久化与数据建模
9 对象持久化与数据建模
 
8 Uml构架建模
8  Uml构架建模8  Uml构架建模
8 Uml构架建模
 
6 架构设计
6  架构设计6  架构设计
6 架构设计
 

Ebay架构演变历程

  • 1. The eBay Architecture Striking a balance between site stability, feature velocity, performance, and cost . nc ,I SD Forum 2006 ay eB Presented By: Randy Shoup and Dan Pritchett Date: November 29, 2006
  • 2. What we’re up against • eBay manages … – Over 212,000,000 registered users – Over 1 Billion photos A sportingis soldsells every 2 seconds An SUV good every 5 minutes – eBay users worldwide trade more than $1590 . worth of goods every second nc – eBay averages over 1 billion page views per day – At any given time, there are approximately ,I 105 million listings on the site – eBay stores over 2 Petabytes of data – over per month ay 200 times the size of the Library of Congress! – The eBay platform handles 3 billion API calls Over ½ Million pounds of Kimchi are sold every year! eB • In a dynamic environment – 300+ features per quarter – We roll 100,000+ lines of code every two weeks • In 33 countries, in seven languages, 24x7 >26 Billion SQL executions/day! 2 © 2006 eBay Inc.
  • 3. eBay’s Exponential Growth 105 Million Listings . nc ,I ay 212 Million Users eB Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3 1998 1999 2000 2001 2002 2003 2004 2005 2006 4 © 2006 eBay Inc.
  • 4. Velocity of eBay -- Software Development Process Feature 212M Users . 300+ Features nc Feature Train 99.94% Per Quarter ,I Feature 100K LOC/Wk 6M LOC ay • Our site is our product. We change it incrementally through implementing new features. eB • Very predictable development process – trains leave on-time at regular intervals (weekly). • Parallel development process with significant output -- 100,000 LOC per release. • Always on – over 99.94% available. All while supporting a 24x7 environment 5 © 2006 eBay Inc.
  • 5. Systemic Requirements Availability Reliability Enable seamless growth Massive Scalability Security . nc ,I Maintainability Deliver quality functionality at Faster Product Delivery ay accelerating rates eB Architect for the future Enable rapid business innovation 10X Growth 6 © 2006 eBay Inc.
  • 6. Architectural Lessons • Scale Out, Not Up – Horizontal scaling at every tier. – Functional decomposition. . nc • Prefer Asynchronous Integration – Minimize availability coupling. ,I – Improve scaling options. • Virtualize Components ay – Reduce physical dependencies. – Improve deployment flexibility. eB • Design for Failure – Automated failure detection and notification. – “Limp mode” operation of business features. 7 © 2006 eBay Inc.
  • 7. Ongoing Platform Evolution… 212M Registered Users . nc ,I V1 1998 1999 2000 ay 2001 2002 2003 2004 2005 Q3 2006 eB V2.0 V2.3 V2.4 V2.5 V3 V4 eBay architecture versions 8 © 2006 eBay Inc.
  • 8. V1.0 1995-September 1997 • Built over a weekend in Pierre Omidyar’s living room in 1995 • System hardware was made up of parts that could be bought at Fry's • Every item was a separate file, generated by a Perl script • No search functionality, only category browsing . nc ,I ay eB This system maxed out at 50,000 active items 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 9 © 2006 eBay Inc.
  • 9. V2.0 September 1997- February 1999 • 3-tiered conceptual architecture (separation of bus/pres and db access tiers) • 2-tiered physical implementation (no application server) • C++ Library (eBayISAPI.dll) running on IIS on Windows • Microsoft index server used for search • Items migrated from GDBM to an Oracle database on Solaris . nc ,I ay eB 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 10 © 2006 eBay Inc.
  • 10. V2.1 February 1999-November 1999 • Servers grouped into pools (small soldiers) • Resonate used for front end load balancing and failover • Search functionality moved to the Thunderstone indexing system • Back-end Oracle database server scaled vertically to a larger machine (Sun E10000) . nc ,I ay eB 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 11 © 2006 eBay Inc.
  • 11. V2.3 June 1999-November 1999 • Second Database added for failover • CGI pools, Listings, Pages, and Search continued to scale horizontally However … . nc By November 1999, the database servers approached their limits of physical growth. ,I ay eB 12 © 2006 eBay Inc.
  • 12. V2.4 November 1999-April 2001 • Database "split" technology. • Logically partition database into separate instances. • Horizontal scalability through 2000, but not beyond. . nc ,I ay eB 13 © 2006 eBay Inc.
  • 13. V2.5 April 2001 – December 2002 • Horizontal scalability through database splits • Items split by category • SPOF elimination . nc User Write User Read FEEDBACK BATCH JOBS ACCOUNTS ARCHIVE BATCH JOBS ,I Bull CATY 1 CATY 2 CATY 3 CATY 4 Bear ay CATY 5 CATY 6 CATY 7 CATY 8 Tran eB Scratch CATY 9 CATY 10 CATY 11 CATY 12 December, 2002 November, 1999 SUN SUN 14 A3500 © 2006 eBay Inc.
  • 14. Now that we have the Database taken care of…. • Application Server – Monolithic 2-tier Architecture – 3.3 Million Line C++ ISAPI DLL (150MB binary) . nc – Hundreds of developers, all working on the same code – Hitting compiler limits on number of methods per class (!!) ,I ay eB 15 © 2006 eBay Inc.
  • 15. V3 – Replace C++/ISAPI with Java 2002-present • Re-wrote the entire application in J2EE application server framework – Gave us a chance to architect the code for reuse and separation of duties • Leveraged the MSXML framework for the presentation layer . nc – Minimizing the development cost for migration • Implemented a development kernel as a foundation for programmers ,I – Allowed for rapid training and deployment of new engineers ay eB 16 © 2006 eBay Inc.
  • 16. Scaling the Data Tier . nc ,I ay eB
  • 17. Scaling the Data Tier: Overview • Spread the Load – Segmentation by function. – Horizontal splits within functions. . nc • Minimize the Work – Limit in database work ,I • The Tricks to Scaling – How to survive without transactions. ay – Creating alternate database structures. eB 18 © 2006 eBay Inc.
  • 18. Scaling the Data Tier: Functional Segmentation • Segment databases into functional areas – User hosts – Item hosts . – Account hosts nc – Feedback hosts – Transaction hosts ,I – And about 70 more functional categories • Rationale ay – Partitions data by different scaling / usage characteristics eB – Supports functional decoupling and isolation 19 © 2006 eBay Inc.
  • 19. Scaling the Data Tier: Horizontal Split • Split databases horizontally by primary access path. • Different patterns for different use cases . – Write Master/Read Slaves nc – Segmentation by data; Two approaches • Modulo on a key, typically the primary key. ,I Simple data location if you know the key Not so simple if you don’t. • Map to data location ay Supports multiple keys. Doubles reads required to locate data. eB SPOF elimination on map structure is complex. • Rationale – Horizontal scaling of transactional load. – Segment business impact on database outage. 20 © 2006 eBay Inc.
  • 20. Scaling the Data Tier: Logical Database Hosts • Separate Application notion of a database from physical implementation • Databases may be combined and separated with no code changes • Reduce cost of creating multiple environments (Dev, QA, …) . nc Application Servers ,I Attributes Catalogs Rules CATY Account Feedback Misc API SCRATCH 1..N User ay eB DB1 DB2 DB3 21 © 2006 eBay Inc.
  • 21. Scaling the Data Tier: Minimize DB Resources • No business logic in database – No stored procedures – Only very simple triggers (default value population) . nc • Move CPU-intensive work to applications – Referential Integrity ,I – Joins – Sorting ay • Extensive use of prepared statements and bind variables eB 22 © 2006 eBay Inc.
  • 22. Scaling the Data Tier: Minimize DB Transactions • Auto-commit for vast majority of DB writes • Absolutely no client side transactions – Single database transactions managed through anonymous PL/SQL blocks. . nc – No distributed transactions. • How do we pull it off? ,I – Careful ordering of DB operations – Recovery through • Reconciliation batch • Failover to async flow ay • Asynchronous recovery events eB • Rationale – Avoid deadlocks – Avoid coupling availability – Update concurrency – Seamless handling of splits 23 © 2006 eBay Inc.
  • 23. Scaling the Application Tier . nc ,I ay eB
  • 24. Scaling the Application Tier – Overview • Spread the Load – Segmentation by function. – Horizontal load-balancing within functions. . nc • Minimize dependencies – Between applications ,I – Between functional areas – From applications to data tier resources • Virtualize data access ay eB 25 © 2006 eBay Inc.
  • 25. Scaling the Application Tier – Massively Scaling J2EE • Step 1 - Throw out most of J2EE – eBay scales on servlets and a rewritten connection pool. • Step 2 – Keep Application Tier Completely Stateless . nc – No session state in application tier – Transient state maintained in cookie or scratch database ,I • Step 3 – Cache Where Possible – Cache common metadata across requests, with sophisticated cache refresh procedures ay – Cache reload from local storage eB – Cache request data in ThreadLocal 26 © 2006 eBay Inc.
  • 26. Scaling the Application Tier – Tiered Application Model • Strictly partition application into tiers •Presentation •Business •Integration . nc XSL Presentation Tier ,I Command (View) XML Model AO/AOF (View) Building Logic Business Tier ay BO/BOF Business Logic eB Integration Tier DO/DAO Data Access Layer (DAL) 27 © 2006 eBay Inc.
  • 27. Scaling the Application Tier – Data Access Layer (DAL) • What is the DAL? – eBay’s internally-developed pure Java OR mapping solution. – All CRUD (Create Read Update Delete) operations are performed . nc through DAL’s abstraction of the data. – Enables horizontal scaling of the Data tier without application code ,I changes • Dynamic Data Routing abstracts application developers from – Database splits ay – Logical / Physical Hosts eB – Markdown – Graceful degradation • Extensive JDBC Prepared Statements cached by DataSources 28 © 2006 eBay Inc.
  • 28. Scaling the Application Tier – Vertical Code Partitioning • Partition code into functional areas • Application is specific to a single area (Selling, Buying, etc.) • Domain contains common business logic across Applications . • Restrict inter-dependencies nc • Applications depend on Domains, not on other Applications • No dependencies among shared Domains ,I UserApplication SellingApplication BuyingApplication BillingApplication SearchApplication Applications UserDomain SellingDomain ay BuyingDomain BillingDomain SearchDomain eB PersonalizationDomain UserValidationDomain SharedBillingDomain Shared SharedBuyingDomain myEbayDomain SharedSearchDomain Domains Core-Domain API Domain 29 LookupDomain © 2006 eBay Inc.
  • 29. Scaling the Application Tier – Functional Segmentation • Segment functions into separate application pools • Minimizes / isolates DB dependencies • Allows for parallel development, deployment, and monitoring ViewItem Pool SYI Pool . nc http://cgi.ebay.com … http://cgi5.ebay.com … CGI0 CGI5 Load Balancing … … ,I IIS WebServers IIS ay IIS IIS IIS eB AppServers Load Balancing AS AS AS AS AS AS Load Balancing 30 User Acct Caty1 … Caty20+ © 2006 eBay Inc.
  • 30. Scaling the Application Tier – Platform Decoupling • Domain Partitioning for Deployment – Decouple non-transactional domains from transactional flows • Search and billing domains are not required in transaction processing. . • Fraud domain is required but easier to manage as separate deployment. nc – Integrate with a combination of asynchronous EDA and synchronous SOA patterns. ,I ay Transaction Platform eB SOA EDA EDA Billing Search Fraud 31 © 2006 eBay Inc.
  • 31. Scaling Search . nc ,I ay eB
  • 32. Scaling Search – Overview • In 2002, eBay search had reached its limits – Cost of scaling third-party search engine had become prohibitive – 9 hours to update the index – Running on largest systems vendor sold – and still not keeping up . nc • eBay has unique search requirements – Real-time updates • Update item on any change (list, bid, sale, etc.) ,I • Users expect changes to be visible immediately – Exhaustive recall ay • Sellers notice if search results miss any item • Search results require data (“histograms”) from every matching item eB – Flexible data storage • Keywords • Structured categories and attributes • No off-the-shelf product met these needs 33 © 2006 eBay Inc.
  • 33. Scaling Search – Voyager • Real-time feeder infrastructure – Reliable multicast from primary database to search nodes • Real-time indexing . nc – Search nodes update index in real time from messages • In-memory search index ,I • Horizontal segmentation ay – Search index divided into N slices (“columns”) – Each slice is replicated to M instances (“rows”) eB – Aggregator parallelizes query over all N slices, load-balances over M instances • Caching – Cache results for highly expensive and frequently used queries 34 © 2006 eBay Inc.
  • 34. Scaling Operations . nc ,I ay eB
  • 35. Scaling Operations – Code Deployment • Demanding Requirements – Entire site rolled every 2 weeks – All deployments require staged rollout with immediate rollback if necessary. . – More than 100 WAR configurations. nc – Dependencies exist between pools during some deployment operations. – More than 15,000 instances across eight physical data centers. ,I • Rollout Plan – Custom application that works from dependencies provided by projects. ay – Creates transitive closure of dependencies. – Generates rollout plan for Turbo Roller. eB • Automated Rollout Tool (“Turbo Roller”) – Manages full deployment cycle onto all application servers. – Executes rollout plan. – Built in checkpoints during rollout, including approvals. – Optimized rollback, including full rollback of dependent pools. 37 © 2006 eBay Inc.
  • 36. Scaling Operations – Monitoring • Centralized Activity Logging (CAL) – Transaction oriented logging per application server • Transaction boundary starts at request. Nested transactions supported. . nc • Detailed logging of all application activity, especially database and other external resources. • Application generated information and exceptions can be reported. ,I – Logging streams gathered and broadcast on a message bus. • Subscriber to log to files (1.5TB/day) ay • Subscriber to capture exceptions and generate operational alerts. • Subscriber for real time application state monitoring. eB – Extensive Reporting • Reports on transactions (page and database) per pool. • Relationships between URL’s and external resources. • Inverted relationships between databases and pools/URL’s. • Data cube reporting on several key metrics available in near real time. 38 © 2006 eBay Inc.
  • 37. Recap Availability Enabling seamless growth Reliability Massive Scalability • Massive Database and Code Scalability . Security nc Delivering quality functionality at ,I Maintainability accelerating rates Faster Product Delivery ay • Further streamline and optimize the eBay development model eB Architecting for Enabling rapid business innovation the future 10X Growth 39 © 2006 eBay Inc.