java - 在 k8s 中使用 spring 缓慢的初始 http 请求
问题描述
我有一个简单的 java 应用程序,它带有一个简单地返回一个 hello world jsp 的控制器。它在非 k8s 环境中按预期工作,但是在 k8s 上部署时,第一次请求页面时响应大约需要 15 秒。在第一次请求之后,性能会在瞬间恢复正常响应。我已经为 spring 启用了调试日志,但那里没有什么用处,只有 15 秒没有日志:
2021-08-04 16:38:16,856 DEBUG org.springframework.web.servlet.view.InternalResourceView: Forwarding to [/WEB-INF/jsp/test.jsp]
...
2021-08-04 16:38:31,452 DEBUG org.springframework.security.web.header.writers.HstsHeaderWriter: Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@5073a20b
2021-08-04 16:38:31,453 DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository$SaveToSessionResponseWrapper: SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2021-08-04 16:38:31,455 DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor: Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
2021-08-04 16:38:31,459 DEBUG org.springframework.web.servlet.FrameworkServlet: Completed 200 OK
2021-08-04 16:38:31,459 DEBUG org.springframework.security.web.access.ExceptionTranslationFilter: Chain processed normally
2021-08-04 16:38:31,460 DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter: SecurityContextHolder now cleared, as request processing completed
我想知道是否有人对可能发生的事情有任何建议,或者我该如何进一步调查?
解决方案
推荐阅读
- c++ - 使用模板参数定义 Hana 结构
- r - 按列表中传递的条件过滤 data.table
- java - 如何修复 Spring Boot 中不支持的请求方法“POST”?
- python - Python数值类型的范围
- wpf - 依赖属性设计数据
- javascript - 在将表单提交到数据库之前,我的代码没有执行我的 JS 函数
- javascript - 用于验证正确模式的 JavaScript 正则表达式
- oauth-2.0 - 无法将 Azure AD 身份验证添加到现有应用
- azure-cosmosdb - gremlin 硬币过滤器的 Cosmosdb 错误。有替代方案吗?
- java - JavaFX Tableview 按自定义规则排序,然后按列选择