Go to file
guqing eb969122ff
perf: add caching for extension getter to enhance performance (#7102)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
为扩展获取增加缓存以提高网站整体性能

在此之前,每个请求都要经过很多过滤器,而一些过滤器会获取扩展因此导致频繁查询扩展和扩展点定义拖慢了速度

**测试情况**

初始化一个全新环境,安装并启用以下插件和主题
- 已激活主题: [Earth 1.11.0](https://github.com/halo-dev/theme-earth)
- 已启动插件:
  - [SEO 工具集 1.0.1](https://github.com/f2ccloud/plugin-seo-tools)
  - [OAuth2 认证 1.5.0](https://github.com/halo-sigs/plugin-oauth2)
  - [Trailing Slash 1.0.0](https://github.com/halo-sigs/plugin-trailing-slash)
  - [评论组件 2.5.1](https://github.com/halo-dev/plugin-comment-widget)
  - [KaTeX 2.1.0](https://github.com/halo-sigs/plugin-katex)
  - [应用市场 1.9.0](https://www.halo.run/store/apps/app-VYJbF)

通过 Apache Benchmark (ab) 进行 1w 次请求并发 100 个,测试访问首页,得到以下测试结果:

核心指标对比

|指标|改进前|改进后|提升情况|
|---|---|---|---|
|**总耗时 (Time taken)**|27.030 秒|25.718 秒|减少约 **4.9%**|
|**每秒请求数 (RPS)**|369.96 req/sec|388.83 req/sec|提升约 **5.1%**|
|**单请求平均耗时**|270.298 ms|257.181 ms|减少约 **4.9%**|
|**传输速率 (Transfer Rate)**|6346.44 KB/s|6670.12 KB/s|提升约 **5.1%**|

综合分析
- 性能提升主要体现在:请求处理时间(Processing)、等待时间(Waiting)以及每秒请求数(RPS)均有 约5% 左右的提升。
- 传输效率更高:通过更快的处理时间,传输速率提高了 5.1%。
- 长尾请求优化显著:最大响应时间减少了约 14.9%,意味着极端情况下的性能更优。

#### Does this PR introduce a user-facing change?

```release-note
为扩展获取增加缓存使网站整体性能提升 5% 以上
```
2024-12-04 02:41:09 +00:00
.devcontainer Add devcontainer support (#6252) 2024-07-10 10:21:25 +00:00
.github Use task list for issue and pr checks (#7011) 2024-11-08 05:53:21 +00:00
api Upgrade to SpringDoc 2.7.0 (#7072) 2024-11-25 10:45:05 +08:00
api-docs/openapi/v3_0 Upgrade to SpringDoc 2.7.0 (#7072) 2024-11-25 10:45:05 +08:00
application perf: add caching for extension getter to enhance performance (#7102) 2024-12-04 02:41:09 +00:00
buildSrc Support publishing to maven central repository (#3767) 2023-04-18 14:28:23 +08:00
config/checkstyle chore: add checkstyle rule (#2091) 2022-05-17 06:46:11 +00:00
docs Add before and after security web filters (#6297) 2024-07-09 14:05:24 +00:00
e2e Refine setup page 2024-10-09 12:20:54 +08:00
gradle/wrapper Upgrade to Gradle 8.11 (#7062) 2024-11-22 04:16:12 +00:00
hack chore: add cherry_pick_pull.sh for cherry-picking pull request (#1554) 2021-12-03 10:21:24 +08:00
platform Upgrade to PF4J 3.13.0 (#7099) 2024-12-02 07:42:59 +00:00
ui chore: add packageManager for corepack (#7081) 2024-11-26 03:58:28 +00:00
.dockerignore chore: rename console to ui in some files (#5347) 2024-02-07 14:40:08 +00:00
.editorconfig Support backup and restore (#4206) 2023-07-24 08:26:16 +00:00
.gitignore test: add e2e test cases of user, role, and plugin (#4920) 2023-11-28 21:52:44 +08:00
.gitpod.yml test: add e2e test cases of user, role, and plugin (#4920) 2023-11-28 21:52:44 +08:00
CODE_OF_CONDUCT.md docs: add CODE_OF_CONDUCT.md (#2150) 2022-06-12 08:10:12 +00:00
CONTRIBUTING.md docs: update the branch name from `master` to `main` in contribution.md (#5359) 2024-02-17 08:00:15 +00:00
Dockerfile chore: specify expose port in dockerfile (#5820) 2024-04-29 10:37:26 +00:00
LICENSE Create LICENSE 2018-03-21 21:39:46 +08:00
OWNERS chore: add LIlGG as a approver (#6795) 2024-10-08 18:25:22 +08:00
README.md docs: Update README.md (#7010) 2024-11-08 07:21:21 +00:00
SECURITY.md Mark the security policy for version 1.x as unsupported (#5450) 2024-03-06 06:06:07 +00:00
build.gradle Upgrade to Spring Boot 3.4.0 (#7060) 2024-11-22 03:12:11 +00:00
gradle.properties Upgrade to SpringDoc 2.7.0 (#7072) 2024-11-25 10:45:05 +08:00
gradlew Upgrade to Gradle 8.11 (#7062) 2024-11-22 04:16:12 +00:00
gradlew.bat Upgrade to Gradle 8.11 (#7062) 2024-11-22 04:16:12 +00:00
settings.gradle Add build script for ui project 2024-02-03 22:51:50 +08:00

README.md

Halo logo

Halo [ˈheɪloʊ],强大易用的开源建站工具。

GitHub release Docker pulls GitHub last commit GitHub Workflow Status Codecov percentage Halo - Powerful and easy-to-use Open-Source website building tool | Product Hunt
官网 文档 社区 Gitee Telegram 频道

Watch the video


快速开始

如果你的设备有 Docker 环境,可以使用以下命令快速启动一个 Halo 的体验环境:

docker run -d --name halo -p 8090:8090 -v ~/.halo2:/root/.halo2 halohub/halo:2.20

或者点击下方按钮使用 Gitpod 启动一个体验环境:

Open in Gitpod

以上仅作为体验使用,详细部署文档请查阅:https://docs.halo.run/getting-started/install/docker-compose

在线体验

专业版

相比于社区版Halo 专业版为用户提供了大量增强功能及技术支持服务增强功能包括短信验证码注册登录、全站私有化、LDAP 登录、三方账号登录及自定义 LOGO 等。 点击查看专业版详细介绍

生态

可访问 官方应用市场awesome-halo 仓库 查看适用于 Halo 2.x 的主题和插件。

许可证

license

Halo 使用 GPL-v3.0 协议开源,请遵守开源协议。

赞助

如果 Halo 对你有帮助,欢迎赞助我们,感谢以下赞助者对 Halo 项目的支持:

sponsors

贡献

参考 CONTRIBUTING

状态

Repobeats analytics