微服务版本控制 [英] Microservice Versioning

查看:107
本文介绍了微服务版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就支持基于微服务的体系结构中的版本控制而言,最佳的实践是什么,就在运行时支持同一服务的多个版本部署,以及消费者如何使用不同的版本?1)如果我们将基于路由的版本控制用作提及的方法之一,请此处那么我想我们会有以下缺点

What is the best practice to adapt for versioning in a Microservice Based Architecture, in terms of supporting multiple versioned deployment of the same service during runtime and how the consumers would be able to use different versions? 1) If we use Routing based Versioning as one of the approaches mentioned here then I guess we would have the following drawbacks

  1. 内部服务必须通过反向代理进行消费.
  2. 消费者始终必须了解所需的版本控制.

将版本信息公开给消费者是最佳实践吗?

Is it a best practice to expose the version information to consumers?

在我看来,在任何情况下,以下条件始终适用:

In any case, as I feel, the following always applies:

  1. 要更改主要版本,必须更改使用者.
  2. 对于MINOR版本更改(向后兼容),只有需要添加功能的使用者才需要更改.
  3. 对于PATCH版本更改,它是可选的,对于任何消费者来说都可以无缝使用.

哪种微服务版本控制策略可以帮助我们实现上述目标?

What kind of Microservice versioning strategy can help us in enabling the above?

注意-如果需要将其分为多个问题,请随时告诉我.

NOTE - Please feel free to let me know if this needs to be split in multiple questions.

推荐答案

我认为可以肯定地说,到目前为止,这尚未解决.在微服务架构中,每个服务应松散耦合.如果在更换生产者时也必须寻找消费者以对其进行更改,则表明您存在设计缺陷.链接中显示的基于路由的版本控制似乎不仅仅具有一些缺点".

I think it is safe to say that as of now it is not a solved problem. In a Microservice Architecture, each service should be loosely coupled. If when you change a producer, you have to hunt down consumers to change them too, then it indicates that you have a design flaw. The routing based versioning presented in the link seems to have much more than a "few drawbacks".

是要对整个服务还是仅对API进行版本控制?

如果对整个服务进行版本控制,您将始终打开相当数量的蠕虫.假设您实现了服务A的第一个版本(v1).现在想象一下,一段时间后,由于业务原因,必须实施一个新版本(v2).如果在此服务的v2上发现错误,该怎么办?小组应检查v1上是否也没有相同的错误.如果是这样,则也应更正并重新部署v1.即使只是复制和粘贴,也需要重新测试和重新部署两个版本.如果版本之间的重构与修复v1的方式与修复v​​2的方式不同怎么办?如果不是5个或10个版本,而不是2个版本,该怎么办?比我更有趣的人应该为此设置一个迅速缩放"的模因.

If you version the entire service, you will invariably open quite a can of worms. Imagine that you implemented the first version (v1) of a service A. Imagine now that after a while, a new version (v2) had to be implemented because of the business. What happens if a bug is discovered on the v2 of this service? The team should check that the same bug doesnt exist on v1 too. If it does, v1 should be corrected and redeployed too. Even if it is just copy and paste, both versions need to be retested and redeployed. And what if there was refactoring between versions and the way to fix v1 is diferent from the way to fix v2? And what if instead of 2 versions, there are 5 or 10? Someone funnier than me should make a "That scalated quickly" meme for this.

仅通过刮擦此选项可能给您带来多少麻烦,我们就基本上可以通过仅对API进行版本控制来决定了.但基本上,如果您在代码级别上对服务进行版本控制:

Just by scratching the surface of how much headache this option could give, we basically can already decide by versioning just the api. But basically if you version your service on the code level:

  1. 团队只需支持该服务的一个版本(错误只需更正一次)
  2. 由于不必了解大量不同且可能非常不同的服务版本,因此减少了团队的认知消耗
  3. 较少的资源消耗
  4. 保证版本之间的所有内容都是一致的(如果不是保证金,至少更有可能)

客户端如何传达他们将使用哪个版本的api?

对于此答案,我将仅提及REST api,因为我所知道的足够多.基本上有4种API版本(我可以想到):

For this answer, I will refer only to REST apis because its what i know enough to talk about. There are basically 4 ways of versioning the api (that i can think of):

  1. 版本化URI:" http://host/serviceA/v3/任何"
  2. 接受标题中的版本
  3. 自定义标题中的版本
  4. 版本作为参数

教程将分别对其进行解释.缺点比我更好,但基本上这些缺点中的任何一个都应该做得很好=)

This tutorial will explain each one of these with their drawbacks better than me, but basically anyone of these should do just fine =)

如何(在f ***** g地狱)以相同的代码维护众多的服务版本?(你疯了吗?)

您的服务本身就是其中之一.您应该做的是应用适配器设计模式,以便与服务的业务层进行交互的ins和outs存在不同的版本.这样,您就可以拥有某些对象的某些版本,并且对服务的核心是透明的.这与问题中提到的文章的结论相同,甚至有一个很好的例子来展示它.

Your service per se is just one. What you should do is apply Adapter Design pattern, so as to exist different versions of ins and outs interacting with the business layer of your service. This way you just have some versions of some objects, with it being transparent to the core of the service. It is the same conclusion of the article mentioned in the question, and it even has a neat example to showcase it.

这篇关于微服务版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