Hi everyone, I am running a MySQL server on RDS (AWS) and I fired 5 INSERT queries into the database which take about 2 minutes to complete each one. The server is at 100% CPU which was to be expected but is this a bad thing? The MySQL server is still serving requests absolutely fine?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (3)
Hey Ben, how did that end?
It was not necessarily a bad thing, you didn't specify the scope of these 5 queries. Maybe you were inserting millions of row on dozens of columns or just a few rows with a few columns.
You could have connected to the server and try to query it to see what was going on in the meantime.
Each query inserts around 250000 rows or updates them, about 20 columns.
I saw the process list and the server was running fine, what I’m asking is why when the CPU was at 100% was it able to still serve requests ?
A combination of OS multi tasking, multi core and MySQL multi threading.
I'm not sure what sort of machines MySQL RDS runs on but is probably running on a Linux distribution which supports multiple threads running on a multi core CPU. This means that you effectively have N CPUs used by various threads. I'm not familiar with MySQL's architecture but I guess each connection is assigned a thread in a pool.
Even if you have a single CPU core each connection is handled by a separate unit of work (the thread), scheduled with a time slice by the kernel scheduler.
100% doesn't mean that your CPU is effectively disabled, it means that the computations inside that process are using 100% of the CPU allotted in a single scheduling period.
Most requests are I/O bound, so they don't bother the CPU much.
There are ways to overwhelm a database but if it can't handle 4 simultaneous inserts, then it's a toy DB :D