Slow scanning time on SpringMVC application
See original GitHub issueHey guys!
I’m currently using the 2.9.2 version on Springfox and I’m facing long wait times deploying my application, just when springfox starts to scan for api listing references and generating unique operations. If I add “nickname” on @ApiOperation to avoid the unique operation generation, the slow time stays the same.
This is my SwaggerConfiguration.java:
@Configuration
@EnableSwagger2
public class SwaggerConfiguration extends WebMvcConfigurerAdapter {
private static final String RESOURCE_PACKAGE = "br.com.finchsolucoes.xgracco.application.api.resource";
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Bean
private Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.useDefaultResponseMessages(false)
.groupName("Api")
.select()
.apis(RequestHandlerSelectors.basePackage(RESOURCE_PACKAGE))
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(regex( "/api.*"))
.build()
.ignoredParameterTypes(AuthenticationPrincipal.class)
.globalOperationParameters(
Collections.singletonList(
new ParameterBuilder()
.name("Authorization")
.description("Bearer token")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(true)
.build()));
.apiInfo(metaDados());
}
private ApiInfo metaDados() {
return new ApiInfoBuilder()
.title("X-Gracco API")
.description("Módulo Gestão Processos.")
.version("5.4.0")
.contact(new Contact("Finch Soluções", "http://www.finchsolucoes.com.br", "comercial@finchsolucoes.com.br"))
.build();
}
}
I was using the 2.4.0 version before, it deploys really fast, but it is very slow to fetch de JSON data from /v2/api-docs to swagger-ui.html. On the other side, the swagger-ui.html works like a charm on 2.9.2, but the deploy doesn’t.
Any help is appreciated.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:33 (12 by maintainers)
Top Results From Across the Web
Spring startup performance issues - java - Stack Overflow
A easy way to generate the Spring XML is to write a simple spring application that uses the class path scanning like your...
Read more >Performance - Spring Boot - Server Response Time-Spring MVC
based on your data my best guess is that the first two steps are slow and untile the DB pool is warmed up...
Read more >Spring MVC + GAE = slow startup - Google Groups
After deploy, the app takes 50+ seconds to start (sometime the first request get killed after 60 seconds and another app is started)...
Read more >Speed up Spring Boot Startup Time - Baeldung
However, lazy initialization has a few drawbacks. The most significant disadvantage is that the application will serve the first request slower.
Read more >SpringFu Solves Slow Spring Startup - Alibaba Cloud
According to unofficial experimental data, transforming the SpringMVC application into the SpringFu structure can shorten the startup time ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
While my pull request fixed issue with 2.9.2, it is required, but not sufficient for 3.0.0 because version 3.0.0-SNAPSHOT has introduced another bottleneck in springfox.documentation.spring.web.scanners.ApiModelReader#mergeModelBranch which has been re-written since 2.9.2 was released. ApiModelReader#mergeModelBranch in version 3.0.0 has @SuppressWarnings({“CyclomaticComplexity”, “NPathComplexity”}) annotation which indicates that some code inspection tool detected that code is potentially very slow, and that warning should not have been ignored.
I could not fix it in version 3.0.0, merging algorithm is fairly complicated. Version 3.0.0-SNAPSHOT is significantly slower than 2.9.2 because it has two bottlenecks, and Springfox initialization takes 5 minutes compared to 40 seconds with version 2.9.2 for 158 REST functions. That makes version 3.0.0-SNAPSHOT completely unusable in large projects with more than 150 REST functions.
So the only option to get it fixed is to make a hotfix release 2.9.3 based on 2.9.2.
I also have this issue with 2.10.5 that
/v2/api-docs
is very slow. Is this issue fixed with 2.10.5 version ?