Will Upgrading RDS Instance Improve Write Speed?

I am writing data to an RDS MySQL DB, but it is extremely slow (> 10 minutes for ~2.5k rows). I am currently running a db.t4g.micro instance with 2 vCPUs and 1 GB of RAM. Will upgrading to a db.t3.large instance with 16 GB of RAM improve the write speed?

Check out metrics on the disk first. If you have a tiny gp2 disk it’ll be following the usual 3 IOPS per GiB performance curve as any other gp2 disk.

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html#Concepts.Storage.GeneralSSD

Enable Performance Insights, then you can look at the wait time and see where it’s spending the majority of time, and what the insurance resources look like

https://aws.amazon.com/rds/performance-insights/

That is very tiny for a database server, so it likely doesn’t have enough resources (especially memory), but could also be storage bound

Your issue is likely to due to autocommit. Which ensures persistent storage after each INSERT. Performance insights will highlight this.

If you are doing large batch inserts, you can disable autocommitting temporarily by starting a transaction and then committing the transaction.

t4g.micro is way too small to run a database. I/O is determined by two things: the size of the drive (gp2) and the size of the instance.

I strongly suggest you increase either or both.

Try switching to gp3. gp2 IOP quotas are proportional to size, and it comes out pathologically bad for small workloads.

I do agree this is likely not a bottlneck by the DB Server itself but due to your Code. Maybe it’s commiting after each line, or even worse opening a new connection for each row Insert.

I mean we are talking about 250 rows per Minute… that is 4 rows per second …

This could be a connection beeing established. Even this small of a database should not be this slow.

Maybe you can Post a simplified Version of the Code that does the inserts?

I would test this with a splash of python code to test what the breakpoints are for performant increases

Instance size determines: Throughput and IO, same as Throughput and IO are determined by the storage.

More specific: iirc the t4g.small had like 25(?) mbit burst throughput and somewhere around 3k burst IO for a limited amount of time ( I think it lasted only for a few minutes, check EBS Byte balance and throughput balance - can’t remember names rn in monitoring).

Also, t4g are burstable as well, make sure you run it in unlimited mode, this will eat up burst credits, though (hope I am not mixing up this setting with EC2, could be that you can’t set t4g to standard).

And last, but not least: What was said above. In that instance size go with a simple gp3 volume, you’ll get 3k IO and 125mb throughput out of the box.

For databases in general: memory

Disk access is almost always buffered in memory because memory access is orders of magnitude faster than disk.

For AWS specifically: the larger instance sizes allow for higher network bandwidth for disk-attached-storage. Faster access to disk = faster I/O.

Depends on the workload. RAM is usually a big consideration, disk is important if there’s a lot of IO, CPU if There is going to be alot of processing. RDS doesn’t give you much options for tuning compared to having your own VM.

That said, your instance is tiny, and given you don’t yet have much experience in DBs it might be worth switching to an auto scaling offering where AWS handles the performance optimisation.

Should you persist with your current strategy, make sure you at least read up on indexes and query plans. A bad query can literally go 100x faster with correct indexes.

Are you using Aurora? If so, V1 and you have secondary indexes you should look into upgrading to V2. That was an issue we had

You doing individual writes or batches? Synchronously, or multi-threaded? If you’re doing them one at a time, one by one, that’s the problem.

I don’t agree it is way too small, it depends on the usage requirements. As the OP is inserting 2.5k rows, it is probably suggesting this is the case. I was using T3s years ago with aurora and getting some mileage on call data record ingest for telecoms, but you’ve got to take some steps to get the best performance…

For the OP…

How many rows in the table already? How many indexes? Are you wrapping this in a transaction? Are you using any bulk insert mechanics? You can speed up the insert using such mechanics but if you have 10 million rows already and lots of indexes, then you may be grinding to a halt trying to re-index so often.

Also for RDW are T class instances set to unlimited automatically? If not then you could be consuming all the CPU burst credits and then the database performance will bin. There is similar bursty nature to IO as well and once you’ve consumed this, then you will be IO throttled.

Scaling the instance will help but cost and you should be sure your ingest process is efficient or you’ll burn a lot of cash.

So you need a SQL dB? NoSQL is pretty cool and you can still build relationships, you just won’t be (necessarily) doing the joins yourself. Mongodb atlas has a free tier. It’s not AWS but it’s SaaS and is very cost effective and performant and you can sign up and create an instance free, paid for production are also affordable and in my experience performance is extremely good.

T type instances are cpu burstable, never use those for databases, check other types of instances that have stable cpu performance.
Check the c7g types for example.

why not t4g large instead?

$$$$ unless I wanted to constantly have to shut off the server every 7 days. I’m still running and using the micro instance for ~22 bucks a month

as in why do u choose t3 large over t4g large?

I didn’t, it’s a t4g micro

u said this “Will upgrading to a db.t3.large instance with 16 GB of RAM improve the write speed?”

So i’m asking why not upgrade to t4g large instead as i think it is cheaper and has better performance than the t3 equivalent