您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Service Fabric 应用程序方案Service Fabric application scenarios

Azure Service Fabric 提供了一个可靠而灵活的平台,可用于编写和运行多种类型的商业应用程序和服务。Azure Service Fabric offers a reliable and flexible platform where you can write and run many types of business applications and services. 这些应用程序和微服务可以无状态也可以有状态,它们在各虚拟机间资源平衡,可最大限度提高工作效率。These applications and microservices can be stateless or stateful, and they're resource-balanced across virtual machines to maximize efficiency.

Service Fabric 的独特体系结构使你可以在应用程序中执行近实时数据分析、内存中计算、并行事务和事件处理。The unique architecture of Service Fabric enables you to perform near real-time data analysis, in-memory computation, parallel transactions, and event processing in your applications. 可以根据不断变化的资源要求轻松向上或向下缩放应用程序(其实是扩展或缩减)。You can easily scale your applications up or down (really in or out), depending on your changing resource requirements.

有关生成应用程序的设计指南, 请参阅Azure Service Fabric 上的微服务体系结构使用 Service Fabric 进行应用程序设计的最佳实践For design guidance on building applications, read Microservices architecture on Azure Service Fabric and Best practices for application design using Service Fabric.

对于以下类型的应用程序,请考虑使用 Service Fabric 平台:Consider using the Service Fabric platform for the following types of applications:

  • 数据收集、处理和 IoT:Service Fabric 通过其有状态服务实现大规模处理和低延迟。Data gathering, processing, and IoT: Service Fabric handles large scale and has low latency through its stateful services. 它可以帮助你处理数百万台设备上的数据(其中的设备数据和计算数据共置在一起)。It can help process data on millions of devices where the data for the device and the computation are colocated.

    已使用 Service Fabric 构建 IoT 服务的客户包括 HoneywellPCL ConstructionCrestronBMWSchneider ElectricMesh SystemsCustomers who have built IoT services by using Service Fabric include Honeywell, PCL Construction, Crestron, BMW, Schneider Electric, and Mesh Systems.

  • 游戏和基于会话的交互式应用程序:如果应用程序需要低延迟读取和写入(例如在线游戏或即时消息),Service Fabric 非常有用。Gaming and session-based interactive applications: Service Fabric is useful if your application requires low-latency reads and writes, such as in online gaming or instant messaging. 通过 Service Fabric,可生成这些交互式有状态应用程序,而无需创建单独的存储或缓存。Service Fabric enables you to build these interactive, stateful applications without having to create a separate store or cache. 有关在游戏服务中使用 Service Fabric 的设计指导,请访问 Azure 游戏解决方案Visit Azure gaming solutions for design guidance on using Service Fabric in gaming services.

    已构建游戏服务的客户包括 Next GamesDigamoreCustomers who have built gaming services include Next Games and Digamore. 已构建交互式会话的客户包括 Honeywell with HololensCustomers who have built interactive sessions include Honeywell with Hololens.

  • 数据分析和工作流处理:必须可靠处理事件或数据流的应用程序可受益于 Service Fabric 中的优化读取和写入。Data analytics and workflow processing: Applications that must reliably process events or streams of data benefit from the optimized reads and writes in Service Fabric. Service Fabric 还支持应用程序处理管道,其中的结果必须能够可靠地传递到下一个处理阶段而不会丢失。Service Fabric also supports application processing pipelines, where results must be reliable and passed on to the next processing stage without any loss. 这些管道包括交易和财务系统,其中的数据一致性和计算保证至关重要。These pipelines include transactional and financial systems, where data consistency and computation guarantees are essential.

    已构建业务工作流服务的客户包括 Zeiss GroupQuorum Business SolutionsSociété GeneralCustomers who have built business workflow services include Zeiss Group, Quorum Business Solutions, and Société General.

  • 数据计算:使用 Service Fabric 可以构建有状态应用程序来执行密集的数据计算。Computation on data: Service Fabric enables you to build stateful applications that do intensive data computation. Service Fabric 允许在应用程序中共置处理(计算)和数据。Service Fabric allows the colocation of processing (computation) and data in applications.

    一般情况下,当应用程序需要访问数据时,与外部数据缓存或存储层相关的网络延迟会限制计算时间。Normally, when your application requires access to data, network latency associated with an external data cache or storage tier limits the computation time. 使用 Service Fabric 有状态服务可消除这种延迟,使读取和写入得到进一步的优化。Stateful Service Fabric services eliminate that latency, enabling more optimized reads and writes.

    例如,假设某个应用程序要为客户执行准实时的建议选择,且要求往返时间小于 100 毫秒。For example, consider an application that performs near real-time recommendation selections for customers, with a round-trip time requirement of less than 100 milliseconds. 与必须从远程存储中提取所需数据的标准实现模型相比,Service Fabric 服务的延迟和性能特征向用户提供一种响应体验。The latency and performance characteristics of Service Fabric services provide a responsive experience to the user, compared with the standard implementation model of having to fetch the necessary data from remote storage. 系统的响应能力更强,因为建议选择计算与数据和规则共置。The system is more responsive because the computation of recommendation selection is colocated with the data and rules.

    已构建计算服务的客户包括 Solidsoft ReplyInfosupportCustomers who have built computation services include Solidsoft Reply and Infosupport.

  • 高度可用的服务:Service Fabric 通过创建多个辅助服务副本提供快速的故障转移。Highly available services: Service Fabric provides fast failover by creating multiple secondary service replicas. 节点、进程或单独的服务因硬件或其他故障而不可用时,其中一个辅助副本会提升为主副本,将对服务的损失降到最低。If a node, process, or individual service goes down due to hardware or other failure, one of the secondary replicas is promoted to a primary replica with minimal loss of service.

  • 可缩放的服务:可对单独的服务进行分区,以允许在群集范围内扩大状态。Scalable services: Individual services can be partitioned, allowing for state to be scaled out across the cluster. 此外,还可动态创建和删除各项服务。Individual services can also be created and removed on the fly. 可将少量节点上的少量实例中的服务横向扩展为许多节点上的数千个实例,以后可根据需要再次缩减。You can scale out services from a few instances on a few nodes to thousands of instances on many nodes, and then scale them in again as needed. 可以使用 Service Fabric 生成这些服务并管理其整个生命周期。You can use Service Fabric to build these services and manage their complete life cycles.

