Need help debugging terrible performance #2755
-
Hi, I recently implemented the same RESTful API server once using r2d2 + Diesel + Rocket and another time using sqlx + actix-web. I benchmarked both servers using vegeta, a CLI HTTP load testing tool, and here are the results I got:
The SA server's performance is pretty good but the DR server's performance is absolutely terrible. I think the issue with the DR server has something to do with how r2d2 and Diesel are configured/used but I can't figure out exactly what the problem is. Complete source code for all DB operations in the DR server: https://github.com/pretzelhammer/kanban/blob/main/diesel-rocket/src/db.rs If someone could take a look at the code above and tell me what I'm doing wrong I'd really appreciate it. At least I hope I'm doing something wrong, I would be shocked if r2d2's and Diesel's performance was just inherently this bad. For comparison, if it's at all helpful, here's the complete source code for all DB operations in the SA server: https://github.com/pretzelhammer/kanban/blob/main/sqlx-actix-web/src/db.rs |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I fear it's not really possible to help you here, at least not with the information you've provided here. This is missing at least the following information:
Leaving these points beside: Are you even sure that this is caused by diesel and not by an other difference in your implementation? At least our benchmarks indicate that diesel on itself is in all situations at least as performant as sqlx, if not much more performanter. Therefore as general advice for benchmarks: If you try to measure the performance difference between only two crates that can serve the same propose, do only change that one piece in your code and don't couple it with other changes (like using rocket instead of actix_web here). If possible do not include any other code at all (so only measure the raw performance of sqlx vs diesel instead of including a full web framework), as this can greatly change the results for other reasons without that being a result of the actual thing you are trying to measure. |
Beta Was this translation helpful? Give feedback.
I fear it's not really possible to help you here, at least not with the information you've provided here. This is missing at least the following information:
Leaving these points beside: Are you even sure that this is caused by diesel and not by an other difference in your implementation? At least our benchmarks indicate that diesel on itself is in all situations at least as performant as sqlx, if not much more performanter. Therefore as general advic…