spring-cloud / spring-cloud/spring-cloud-gateway

Load Routes before Netty port bind

Open
#2,169 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

Is your feature request related to a problem? Please describe.

2021-03-04 16:10:00.678  INFO 89451 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2021-03-04 16:10:01.292  INFO 89451 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=75ee6c1a-251a-318a-b7e0-4eb8fe799bbf
2021-03-04 16:10:01.625 DEBUG 89451 --- [           main] o.s.c.gateway.config.GatewayProperties   : Routes supplied from Gateway Properties: [RouteDefinition{id='default', predicates=[PredicateDefinition{name='Host', args={_genkey_0=**}}], filters=[FilterDefinition{name='PreserveHostHeader', args={}}], uri=http://127.0.0.1:8081/, order=0, metadata={}}]
2021-03-04 16:10:01.816  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [After]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Before]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Between]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Cookie]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Header]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Host]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Method]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Path]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Query]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [ReadBody]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [RemoteAddr]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [Weight]
2021-03-04 16:10:01.817  INFO 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : Loaded RoutePredicateFactory [CloudFoundryRouteService]
2021-03-04 16:10:02.167  INFO 89451 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
2021-03-04 16:10:02.205  INFO 89451 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 16 endpoint(s) beneath base path '/actuator'
2021-03-04 16:10:02.242  INFO 89451 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 18091
2021-03-04 16:10:02.277 DEBUG 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition default applying {_genkey_0=**} to Host
2021-03-04 16:10:02.293 DEBUG 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition default applying filter {} to PreserveHostHeader
2021-03-04 16:10:02.295 DEBUG 89451 --- [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition matched: default
2021-03-04 16:10:02.304  INFO 89451 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 5.213 seconds (JVM running for 5.512)

Netty server port bind before routers load. This may stuck incoming requests when some filter need more time to load

Describe the solution you'd like
Add a configuration to enabled netty port bind after routers load. Just like bindOnInit in Tomcat configuration

Describe alternatives you've considered

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the startup sequence represented by NettyWebServer and RouteDefinitionRouteLocator in the issue logs, and compare it with the mentioned Tomcat bindOnInit configuration. Determine how route loading and Netty port binding are ordered, then verify that the requested configuration makes routes load before the server accepts requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.