最新消息:

ebay 电子商务平台研究(2)-ebay architecture

互联网金融 3448浏览 4评论

4、ebay系统架构

4.1、架构度量标准

搭建高扩展性的系统架构是每一个架构师的口号,又有几个实现了这样的承诺?什么叫架构的高扩展性,我自己一直也没有明确的答案,ebay的架构师Dan Pritchett在其blog上的一篇文章You Scaled Your What?,对架构的高扩展性的维度要素进行了较为精辟的阐述:

  • Transactional
  • Data
  • Operational
  • Deployability
  • Productivity
  • Feature TTM

尤其值得注意的是他把系统的运营性、易部署作为架构扩展的重要指标提出,很好的实践性经验总结。对于大部分的互联网公司而言,“以软件作为服务”,运营效率、运营成本是核心的竞争力之一;在需求变更频繁、迭代时间较短、需要部署服务器众多的情况下,怎样在不影响生产系统业务运行的前提下,实现代码快速、安全的上线部署,直接影响能否及时响应需求变更和服务质量。因此在架构搭建、程序开发过程中一定要考虑系统的可维护性、可运营性以及部署上线的要求。

4.2、架构目标

高可用性、高可靠性、高扩展性、高安全性:支撑系统无缝的增长,保证大容量数据库和代码的扩展性

高可维护性,更快的产品交付:以加速度交付高质量的功能,更进一步精简和优化ebay的开发模型

为未来而架构:支撑10倍速的增长,支撑快速的业务革新

 

 

4.3、架构

image

 image

 

 

4.4、软件设计模式实践

http://au.sun.com/events/dev_forum/files/best_practices.pdf

http://gceclub.sun.com.cn/java_one_online/2003/TS-3264CHI(USA,2003)/ts3264ch.pdf

http://blog.spiralarm.com/richard/2006/12/billion-hits-a-day-ebay-javaone.pdf

image

image

 

5、架构最佳实践

• Scale Out, Not Up
– Horizontal scaling at every tier.
– Functional decomposition.
• Prefer Asynchronous Integration
– Minimize availability coupling.
– Improve scaling options.
• Virtualize Components
– Reduce physical dependencies.
– Improve deployment flexibility.
• Design for Failure
– Automated failure detection and notification.
– “Limp mode” operation of business feature

 

5.1、Data Tier(数据层)

5.1.1、功能分段(Functional Segmentation)

  通过对数据库数据按照功能进行分段(应该就是按照use case的领域模型或实体模型),可以将原来存储到一台数据库服务器的数据按照功能分布到不同数据库服务器上。例如User数据库、Item数据库、Account数据库等,ebay有多达70多种功能分类。 功能分段可以支持功能间的解耦和彼此独立性,在分段时候需要根据功能使用频率、扩展性等特征对不同数据进行分段。一个典型的例子就是应当把OLTP和OLAP的功能分段,分别在不同的服务器上进行处理。

  值得注意的是:ebay在应用服务器、数据库数据分区上是基于use case进行划分的,很好的度量标准,只是在use case的粒度定义上需要经验和技巧。

5.1.2、水平切割(Horizontal Split)

  按照所谓的主要存取路径“primary access path”进行水平切割。在模式上有多种。例如:写操作读取master数据库,读操作读取slave库;或者按照数据分段访问(按key、按Map to data location)

5.1.3、逻辑数据库主机(Logical Database Hosts)

    逻辑数据库主机应该是类似数据库中间件或统一的数据存取层以隔离数据的实际物理存储库。在自己实现时候最为简单的方案就是在应用层面各Use Case的DAO层应当能够使用不同的数据源(多个数据库),而不是只能使用统一的数据源配置信息。

5.1.4、降低数据库资源占用(Minimize DB Resources)

   不在数据库服务器处理具有业务逻辑的操作:无存储过程,只采用简单的触发器

   将CPU占用较大的操作移到应用程序来处理:包括对依赖完整性、Join、排序等操作都放到应用程序来处理。这也对,毕竟大部分应用数据库是瓶颈,而且应用服务器还是比数据库服务器配置低,成本也低。

   大量使用prepared statements 和绑定变量(bind variables)

5.1.5、减少数据库事务处理(Minimize DB Transactions)

  避免死锁情况,降低耦合性,并发更新,无缝处理切割数据的访问 

  对于大部分的数据库操作采用Auto Commit方式。

  完全没有使用客户端事务(程序代码):单数据库的事务采用数据库服务器端匿名的PL/SQL块来进行事务管理

  较少使用XA分布式事务。

      

5.2、Application Tier (应用层)

5.2.1、最大限度地扩展J2EE

没有使用大部分的J2EE特性,主要使用了JDBC、servlet和rewrite过得connection pool

保持应用层无状态性:在应用层没有session状态,状态迁移在cookie或数据库存取。

Cache所有能够cache的:Cache公用的metadata,采用复杂的cache刷新机制;Cache从本地存储重新装载(memory db?);Cache数据采用ThreadLocal模式,保证线程安全;

 

5.2.2、分层架构模型

严格按照J2EE规范,把应用画风华展现层(Presentation)、业务层(Business)、集成层(Integration)

应用服务器将不相互通信,不采用cluster方案。

 

5.2.3、数据访问层(Data Access Layer )

采用了ebay内部的存Java OR
mapping方案(类Hibernate)

所有的CRUD (Create Read Update Delete)操作都通过DAL的数据接口层操作。

在不变更代码的情况下支撑数据层的水平扩展(应该要修改配置文件吧?)

