Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Spring Boot + Zuul Finchley Notes

Preface

Listen, if you want to use Zuul, the easiest path is just use the Spring Boot version. I'm not exactly a fan of Spring in general, but this is the only solution available that's the least painful. Recent release of Spring Cloud Gateway looks promising but I'm satisfied so far with Spring Boot + Zuul that I'm not that interested in evaluating Spring Cloud Gateway,

We are also talking about Zuul 1.x here. Zuul 2.x is a whole can of worms I'd rather not rant about here.

This applies to Finchley (2.x) from SR1 release (may apply to other releases but not guaranteed)

  • Re: using logback. The documentation says it's recommended to use logback-spring.xml in your classpath, but it doesn't work. You should actually use logback.xml or your logging configuration is not recognized at all. While at the subject, it is recommended not to use asynchronous logging at all. Using async logging reduces the throughput by a significant margin.
  • Using OkHttp with Zuul. It's not enough to set ribbon.okhttp.enabled to true. I know this is not enough because when i set breakpoints in the OkHttp factory classes, they never get hit. So after scouring the intarwebs and found this (i don't even read Chinese), you need to set ribbon.httpclient.enabled (the default http client) to false. you know that it's going to try to load Ok http client because if you don't add the Okhttp dependencies in your classpath/pom.xml, you get class not found runtime errors related. specifically, this error message:
***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of method ribbonRoutingFilter in org.springframework.cloud.netflix.zuul.ZuulProxyAutoConfiguration required a bean of type 'org.springframework.cloud.netflix.zuul.filters.route.RibbonCommandFactory' that could not be found.
	- Bean method 'ribbonCommandFactory' not loaded because AnyNestedCondition 0 matched 1 did not; NestedCondition on RibbonCommandFactoryConfiguration.OnRibbonHttpClientCondition.RibbonProperty @ConditionalOnProperty (ribbon.httpclient.enabled) found different value in property 'ribbon.httpclient.enabled'
	- Bean method 'ribbonCommandFactory' not loaded because @ConditionalOnClass did not find required class 'okhttp3.OkHttpClient'
	- Bean method 'ribbonCommandFactory' not loaded because AnyNestedCondition 0 matched 1 did not; NestedCondition on RibbonCommandFactoryConfiguration.OnRibbonRestClientCondition.RibbonProperty @ConditionalOnProperty (ribbon.restclient.enabled) did not find property 'ribbon.restclient.enabled'


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.cloud.netflix.zuul.filters.route.RibbonCommandFactory' in your configuration.

so obviously you add com.squareup.okhttp3#okhttp to your list of dependencies:

<dependency>
  <groupId>com.squareup.okhttp3</groupId>
  <artifactId>okhttp</artifactId>
</dependency>
  • Undertow (with ok http) is better than the (default) Tomcat (with ok http) container in my limited experience so far. don't even bother with the default (apache) http client.
  • To further modify the throughput behavir of zuul, you can change the following application settings: zuul.host.max-per-route-connection, zuul.host.max-total-connections, zuul.host.socket-timeout-millis, zuul.host.connect-timeout-millis. The default settings for these settings are fairly conservative so you may want to adjust it depending on your througput requirements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.