<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vishal Anand</title>
    <description>The latest articles on DEV Community by Vishal Anand (@vishalanandl177).</description>
    <link>https://dev.to/vishalanandl177</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F367795%2F41ea9e34-9202-44d1-b668-25d252312722.jpeg</url>
      <title>DEV Community: Vishal Anand</title>
      <link>https://dev.to/vishalanandl177</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vishalanandl177"/>
    <language>en</language>
    <item>
      <title>MySQL Bulk Insert taking long time</title>
      <dc:creator>Vishal Anand</dc:creator>
      <pubDate>Tue, 09 Jun 2020 13:51:39 +0000</pubDate>
      <link>https://dev.to/vishalanandl177/mysql-bulk-insert-taking-long-time-1omk</link>
      <guid>https://dev.to/vishalanandl177/mysql-bulk-insert-taking-long-time-1omk</guid>
      <description>&lt;p&gt;I'm using python, using MySQL connector. I'm having nearly 67 Million (14GB) entries in a table. When I do a bulk insert of 2K data each time, it is taking very long to insert.&lt;/p&gt;

&lt;p&gt;Inserted 2000 rows in 23 Seconds&lt;br&gt;
Inserted 2000 rows in 25 Seconds&lt;br&gt;
Inserted 2000 rows in 29 Seconds&lt;br&gt;
Inserted 2000 rows in 28 Seconds&lt;br&gt;
For another table (having less data), insertion speed is fine(2-4 seconds).&lt;/p&gt;

&lt;p&gt;After using the transaction:&lt;/p&gt;

&lt;p&gt;Inserted 2000 rows in 21 Seconds&lt;br&gt;
Inserted 2000 rows in 20 Seconds&lt;br&gt;
Inserted 2000 rows in 20 Seconds&lt;br&gt;
Inserted 2000 rows in 18 Seconds&lt;br&gt;
How can I improve the speed?&lt;/p&gt;

&lt;p&gt;I'm using AWS RDS, Aurora MySQL version 5.7.12 (db.t3.medium) having CPU usage 4% to 8%. My objective is to insert around 50K data into a table. This table is currently having nearly 67 Million (14GB) data already. Data must need to be inserted ASAP. This almost real-time data is very important for the client. The table is having 18 columns: id(PK auto-increment), customer, serial_number, batch, data, and some others. Indexes are on (customer,serial_number) - To make the combination unique, batch - For searching, data(unique). All are by default BTREE indexed. This insertion should need to take less than 1 minute for 50K. But currently taking around 15 minutes. I've tried inserting on an empty table. It is inserting 50K data just in 5-7 seconds. As you increase the number of entries in the table, the insertion process time is increasing.&lt;/p&gt;

&lt;p&gt;Is upgrading MySQL version is going to speed-up the insertion process anyhow? Is it the last option to split or partitioning the table? I cannot consolidate the data because each data is important, specially the last 2 years of data. Please help.&lt;/p&gt;

&lt;p&gt;My table schema is already having some default values in 8 columns and these data are never going to update later. There are not many Read/Write operations are going on. Almost 2 or in some cases 3 selects per second as per RDS monitor shows.&lt;/p&gt;

</description>
      <category>python</category>
      <category>database</category>
      <category>sql</category>
      <category>aws</category>
    </item>
    <item>
      <title>How to write cron jobs on AWS EC2 instance</title>
      <dc:creator>Vishal Anand</dc:creator>
      <pubDate>Thu, 16 Apr 2020 07:22:30 +0000</pubDate>
      <link>https://dev.to/vishalanandl177/how-to-write-cron-jobs-on-aws-ec2-instance-mf4</link>
      <guid>https://dev.to/vishalanandl177/how-to-write-cron-jobs-on-aws-ec2-instance-mf4</guid>
      <description>&lt;p&gt;Cron is a time-based job scheduler run on the server in the Unix-like operating system.&lt;br&gt;
To perform such action we write cron expression made of five fields, followed by a shell command to execute.&lt;/p&gt;

&lt;p&gt;First, we have to log in to AWS EC2 instance using CLI (Command Line Interface).&lt;br&gt;
For log in, type:&lt;br&gt;
ssh -i &amp;lt;.pem file&amp;gt; username@ip_address&lt;br&gt;
After successfully log in, type: &lt;br&gt;
crontab -e&lt;br&gt;
then select any editor from the list (preferred nano).&lt;br&gt;
 Type cron command. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;* * * * * php /var/www/html/file/name.php
Now save the changes. If you are using nano editor type Ctrl + x and Select Y and then press Enter.
To list out all the running cron type:
crontab -l&lt;/li&gt;
&lt;li&gt;is used for every minute, every hour, etc. Here ”php” is shell command followed by file location of php script, separated by white space.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to run nodejs script then type:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;* * * * * node /var/www/html/nodejs/file/name.js
Each from five stars represents a job:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How to write CRON jobs on AWS EC2 instance&lt;/p&gt;

&lt;p&gt;Allowed special characters are:&lt;/p&gt;

&lt;p&gt;Comma (,) – Commas are used to separate the item list.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Cron to run at minute 1 and 10 every hour &lt;br&gt;
1,10 * * * * php /var/www/html/file/name.php&lt;br&gt;
Cron to run at mid-night and mid-day &lt;br&gt;
0 0,12 * * * php /var/www/html/file/name.php&lt;br&gt;
Hyphen (-) – Hyphen defines range.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Cron to run at every minute from 1 minute through 10 minute, every hour&lt;br&gt;
0-10 * * * * php /var/www/html/file/name.php&lt;br&gt;
Cron to run at minute 0 past every hour from 6 AM through 6 PM &lt;br&gt;
0 6-18 * * * php /var/www/html/file/name.php&lt;br&gt;
Slash (/) – Slash defines step values.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Cron to run every 5th minute &lt;br&gt;
*/5 * * * * php /var/www/html/file/name.php&lt;br&gt;
Cron to run at minute 0 past every 6th hour &lt;br&gt;
0 */6 * * * php /var/www/html/file/name.php&lt;br&gt;
Sleep cron:&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Cron to run every minute after sleep of 30 seconds&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;* * * * * sleep 30; php /var/www/html/file/name.php&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more examples visit: &lt;a href="https://coderssecret.com/how-to-write-cron-jobs-on-aws-ec2-instance/"&gt;https://coderssecret.com/how-to-write-cron-jobs-on-aws-ec2-instance/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cron</category>
      <category>ec2</category>
    </item>
  </channel>
</rss>