大量使用JDBC的Prepared Statements
动态的数据路由:Dynamic Data Routing(DDR) hides the physical location of data from developers by providing a mapping from logical names to physical tables and database servers on which they reside. eBay uses some scalability patterns to reduce complexity/latency. For example, on any given day, there are roughly 40 million distinct items for sale on eBay. These items are split amongst 20 different database servers. These details are hidden from developers-they access an Item object using its id (ItemID)-the exact server from which it is fetched is computed by DDR and queries are routed to that host+table at runtime.

DAL的failover机制:可以通过自动或手动方式监控数据源的可用性,在数据源不可用情况下能够自动按照预设的规则把数据源切换到备用主机,据说是在切换过程中用户的操作不会有中断。DAL的failover机制应该有点类似HA或Clsuter的功能(是F5?),只是其实时性、动态性怎样实现的,值得学习。

 
5.2.4、代码垂直分区(Vertical Code Partitioning)

按功能对代码进行分区:应用细粒度化,只操作单一区的数据(例如Selling,Buying等);Domain包含了扩应用的公用业务逻辑(应该就是公用组件)

严格限定应用间的相互依赖性:应用最多只能依赖Domain,而不能依赖其他的应用;在公用的Domain间没有相互依赖关系

image

 

5.2.5、功能分段(Functional Segmentation )

将功能切分层独立的应用池

降低或隔离DB的依赖性

允许平行的开发、部署和监控

 

5.2.6、平台解耦(Platform Decoupling)

将无事务操作的Domain从有事务的流程中解耦出来。

通过异步的EDA和同步的SOA模式对应用进行集成

采用JMS实现子系统之间和与数据库的松耦合。

 

 

6、运营最佳实践

6.1、系统部署

• Demanding Requirements
– Entire site rolled every 2 weeks
– All deployments require staged rollout with immediate rollback if necessary.
– More than 100 WAR configurations.
– Dependencies exist between pools during some deployment operations.
– More than 15,000 instances across eight physical data centers.
• Rollout Plan
– Custom application that works from dependencies provided by projects.
– Creates transitive closure of dependencies.
– Generates rollout plan for Turbo Roller.
• 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 pool

6.2、网管监控

Centralized Activity Logging (CAL)
– Transaction oriented logging per application server
• Transaction boundary starts at request. Nested transactions supported.
• Detailed logging of all application activity, especially database and other external
resources.
• Application generated information and exceptions can be reported.
– Logging streams gathered and broadcast on a message bus.
• Subscriber to log to files (1.5TB/day)
• Subscriber to capture exceptions and generate operational alerts.
• Subscriber for real time application state monitoring.
– 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.

7、搜索优化(Scaling Search)

eBay的搜索引擎系统原来使用的是Thunderstone的系统,但到2002年时候就遇到了性能瓶颈,当时更新一次索引需要9个小时,使用了最高档的设备也满足不了需求。eBay对全文检索的要求很高,产品列表、竞标等信息要求实时更新、很多查询要求返回所有结果、存储有按关键字、分类和结构化属性组织等多种形式。由于没有现成产品能满足所有需求,eBay开发了自己的全文检索系统。

实时供给器平台负责将更新从主数据库可靠广播到多个检索节点,索引支持实时更新,支持内存索引。

索引系统是高度分布式的,索引机有多组副本,一组又包含多台机器。

缓存技术也被应用于搜索系统中,主要是缓存常用搜索或非常耗资源的搜索的结果。

8、平台开发接口

 

9、网络解决方案

http://www.sinogrid.com/shownews.asp?news_id=72

http://www.sinogrid.com/show_solution.asp?solution_id=43&cat_id=15

10、参考资料

10.1、产品研发相关

http://pages.ebay.com/community/chatter/2005november/insideebay.html

http://pages.ebay.com/community/chatter/2005december/insideebay.html

http://www.lukew.com/ff/entry.asp?318

http://www.slideshare.net/lukew/design-patterns-defining-and-sharing-web-design-languages

10.2、架构相关

http://www.artima.com/forums/flat.jsp?forum=106&thread=188683

http://www.addsimplicity.com/downloads/eBaySDForum2006-11-29.pdf

http://www.addsimplicity.com/adding_simplicity_an_engi/2006/11/you_scaled_your.html

http://www.eweek.com/article2/0,1759,2041437,00.asp

http://highscalability.com/ebay-architecture

http://www.infoq.com/interviews/dan-pritchett-ebay-architecture

http://glinden.blogspot.com/2006/12/talk-on-ebay-architecture.html

http://www.ddj.com/blog/architectblog/archives/2007/08/ad_2007_the_eba.html

http://blogs.zdnet.com/service-oriented/?p=675

http://itmanagement.earthweb.com/service/article.php/3531291

http://article.pchome.net/content-123538.html

http://pages.ebay.com/community/chatter/2005november/insideebay.html

http://designcult.typepad.com/designcult/files/Design_Patterns_IA_Summit_public.pdf

http://au.sun.com/events/dev_forum/files/best_practices.pdf

http://gceclub.sun.com.cn/java_one_online/2003/TS-3264CHI(USA,2003)/ts3264ch.pdf 

http://download.oracle.com/oowsf2004/1235_wp.pdf

转载请注明:出家如初,成佛有余 » ebay 电子商务平台研究(2)-ebay architecture

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (4)

  1. 分析的很不错。
    lizhantao17年前 (2007-11-09)回复
  2. http://www.informationweek.com.cn/iarticle/36091.html
    lizhantao17年前 (2007-11-09)回复
  3. I just hope whevoer writes these keeps writing more!
    Johnavon13年前 (2011-09-23)回复