应用程序设计案例研究Application design case studies

客户案例Azure 中的微服务站点上发布了介绍如何使用 Service Fabric 设计应用程序的案例研究。Case studies that show how Service Fabric is used to design applications are published on the Customer stories and Microservices in Azure sites.

设计由无状态和有状态微服务组成的应用程序Designing applications composed of stateless and stateful microservices

构建使用 Azure 云服务辅助角色的应用程序是无状态服务的一个示例。Building applications with Azure Cloud Services worker roles is an example of a stateless service. 相之之下,除请求及其响应以外,有状态微服务还维护其权威状态。In contrast, stateful microservices maintain their authoritative state beyond the request and its response. 此功能在复制支持下提供交易保证的简单 API,从而提供状态的高可用性和一致性。This functionality provides high availability and consistency of the state through simple APIs that provide transactional guarantees backed by replication.

Service Fabric 中的有状态服务可让所有类型的应用程序(而不仅仅是数据库和其他数据存储)实现高可用性。Stateful services in Service Fabric bring high availability to all types of applications, not just databases and other data stores. 这是顺其自然的进步。This is a natural progression. 针对高可用性,应用程序已从使用单纯的关系数据库发展到 NoSQL 数据库的境界。Applications have already moved from using purely relational databases for high availability to NoSQL databases. 现在,应用程序可在自身内部管理其“热”状态和数据,以便进一步提高性能,而无需损失可靠性、一致性或可用性。Now the applications themselves can have their "hot" state and data managed within them for additional performance gains without sacrificing reliability, consistency, or availability.

构建包含微服务的应用程序时,通常有一个无状态 Web 应用(例如 ASP.NET 和 Node.js)组合调用应用于无状态和有状态业务中间层服务。When you're building applications that consist of microservices, you typically have a combination of stateless web apps (like ASP.NET and Node.js) calling onto stateless and stateful business middle-tier services. 这些应用和服务全部通过 Service Fabric 部署命令部署到同一个 Service Fabric 群集。The apps and services are all deployed in the same Service Fabric cluster through the Service Fabric deployment commands. 在规模、可靠性和资源使用方面,其中的每个服务都是独立的。Each of these services is independent with regard to scale, reliability, and resource usage. 这种独立性大大提高了开发和生命周期管理的敏捷性与灵活性。This independence improves agility and flexibility in development and life-cycle management.

有状态微服务将简化应用程序设计,因为它们不再需要传统上需要用来处理纯无状态应用程序的可用性和延迟需求的附加队列和缓存。Stateful microservices simplify application designs because they remove the need for the additional queues and caches that have traditionally been required to address the availability and latency requirements of purely stateless applications. 由于有状态服务具有高度可用和低延迟的特点,要在应用程序中管理的详细信息更少。Because stateful services have high availability and low latency, there are fewer details to manage in your application.

下图演示了设计有状态应用程序与无状态应用程序之间的差异。The following diagrams illustrate the differences between designing an application that's stateless and one that's stateful. 通过利用 Reliable ServicesReliable Actors 编程模型,有状态服务降低了应用程序的复杂性,同时实现了高吞吐量和低延迟。By taking advantage of the Reliable Services and Reliable Actors programming models, stateful services reduce application complexity while achieving high throughput and low latency.

下面是使用无状态服务的示例应用程序:使用无状态服务的应用程序Here's an example application that uses stateless services: Application that uses stateless services

下面是使用有状态服务的示例应用程序:使用无状态服务的应用程序Here's an example application that uses stateful services: Application that uses stateless services

后续步骤Next steps