在我们使用Spring Cloud开发微服务的过程中,我们开始使用Zuul作为从外部到微服务的任何连接的代理,以及任何需要联系其他微服务的微服务.
一段时间后,我们得出结论,Zuul被设计为边缘服务(仅从外部到微服务的代理流量),不应该用于跨微服务通信.特别是Spring Cloud建议使用eureka与另一个服务建立直接(可能是负载平衡)连接的方式使我们反对在所有事件之间使用Zuul.
当然,一切都按预期工作得很好(就像Spring云一样),但我们对如何使用此设置执行某个用例毫无头绪.
在部署新版本的微服务时,我们希望对旧版本和新版本进行蓝/绿部署.但是,在微服务之间没有Zuul,两个单独服务之间的通信将继续使用旧版本,直到从eureka中删除.
我们正在考虑如何实现这一目标.在下面的图片中,我画了我认为可能是一个选项.
在图片的第一部分,Zuul打电话给eureka来获取注册表来创建路线.服务1还调用eureka以使注册表路由到服务2.由于服务2在eureka注册表中,因此路由成功完成.
在图的第二部分中,部署了服务2(服务2.1)的更新.它也注册了eureka,这使得服务1现在可以路由到服务2和服务2.1.蓝/绿部署不需要这样做.
在第三部分中,展示了针对此问题的另一个eureka实例的潜在解决方案.此实例不支持对等,不会与第一个eureka实例同步.与第一个实例相反,这个唯一的目的是促进蓝色/绿色部署.服务2.1向第二个eureka实例注册,服务1将其配置更改为从第一个尤其是第二个eureka实例获取其注册表.

