简体   繁体   English

服务结构有状态服务-扩展而不分区?

[英]Service fabric Stateful service - Scaling without partitioning?

I am planning to migrate my existing cloud monolithic Restful Web API service to Service fabric in three steps. 我计划通过三个步骤将现有的云整体式Restful Web API服务迁移到Service Fabric。 The Memory cache (in process) has been heavily used in my cloud service. 内存缓存(正在处理)已在我的云服务中大量使用。

Step 1) Migrate cloud service to SF stateful service with 1 replica and single partition. 步骤1)将云服务迁移到具有1个副本和单个分区的SF状态服务。 The cache code is as it is. 缓存代码保持原样。 No use of Reliable collection. 不使用可靠收集。

Step 2) Horizontal scaling of SF Monolithic stateful service to 5 replica and single partition. 步骤2) SF整体状态服务的水平扩展到5个副本和单个分区。 Cache code is modified to use Reliable collection. 缓存代码已修改为使用可靠收集。

Step 3) Break down the SF monolithic service to micro services (stateless / stateful) 步骤3)将SF整体服务分解为微服务(无状态/有状态)

Is the above approach cleaner? 以上方法更清洁吗? Any recommendation.? 有什么建议吗? Any drawback? 有什么缺点吗?

More on Step 2) Horizontal scaling of SF stateful service 有关步骤2)SF状态服务的水平扩展的更多信息

  • I am not planning to use SF partitioning strategy as I could not think of uniform data distribuition in my applictaion. 我不打算使用SF分区策略,因为我无法想到应用程序中的统一数据分布。
  • By adding more replica and no partitioning with SF stateful service , I am just making my service more reliable (Availability) . 通过添加更多副本并且不使用SF状态服务进行分区,我只是使我的服务更加可靠(可用性)。 Is my understanding correct? 我的理解正确吗?
  • I will modify the cache code to use Reliable collection - Dictionary. 我将修改缓存代码以使用“可靠集合-字典”。 The same state data will be available in all replicas. 相同状态数据将在所有副本中可用。
  • I understand that the GET can be executed on any replica , but update / write need to be executed on primary replica? 我了解GET可以在任何副本上执行,但是需要在主副本上执行更新/写入吗?
  • How can i scale my SF stateful service without partitioning ? 如何在不分区的情况下扩展SF状态服务?
  • Can all of the replica including secondory listen to my client request and respond the same? 包括secondory在内的所有副本都可以侦听我的客户请求并响应吗? GET shall be able to execute , How PUT & POST call works? GET将能够执行,PUT&POST调用如何工作?

  • Should i prefer using external cache store (Redis) over Reliable collection at this step? 我是否应该在此步骤中使用外部缓存存储(Redis)而不是可靠的收集? Use Stateless service? 使用无状态服务?

This document has a good overview of options for scaling a particular workload in Service Fabric and some examples of when you'd want to use each. 本文档很好地概述了用于扩展Service Fabric中特定工作负载的选项,以及一些有关何时使用它们的示例。

Option 2 (creating more service instances, dynamically or upfront) sounds like it would map to your workload pretty well. 选项2(动态或预先创建更多服务实例)听起来像可以很好地映射到您的工作负载。 Whether you decide to use a custom stateful service as your cache or use an external store depends on a few things: 您决定使用自定义状态服务作为缓存还是使用外部存储取决于以下几件事:

  • Whether you have the space in your main compute machines to store the cached data 主计算机中是否有足够的空间来存储缓存的数据
  • Whether your service can get away with a simple cache or whether it needs more advanced features provided by other caching services 您的服务是否可以通过简单的缓存摆脱困境,还是需要其他缓存服务提供的更高级功能?
  • Whether your service needs the performance improvement of a cache in the same set of nodes as the web tier or whether it can afford to call out to a remote service in terms of latency 您的服务是否需要提高与Web层相同的一组节点中的缓存的性能,或者是否可以承受延迟方面的对远程服务的调用
  • whether you can afford to pay for a caching service, or whether you want to make due with using the memory, compute, and local storage you're already paying for with the VMs. 您是否可以负担得起缓存服务的费用,或者是否要使用已经通过虚拟机付费的内存,计算和本地存储来赚钱。
  • whether you really want to take on building and running your own cache 是否真的要构建并运行自己的缓存

To answer some of your other questions: 要回答您的其他一些问题:

  • Yes, adding more replicas increases availability/reliability, not scale. 是的,添加更多副本将增加可用性/可靠性,而不是规模。 In fact it can have a negative impact on performance (for writes) since changes have to be written to more replicas. 实际上,这可能会对性能(写入)产生负面影响,因为必须将更改写入更多副本。
  • The state data isn't guaranteed to be the same in all replicas, just a majority of them. 不能保证所有副本中的状态数据都是相同的,只是其中大部分是相同的。 Some secondaries can even be ahead, which is why reading from secondaries is discouraged. 某些中学甚至可以领先,这就是为什么不鼓励从中学读书的原因。
  • So to your next question, the recommendation is for all reads and writes to always be performed against the primary so that you're seeing consistent quorum committed data. 因此,对于您的下一个问题,建议始终对主数据库执行所有读写操作,以便您看到一致的仲裁提交数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM