关于async对webapi性能影响的疑问(asp.net core3) -- 请教大神
都说action上使用异步能提升系统的整体性能,我就做了个简单的测试。
用了一个非常简单的写数据的方法(entityframework),一种是异步模式,一种是同步模式,测试下来,同步模式稍微块一点点。
难道说,只有比较耗时的方法,才适合采用用异步模式?
或者说我这测试有什么问题?
代码1
public async Task<PostResult> EditLesson(LessonDto dto) { return await Task.Run(() => { return lessonService.EditLesson(dto, UserInfo); }); }
插入5000条数据的测试结果
Status 200: 5000 RPS: 115.1 (requests/second) Max: 2285ms Min: 29ms Avg: 83.5ms 50% below 74ms 60% below 78ms 70% below 83ms 80% below 91ms 90% below 105ms 95% below 121ms 98% below 145ms 99% below 167ms 99.9% below 2265ms
代码2
public PostResult EditLesson2(LessonDto dto) { return lessonService.EditLesson(dto, UserInfo); }
测试结果
Status 200: 5000 RPS: 149.5 (requests/second) Max: 2793ms Min: 18ms Avg: 63.6ms 50% below 58ms 60% below 60ms 70% below 63ms 80% below 67ms 90% below 74ms 95% below 86ms 98% below 103ms 99% below 126ms 99.9% below 2160ms
posted on 2020-09-30 14:01 Simple is best 阅读(564) 评论(1) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?