I have 15 Amazon AWS EC2 t1.micro instances which simultaneously populate Amazon RDS MySQL d2.m2.xlarge database with data using large INSERTs (40000 rows in query).
The queries are sent continuously. The table is INNODB, two INT columns, there is index for both columns. CPU utilization of RDS instance is about 30% during data receiving.
When I have one EC2 instance, the speed is in orders of magnitude faster than I run 15 instances simultaneously. In light of this, the 15-instances group works slower and slower until the speed becomes totally unsatisfactory.
How can I optimize performance for this process?
SHOW CREATE TABLE result is the following:
CREATE TABLE `UserData` ( `uid` int(11) NOT NULL, `data` int(11) NOT NULL, PRIMARY KEY (`uid`,`data`), KEY `uid` (`uid`), KEY `data` (`data`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1
I need 2 indexes because it is necessary for me to fetch data by
uid and by
I insert data with
INSERT INTO UserData (uid, data) VALUES (1,2),(1,3),(1,10),... with 40000
15 parallel instances insert ~121 000 000 rows in 2 hours, but I am sure that it can be much more faster.