关于“Spring at China Scale: Alibaba Group (Alipay, TaoBao, and TMall)”这一主题,可以从以下几个方面来探讨Spring框架在阿里巴巴集团(特别是支付宝、淘宝和天猫)的大规模应用:
一、阿里巴巴集团与Spring框架的渊源
阿里巴巴集团是全球领先的电子商务和科技公司,其业务涵盖了电子商务、云计算、数字娱乐和金融科技等多个领域。在阿里巴巴集团的技术栈中,Spring框架扮演了重要的角色。
二、Spring在阿里巴巴集团的应用
-
支付宝(Alipay)
- 支付宝是全球领先的第三方支付平台,其背后的技术系统复杂且庞大。在支付宝的技术架构中,Spring框架被广泛应用于服务层的开发,帮助实现业务逻辑的解耦和模块化。
- 通过Spring的依赖注入(DI)和面向切面编程(AOP)特性,支付宝的开发人员能够更高效地管理和维护代码,提高开发效率。
-
淘宝(Taobao)和天猫(Tmall)
- 淘宝和天猫作为阿里巴巴集团旗下的电商平台,拥有海量的用户和商家。为了支撑如此庞大的业务规模,淘宝和天猫的技术团队采用了Spring Cloud等Spring家族的技术栈,构建了微服务架构。
- 在微服务架构中,Spring Cloud提供了服务注册与发现、配置管理、负载均衡等功能,帮助淘宝和天猫实现了服务的弹性扩展和高效运维。
- 同时,Spring框架的轻量级和灵活性也使得淘宝和天猫能够更快速地响应市场变化,推出新的业务功能。
三、Spring在阿里巴巴集团的应用成效
-
提高开发效率
- Spring框架的简化配置和依赖注入等特性,使得阿里巴巴集团的开发人员能够更专注于业务逻辑的实现,提高了开发效率。
-
提升系统稳定性
- 通过Spring Cloud等微服务架构的引入,阿里巴巴集团的系统实现了更细粒度的服务划分和更灵活的部署策略,提升了系统的稳定性和可用性。
-
促进业务创新
- Spring框架的轻量级和灵活性为阿里巴巴集团的业务创新提供了有力支持。开发人员能够更快速地响应市场变化,推出新的业务功能,满足用户的多样化需求。
四、总结
Spring框架在阿里巴巴集团(特别是支付宝、淘宝和天猫)的大规模应用中取得了显著的成效。它不仅提高了开发效率,还提升了系统的稳定性和可用性,促进了业务的创新和发展。随着技术的不断进步和业务的不断发展,相信Spring框架在阿里巴巴集团的应用将会更加广泛和深入。
此外,值得注意的是,阿里巴巴集团不仅是Spring框架的用户,还在Spring的基础上进行了创新。例如,阿里巴巴集团开源了诸多基于Spring Cloud的组件和框架,如Nacos(服务注册与发现、配置管理解决方案)、Sentinel(流量控制、熔断降级组件)等,为Spring社区贡献了自己的力量。这些组件和框架的广泛应用也进一步验证了Spring框架在大型互联网企业中的价值和潜力。
Spring框架在支付宝中的应用非常广泛,主要体现在以下几个方面:
一、服务架构与微服务
支付宝作为一个庞大的支付平台,其业务复杂且用户量巨大。为了应对这种挑战,支付宝采用了微服务架构,而Spring框架中的Spring Cloud组件为微服务的实现提供了有力支持。Spring Cloud提供了服务注册与发现、配置管理、负载均衡、断路器等一系列功能,帮助支付宝构建了一个高可用性、可扩展性的服务架构。
二、业务逻辑开发
在支付宝的业务逻辑开发中,Spring框架也发挥了重要作用。Spring的依赖注入(DI)和面向切面编程(AOP)特性,使得开发人员能够更轻松地实现业务逻辑的解耦和模块化。通过Spring的注解和配置,开发人员可以快速地将不同的业务组件组合在一起,形成完整的业务流程。
三、支付功能实现
支付宝的核心功能是支付,而Spring框架在支付功能的实现中也扮演了关键角色。Spring框架提供了丰富的工具类和库,可以帮助开发人员更方便地处理支付请求、验证支付结果、处理支付异常等情况。此外,Spring框架还支持与多种支付渠道进行集成,如银行卡支付、快捷支付、扫码支付等,为支付宝提供了多样化的支付方式。
四、安全性与稳定性
在支付领域,安全性和稳定性是至关重要的。Spring框架提供了一系列的安全机制,如Spring Security,可以帮助开发人员实现身份认证、授权、加密等安全功能,确保支付过程的安全性。同时,Spring框架还提供了丰富的监控和日志功能,可以帮助开发人员及时发现并处理系统中的问题,确保系统的稳定性。
五、开发效率与团队协作
Spring框架的轻量级和灵活性使得开发人员能够更快速地响应业务需求,提高开发效率。此外,Spring框架还提供了丰富的文档和社区支持,使得开发人员能够更容易地学习和使用框架。在团队协作方面,Spring框架也提供了良好的支持,如Spring Boot的自动配置特性可以减少配置文件的工作量,使得团队成员能够更专注于业务逻辑的实现。
六、实际案例
在支付宝的实际开发中,Spring框架已经被广泛应用于各个业务场景。例如,在支付宝的订单处理系统中,Spring框架被用于实现订单的创建、支付、退款等功能;在支付宝的风控系统中,Spring框架被用于实现风险识别、风险评估等功能。这些实际案例充分证明了Spring框架在支付宝中的价值和作用。
概括而言,Spring框架在支付宝中的应用非常广泛且深入。它不仅帮助支付宝构建了高可用性、可扩展性的服务架构,还提高了开发效率、确保了系统的安全性和稳定性。随着业务的不断发展和技术的不断进步,相信Spring框架在支付宝中的应用将会更加广泛和深入。
Some of the companies of
the Alibaba group
The challenges inherent to building enterprise applications that meet China-scale demand are unparalleled. One exemplary Chinese organization using Spring heavily to solve very unique challenges is the Alibaba group. Alibaba is itself an online auction site, like eBay in the west. The Alibaba group in turn owns a few other online service companies, like Alipay (a secure transaction processor, like PayPal in the west), TaoBao (a comparison shopping engine, like Shopzilla in the west), and TMall (an e-tailer, exposing the catalogues of merchants, like Amazon in the west).
From the InfoQ article, “on 11 November, 2012 (the Double Sticks promotion day), Tmall and Taobao witnessed 147 million user visits, purchases of 30 million people and nearly 100 million paid orders. At 0:00, more than 10 million users were concurrently online.” The “double sticks promotion day” is celebrated as a sort of day to honor the single people out there. People make blind-dates, attend speed-dating events, and - somewhat like cyber monday shopping in the US - look for good deals from merchants. TaoBao reported USD $3 billion dollars for a single 24 hour period. That’s almost triple the entire 2011 Black Friday sales of two of the largest e-commerce sites (combined) in the United States! Now that’s awesome scale!
The Alibaba group has never been shy about talking about what they’re doing and how they’re doing it. They were kind enough to come to the SpringOne Beijing event in December, 2012, where they explained at great length how they’re using Spring to meet their unique challenges.
So, what’s it take to handle China scale? Unsurprisingly, quite a bit! Each company had its own specific needs and use cases, and developed quite a bit of custom infrastructure and middleware to meet those demands. The architectures in a lot of ways mirror the architectures described by architects at Twitter, Facebook and Google over the years. The difference is that, by building on the Spring framework, they didn’t have to go it alone, and could get to production quicker. The Spring framework underpinned all of these organizations, providing a common POJO-centric framework and idiom, while making software testing orders of magnitude simpler. Talented architects, in many cases, built their own custom, use-case specific frameworks and middleware on top of Spring’s component model and runtime.
There are lots of pieces that are common across these organizations. Each organization deals with massive amounts of data and needs a scalable services and cross-service communication. Generally, these engines support the concept of a registry, which knows about which services are up in network topologies, which are available, as well as the RPC contracts supported by type. A registry like this knows how to configure each instance with an eye towards the whole network topology. Each organization uses messaging to connect systems in a reliable, fast way. Each organization has achieved optimum scale by decomposing their services and scaling each service independently. This decomposition implies that services aren’t collocated, and must now incur the cost of network communication. To keep network communication to a minimum, efficiently conveyed binary representations of data with known contracts are used. Finally, to expose these services to their users, they build highly optimized, almost stateless web applications.
Alibaba group is using a variety of Pivotal technology in many different places. Above and beyond using core Spring, they’re also using Spring MVC, Spring Security, and Groovy in varying configurations and uses.
They’ve also taken advantage of the deep flexibility that Spring provides and built their own frameworks on top of Spring. It’s worth noting that a lot of this code is available online as open-source.
The topology of a Dubbo cluster
There are actually a couple of different approaches to services in play at the Alibaba group, for different reasons. One approach is called Dubbo. Dubbo is a high performance services framework. It makes it easy to export and consume services through various modes of RPC. It also makes it easy to cluster these services. The whole system is open source. You may get the code at GitHub.
Dubbo builds on top of many existing open-source components, including Apache Zookeeper, Redis, and, of course, Spring. It’s easy to see why Dubbo has become such a key part of the stack, serving more than 2,000 services with more than 3 billion invocations everyday. Dubbo has become a key part of Alibaba’s service-based solutions, and has been deployed to the whole Alibaba.com family.
You can easily setup and export services using Dubbo with the Spring namespace, which works like this:
<dubbo:application name=“hello-world-app” />
<dubbo:registry address=“multicast://224.5.6.7:1234” />
<dubbo:protocol name=“dubbo” port=“20880” />
<dubbo:service interface=“com.alibaba.dubbo.demo.DemoService” ref=“demoService” />
Consuming a service is just as easy. On the client, you use the dubbo:reference element in the Dubbo namespace to bind a proxy by interface. Then, you may inject a reference to that proxy to any service that needs it, like this:
<!-- consumer application name -->
<dubbo:application name="consumer-of-helloworld-app" />
<!-- registry address, used for consumer to discover services -->
<dubbo:registry address="multicast://224.5.6.7:1234" />
<!-- which service to consume? -->
<dubbo:reference id="demoService" interface="com.alibaba.dubbo.demo.DemoService" />
SOFA architecture
Another approach to services that’s used specifically at Alipay is a project they call SOFA, which also supports the easy export and consumption of services in a distributed (and, importantly, collocated environment). SOFA offers many different styles of RPC, with multiple bindings available. It is similarly easy to export services using SOFA, like this:
<sofa:service ref=“beanId” interface=“MyInterface”>
sofa:binding.ws/
</sofa:service>
<sofa:reference id=“refId” interface=“MyInterface”>
sofa:binding.ws/
sofa:reference/
You can configure lots of different types of bindings, beyond <sofa:service.ws />, for example: sofa:binding.tr, sofa:binding.msg, and sofa:binding.http SOFA components
SOFAMVC architecture
While SOFA is itself very interesting, what I really like is that they’ve built a SOFA-architecture aware version of Spring MVC called SOFA MVC. SOFA MVC provides extensions to Spring MVC, including certain optimizations to Velocity template rendering, data mocking support, A/B test support, specific protection against certain security exploits (XSS, CSRF, upload filtration, and cookies) based on Spring Security. Additionally, they’ve built their own deployment and runtime, offering features like Spring application context isolation and Servlet 3-style Java configuration.
This integrated runtime approach has proven very powerful, and the next step for their very unique requirements is to migrate away from heavier runtimes like JBoss and move to a home-grown, tailor-made, lighter weight and customized container like Eclipse Virgo. They believe that OSGi is a powerful and effective microkernel, and provides for an extensible architecture. They enjoy the isolation it provides multiple deployments on the same machine (at that scale, they try to collocate and re-use as much of an application server as possible!), and they like that service specification that OSGi requires.
I would advise anyone who has the chance to take a look at the open source projects at Alibaba group. My visit to their organization was really valuable. I learned a lot about how they’re changing the world. They had some feedback to give me, as well, and that has all gone back into engineering at SpringSource so that you, the community, can benefit from the advances and Alibaba has made, one transaction at a time. I personally want to thank JingYu Wang, XinSheng Wang, Ding Li, and LeWei Zhang at TaoBao; Zhuoran Zhuang, ChangDing Liu, Fei Liang, FuQiang Wang at TMall; Bing Yang , Lei Wang at Alipay; and - particularly - XueFeng Ding (also from Alipay) who helped organize the whole, amazing in-depth look at the way the Alibaba group is using Spring.
comments powered by Disqus
构建满足中国规模需求的企业应用程序所面临的挑战是无与伦比的。阿里巴巴集团(Alibaba group)是一个典型的中国组织,它大量使用Spring来解决非常独特的挑战。阿里巴巴本身就是一个在线拍卖网站,就像西方的eBay一样。阿里巴巴集团还拥有其他几家在线服务公司,如支付宝(一种安全的交易处理器,如西方的PayPal)、淘宝(一种比较购物引擎,如西方的Shopzilla)和天猫(一家电子零售商,揭露了西方的亚马逊等商家的商品目录)。
从InfoQ的文章来看,“2012年11月11日(双棒促销日),天猫和淘宝的用户访问量达到1.47亿,购买量达到3000万,支付订单近1亿。在0:00,超过1000万的用户同时在线。“双棒促销日”是一种纪念单身人士的节日。人们相亲,参加速配活动,还有——有点像美国的网络星期一购物——从商家那里寻找好的交易。淘宝网的报告显示,在一个24小时的时间里,淘宝网的销售额达到了30亿美元。这几乎是2011年黑色星期五美国最大的两个电子商务网站(合计)销售额的三倍!现在这是可怕的规模!