是否有审计 Spring Rest 应用程序的最佳实践?

Is there any best practice to make audit of Spring Rest application?

我必须提高 spring 启动应用程序的性能,这是非常经典的休息 API + 休眠 + postgres。我们有 250k 活跃用户,想提取一些请求到从平衡实例上,并可能缓存一些数据。现在我只怀疑一些请求需要缓存,但我想做一些审计和报告,一些请求被调用了很多次我们应该使用其他策略,或者“这个”sql 请求每次都被触发休息调用,所以它吃掉了很多数据库生命周期,这可以使用缓存来解决。有什么最佳实践可以制作这种 audit/analytic 吗?请求率、每个用户的请求率、每个请求的 SQL 率、每个用户每个请求的 SQL 率以及其他一些指标

Spring Boot 的 metrics should give you a good starting point. The Spring MVC metrics should allow you to identify if there are certain types of request that are taking longer than others. Depending on how you are accessing your database, there are also DataSource metrics, Hibernate metrics, and Spring Data Repository metrics(Spring Boot 2.5 中的新功能)可能会引起您的兴趣。

这些指标将针对您的整个应用程序而不是针对每个用户。拥有超过 250,000 个活跃用户,基于每个用户的标记指标几乎肯定不切实际。除非您怀疑特定用户有问题,否则我至少会从应用程序范围的指标开始,看看情况如何。