我们面临的主要问题是这是否是一个可行的解决方案.具有Zuul路由的灵活性是我们在这种情况下没有的一大优点.我们应该回过头来通过Zuul路由每个服务到服务的呼叫,还是有另一个解决方案(可能是某种类型的功能区配置)更合适?或者第二个eureka实例是此类部署的最佳解决方案?
任何反馈将不胜感激.
亲切的问候,安德烈亚斯
blue-green-deployment microservices spring-cloud netflix-eureka netflix-zuul
春天的人们在发布大量优质项目方面做得很好.我们一直在使用的是Spring Cloud及其各个子项目.
一个令我困惑的方面是Spring Cloud版本名称.例如,如果您转到Spring Cloud,它会读取Camden或Angel或Brixton.然后,如果你转到特定的项目站点,例如,Spring Cloud Config它会显示像1.3.0或的版本1.2.3
关于这些的两个问题.
从命名版本(camden,brixton,angel)来看,很难看出哪个是最新版本及其序列.有没有一个记录良好的地方?
如何将命名版本与子项目编号发布相关联?
感谢您的时间.
我有一个独立的嵌入式Eureka服务器,由Spring Boot 1.2.0.RELEASE和Spring Cloud 1.0.0.RC1提供支持.我看到服务在仪表板中正确注册,这很棒.状态链接使用它们运行的框的主机名.不幸的是,我们使用的是虚拟机,他们没有在DNS中注册,这意味着链接无法解析.我开始查看代码,但无法找到强制链接使用主机的IP地址的方法.破坏仪表板并不是世界末日,但我担心一旦我们开始使用Ribbon或Feign联系服务,这些URL也将使用主机名并且无法解析.也许我真正想问的是有没有办法强制客户注册一个IP地址而不是一个主机名?任何帮助表示赞赏.
我了解可以使用用户名和密码保护Spring Cloud Config Server,该用户名和密码必须由访问客户端提供.
如何防止客户端将这些用户名和密码以明文形式存储在客户端应用程序/服务的bootstrap.yml文件中?
我有同样的问题,我试图覆盖application.yaml中的hystrix属性.当我运行应用程序并使用localhost:port/app-context/hystrix.stream检查属性时,我得到所有默认值.
这是我的application.yaml中的hystrix配置
hystrix:
command.StoreSubmission.execution.isolation.thread.timeoutInMilliseconds: 30000
command.StoreSubmission.circuitBreaker.requestVolumeThreshold: 4
command.StoreSubmission.circuitBreaker.sleepWindowInMilliseconds: 60000
command.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000
collapser.StoreSubmission.maxRequestsInBatch: 1
collapser.StoreSubmission.requestCache.enabled: FALSE
threadpool.StoreSubmission.coreSize: 30
threadpool.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000
Run Code Online (Sandbox Code Playgroud)
这是我在浏览网址时看到的 - localhost:port/app-context/hystrix.stream [这是用于hystrix仪表板的相同流网址] -
data: {"type":"HystrixCommand","name":"storeSubmission","group":"StoreSubmission","currentTime":1435941064801,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":0,"rollingCountCollapsedRequests":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackFailure":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"latencyTotal_mean":0,"latencyTotal":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1}
data: {"type":"HystrixThreadPool","name":"StoreSubmission","currentTime":1435941064801,"currentActiveCount":0,"currentCompletedTaskCount":35,"currentCorePoolSize":30,"currentLargestPoolSize":30,"currentMaximumPoolSize":30,"currentPoolSize":30,"currentQueueSize":0,"currentTaskCount":35,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":180000,"reportingHosts":1}
Run Code Online (Sandbox Code Playgroud)
问题在于hystrix命令和collapser属性,其中正确设置了线程池属性.我的@configuration类中有以下注释-
@EnableAutoConfiguration(exclude=MongoAutoConfiguration.class)
@EnableHystrix
@EnableHystrixDashboard
Run Code Online (Sandbox Code Playgroud)
有人尝试在Spring-Boot应用程序中使用application.yaml配置hystrix命令属性,可以帮忙吗?
我试图在一个简单的spring-cloud-Netflix Api网关(反向代理)中使用ZuulFilter,以便对自定义身份验证提供程序(通过Rest调用)验证请求.
过滤器应拒绝使用401的未授权请求,并且不要将这些请求进一步传递给代理服务.
这对ZuulFilter来说甚至可能吗?我没有在Zuuls api中找到文档,示例或其他内容.
有什么建议?
我正在使用Eureka和Zuul开始使用Spring Cloud,并且在构建蓝色/绿色和Canary部署方面遇到了一些问题.到目前为止,我已经完成了基础工作,并让Eureka,Zuul和配置服务器按预期工作.我想要完成的是建立一个有两个版本的服务,比如1.0和1.1.对于特定用户的子集,我想将它们路由到1.1版本,其他人都应该转到1.0版本.
Zuul过滤器API对文档有点了解,我正在努力解决一些概念,所以我想我会在这里问几个问题.我还运行了一些基本的过滤器,除了获取他们请求的主体和服务的身份之外,它不会做很多事情.我在墙上的位置是了解如何向Eureka和Zuul公开同一服务的两个不同版本.我很好奇的一些事情:
/simpleservice,我会暴露两个不同的serviceIDs(即simpleservice和simpleservice-1.1)?如果我这样做,当其中一个目标用户请求时/simpleservice,我让Zuul发送给他们/simpleservice-1.1canary-deployment microservices spring-cloud netflix-eureka netflix-zuul
有没有办法在Spring Boot应用程序中HystrixCommand使用@HystrixCommand注释时失败的原因?看起来如果您实现自己的HystrixCommand,您可以访问getFailedExecutionException但是如何在使用注释时访问它?我希望能够根据发生的异常类型在回退方法中执行不同的操作.这可能吗?
我看到一个音符有关HystrixRequestContext.initializeContext(),但HystrixRequestContext不给你访问什么,有没有使用上下文来获取访问例外不同的方式?
我已更新后端服务以使用最新的 Spring Boot 3,但是更新后,SB 应用程序由于在配置加载期间设置延迟日志的一些问题而失败。任何人都可以帮忙想想可能出了什么问题,下面是堆栈跟踪:
java.lang.IllegalArgumentException: Unable to instantiate factory class [org.springframework.cloud.config.client.ConfigServerConfigDataLocationResolver] for factory type [org.springframework.boot.context.config.ConfigDataLocationResolver]
at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$throwing$0(SpringFactoriesLoader.java:650)
at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$handleMessage$3(SpringFactoriesLoader.java:674)
at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:231)
at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:206)
at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:160)
at org.springframework.boot.context.config.ConfigDataLocationResolvers.<init>(ConfigDataLocationResolvers.java:66)
at org.springframework.boot.context.config.ConfigDataEnvironment.createConfigDataLocationResolvers(ConfigDataEnvironment.java:160)
at org.springframework.boot.context.config.ConfigDataEnvironment.<init>(ConfigDataEnvironment.java:148)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.getConfigDataEnvironment(ConfigDataEnvironmentPostProcessor.java:101)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:96)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:109)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:94)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:352)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:59)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:47)
at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1386)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:543)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137) …Run Code Online (Sandbox Code Playgroud) 简短说明: 我正在尝试使用ZuulProxy来处理实例故障转移但它抛出ZuulException:转发错误,而不是使用工作实例的结果进行响应.
详细说明: 我的设置是一个独立的Eureka服务器,一个ConfigServer,一个ZuulProxy(@EnableZuulProxy)和两个服务实例,所有这些都在Eureka注册.
一切都在运行spring-cloud-starter-parent Angel.SR3
我的服务发现:
@SpringBootApplication
@EnableEurekaServer
public class EurekaServer {
public static void main(String[] args) {
SpringApplication.run(EurekaServer.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
我的ConfigServer:
@SpringBootApplication
@EnableAutoConfiguration
@EnableConfigServer
@ComponentScan
@EnableDiscoveryClient
public class ConfigserverApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigserverApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
我的ZuulProxy:
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
@EnableDiscoveryClient
@EnableZuulProxy
public class ZuulProxy {
public static void main(String[] args) {
SpringApplication.run(ZuulProxy.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
该路由规则在zuul:
zuul.ignoredServices=*
zuul.routes.examplems=/example/**
Run Code Online (Sandbox Code Playgroud)
我的服务实例:
@SpringBootApplication
@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@ComponentScan(basePackages = …Run Code Online (Sandbox Code Playgroud) spring-cloud ×10
netflix-zuul ×3
hystrix ×2
spring ×2
spring-boot ×2
java ×1
logging ×1
netflix ×1