# cache_test **Repository Path**: RemoteControl/cache_test ## Basic Information - **Project Name**: cache_test - **Description**: 测试spring-data-redis 缓存场景的(有更新需求的数据的缓存,确保高性能) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 3 - **Created**: 2019-11-18 - **Last Updated**: 2024-03-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cache_test #### 介绍 测试spring-data-redis_plus 缓存场景的(有更新需求的数据的缓存) 需要以下环境 1. mysql5.7+ 导入 1、创建数据库 cache_test 2、 doc中sql脚本导入 2. redis+redisearch 3. jdk1.8+maven3.5 4. cn.bblocks.cacheTest.CacheTestApplication 5. 接口地址:http://localhost:8089/cache-test/doc.html 6. 使用jmeter进行压力测试:doc/jmeter进行压测 “HTTP Request.jmx” spring-data-redis_plus [传送门](https://gitee.com/RemoteControl/spring-data-redis) #### 软件架构 springboot 2.2.2 + spring-data-redis-plus(2.2.0)+mysql5.7+redis4.0+redisearch+jpa ###本地测试结果 1. 场景182522用户 ,11211529用户银行卡 2. 模拟100个用户,执行10000次查询,在查询到记录后,1/300机会修改,1/300之机会添加,1/300机会删除卡 3. 测试环境AMD R5 3600 16G,win10旗舰版 4. 安装软件:mysql,win10子系统ubuntu,redis4.0+redisearch(ubuntu上),eclipse 运行项目 5. 测试截图:![测试截图](http://res.bblocks.cn/ceshi.png) 作为对比一下2图为标准cache方案的 和 不用cache方案的: + 标准缓存方案(查询缓存,使用“standard_springcache”分支主要修改为一单涉及到修改则执行@CacheEvict(allEntries=true)): ![标准缓存方案](http://res.bblocks.cn/cache_test/standard_cache.png "标准缓存方案") + 无缓存方案(RedisConfiguration 屏蔽掉 @EnableCaching,走纯db方案): ![无缓存方案](http://res.bblocks.cn/cache_test/no_redis.png "无缓存方案") 7. 另一组对比:纯查询方案 + spring-data-redis_plus 纯查询缓存方案: ![plus纯查询缓存方案](http://res.bblocks.cn/cache_test/plus_onlyquery.png "纯查询缓存方案") + 标准缓存纯查询方案: ![标准缓存纯查询方案](http://res.bblocks.cn/cache_test/standard_cache_onlyquery.png "标准缓存纯查询方案") + 无缓存纯查询方案: ![无缓存纯查询方案](http://res.bblocks.cn/cache_test/no_redis_onlyquery.png "无缓存纯查询方案") 8. **数据对比** |场景|QPS|应用cpu占比(%)|jmeter占比(%)|redis(%)|mysql(%)| | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | |plus_cache方案综合|14814|51|32.3|5.6|3.3| |cache方案综合|5573|-|12.6|1.3|50.8| |no_cache方案综合|5884|30.6|12.3|-|54.4| |plus_cache方案纯查询|17114|62.4|21.9|5.4|0| |cache方案纯查询|21410|63.4|26|2.3|0| |no_cache方案纯查询|6422|29.2|7.4|0|60.5| ## 结论: ## 1、在综合情况下(查询、各种修改存在)不占用mysql的性能的情况显著提高性能,在服务器足够的情况单例mysql 和 redis支撑15W的qps应该没问题 ## 2、在纯查询的情况(认为数据基本不变动)本方案性能比标准cache方案略低,在缓存足够的情况下15W QPS也应该可以都支持 ## 3、纯db方案 基本上1W的qps已经达到上限(单例MYSQL 未足够优化) #### 安装教程 1. xxxx 2. xxxx 3. xxxx #### 使用说明 1. xxxx 2. xxxx 3. xxxx #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 码云特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)