Medium的微服务架构

In the monolithic storage model, the recommendation service has direct access to the same persistent storage that the monolithic app does. This is a bad idea because:

在“单体”存储模型中,推荐服务可以直接访问与单体应用相同的持久性存储。这是一个坏主意,因为:

  • Caching can be tricky. If the recommendation service shares the same cache as the monolithic app, we will have to duplicate the cache implementation details in the recommendation service as well; if the recommendation service uses its own cache, we won’t know when to invalidate its cache when the monolithic app updates the post data.
  • 缓存可能很棘手。如果推荐服务与单体应用程序共享同一个缓存,我们将不得不在推荐服务中复制缓存实现的细节;如果推荐服务使用自己的缓存,我们将不知道何时在单体应用程序更新帖子数据时使其缓存失效。
  • If the monolithic app decides to change to use RDS instead of DynamoDB to store post data, we will have to reimplement the logic in the recommendation service and all other services that access the post data as well.
  • 如果单体应用决定改用RDS而不是DynamoDB来存储帖子数据,我们将不得不在推荐服务和所有其他访问帖子数据的服务中重新实现逻辑。
  • The monolithic app has complex logic to interpret the post data, e.g., how to decide if a post should not be viewable to a given user. We have to reimplement those logics in the recommendation service. Once the monolithic app changes or adds new logics, we need to make the same changes everywhere as well.
  • 单体应用有复杂的逻辑来解释帖子数据,例如,如何决定某个用户是否可以查看帖子。我们必须在推荐服务中重新实现这些逻辑。一旦单体应用更改或添加新的逻辑,我们也需要在其他地方进行相同的更改。
  • The recommendation service is stuck with DynamoDB even if it is the wrong option for its own data access pattern.
  • 即使对于自身的数据访问模式来说,推荐服务也被困在DynamoDB中,即使这是错误的选择。

In the decoupled storage model, the recommendation service does not have direct access to the post data, neither do any other new services. The implementation details of post data are retained in only one service. There are different ways of achieving this.

在解耦的存储模型中,推荐服务没有直接访问发布数据的权限,其他新服务也是如此。发布数据的实现细节仅保留在一个服务中。有多种实现这一点的方法。

Ideally, there should be a Post Service that owns the post data and other services can only access post data through the Post Service’s APIs. However, it could be an expensive upfront investment to build new services for all core data ...

开通本站会员,查看完整译文。

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.131.0. UTC+08:00, 2024-09-06 21:01
浙ICP备14020137号-1 $bản đồ khách truy cập$