BCryptPasswordEncoder.matches()到底有多耗CPU

2025年10月17日12:44:05 發表評論 142 ℃

一個簡單的登錄接口,8核CPU,500個并發直接CPU吃滿。調整到50個并發,還是直接8核CPU跑滿。最后無奈用20個并發測下,發現依然跑滿。

BCryptPasswordEncoder.matches()到底有多耗CPU

接口請求很簡單,無非就是數據庫查詢數據驗證賬號密碼,而數據庫。

BCryptPasswordEncoder.matches()到底有多耗CPU

數據庫查詢和feign調用基本都是io請求,唯一存在計算的就是密碼加密,現在用的是BCryptPasswordEncoder.matches()。

網上一查這個方法的確會消耗大量的CPU資源,屬于CPU密集型計算。

于是換了一個其他加密方法,500并發,CPU只消耗了60%左右。

BCryptPasswordEncoder.matches()到底有多耗CPU

數據庫QPS也起來了。

BCryptPasswordEncoder.matches()到底有多耗CPU

測試多次基本穩定了。

BCryptPasswordEncoder.matches()到底有多耗CPU

【騰訊云】云服務器、云數據庫、COS、CDN、短信等云產品特惠熱賣中

發表評論

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: