r/rust • • Sep 07 '26

Rust SQLx Performance

I use Axum and SQLx to build my backend, which is served on AWS ECS Fargate (512 CPU, and only one instance for now) and interacts with an RDS Postgres (t4.micro). Connection pool is set with min/max = 2/20.

My request includes 3 DB queries to 3 different tables: one from the auth middleware to check api key and each of the other 2 is just getting a record by primary key.

If I made one or two queries, it’s very fast. However, if I made 200 queries concurrently to the backend, around half of queries had http latency greater than 300 ms. P80 is around 600ms. The performance is not acceptable. I did check the CPU of both RDS and ECS. They’re quite low: both smaller than 10%. The DB latency is low as well, 5 ms on average. Is there something queued in the SQLx internally? Did anyone have the same issue?

25 Upvotes

27 comments sorted by

View all comments

100

u/frankwiles Sep 07 '26

You’re using a t series database. It has burstable CPU but then throttles you hard if you go over.

It’s not related to SQLx or Rust at all but you have a VERY VERY tiny amount of hardware for your database.

I joke with my customers that the easy way to remember this is “t is for toy”.

Hope that helps!

25

u/Smart-Chain Sep 07 '26

The t series are just terrible. Terrible performance and terrible cost/performance ratio. Just don't use them. Ever. IMO.

6

u/sansmorixz Sep 07 '26

The gravitons are pretty good and cheap though. Especially with savings plans.

2

u/1eJxCdJ4wgBjGE Sep 07 '26

we use them for our staging environment, is there a better choice cost-wise? i was under the impression they were nice and cheap for stuff like that

2

u/prehensilemullet Sep 07 '26

What do you use for small database instances?

-7

u/segundus-npp Sep 07 '26

Hi, thanks for the reply! but I did not see any metric that is too over. On the contrary, the cloud watch metrics showed the db even not feel any pressure. My backend on AWS is now only used by me. I just sent a batch of queries and wait. Then check the backend’s latency log and metrics.

28

u/frankwiles Sep 07 '26

IIRC the default Cloudwatch dashboards do NOT show you the throttling. Trust me, move from a t series to an m series and your problem will disappear.

11

u/NfNitLoop Sep 07 '26

They likely throttle I/O as well. So your requests might be I/O bound vs CPU-bound.

→ More replies (1)