<?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: rizkypujiraharja</title>
    <description>The latest articles on DEV Community by rizkypujiraharja (@rizkypujiraharja).</description>
    <link>https://dev.to/rizkypujiraharja</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%2F419422%2F3619664d-e216-4ebf-b0a6-97e8328fc262.jpeg</url>
      <title>DEV Community: rizkypujiraharja</title>
      <link>https://dev.to/rizkypujiraharja</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rizkypujiraharja"/>
    <language>en</language>
    <item>
      <title>⚡️Golang VS Node.js⚡️ - CSV Data Export</title>
      <dc:creator>rizkypujiraharja</dc:creator>
      <pubDate>Tue, 17 Oct 2023 02:22:52 +0000</pubDate>
      <link>https://dev.to/rizkypujiraharja/golang-vs-nodejs-csv-data-export-29eh</link>
      <guid>https://dev.to/rizkypujiraharja/golang-vs-nodejs-csv-data-export-29eh</guid>
      <description>&lt;h2&gt;
  
  
  Prologue
&lt;/h2&gt;

&lt;p&gt;Three months ago, I encountered a challenge while exporting &lt;strong&gt;CSV&lt;/strong&gt; data using &lt;strong&gt;PHP&lt;/strong&gt;. The problem revolves around long duration and large memory consumption. Therefore, I started looking for alternative solutions to overcome this problem. This prompted me to conduct an experiment comparing data export speed using &lt;strong&gt;Node.js&lt;/strong&gt; and &lt;strong&gt;Golang&lt;/strong&gt;. I have created a project repository for this, which you can find at &lt;a href="https://github.com/rizkypujiraharja/benchmark-export-data-to-csv"&gt;https://github.com/rizkypujiraharja/benchmark-export-data-to-csv&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When it comes to exporting data in CSV format, efficiency and speed are key factors to consider. In this article, we will delve into how each programming language can be employed to accomplish this task and how to measure and compare their performance. By understanding the differences in approaches and performance outcomes among these two languages, you will be better equipped to make informed decisions when selecting the right tool for your next CSV data export project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here we go!!
&lt;/h2&gt;

&lt;p&gt;In this testing, I use a server with specifications of 8 GB RAM / 8 vCPU per day on &lt;a href="https://railway.app?referralCode=_eAGQJ"&gt;Railway&lt;/a&gt;. I have created a REST API to export data to CSV, which retrieves 50,000 records from MongoDB database.&lt;br&gt;
To minimize memory usage and enhance efficiency, I fetched the data in chunks of 10,000 rows per query. This approach enables more efficient processing of large datasets, as data does not need to be fully loaded into memory all at once. &lt;/p&gt;

&lt;p&gt;I will conduct two rounds of testing: the first one will be manual testing, and the second will involve load testing using &lt;a href="https://github.com/tsenart/vegeta"&gt;https://github.com/tsenart/vegeta&lt;/a&gt;.&lt;br&gt;
I hope this explanation helps you better understand the context of this testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  #Manual Testing
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Golang took 0.332430 seconds, while Node.js took 0.844 seconds. This means Golang is 3 times faster than Node.js.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uPPsfyDl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2p606nmgfwncqxmfn8vx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uPPsfyDl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2p606nmgfwncqxmfn8vx.png" alt="Golang manual test" width="800" height="169"&gt;&lt;/a&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BDWQ7sv1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5rnwi7j2ecwkjxmucqp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BDWQ7sv1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5rnwi7j2ecwkjxmucqp.png" alt="Node.js manual test" width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  #Load Testing
&lt;/h3&gt;

&lt;p&gt;The testing was conducted by sending 5 concurrent requests every second for a duration of 10 seconds.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Min&lt;/th&gt;
&lt;th&gt;Max&lt;/th&gt;
&lt;th&gt;Mean&lt;/th&gt;
&lt;th&gt;CPU Usage&lt;/th&gt;
&lt;th&gt;Memory Usage&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Golang&lt;/td&gt;
&lt;td&gt;530.717ms&lt;/td&gt;
&lt;td&gt;984.27ms&lt;/td&gt;
&lt;td&gt;572.301ms&lt;/td&gt;
&lt;td&gt;0.2vCPU&lt;/td&gt;
&lt;td&gt;317MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node.js&lt;/td&gt;
&lt;td&gt;6.245s&lt;/td&gt;
&lt;td&gt;18.586s&lt;/td&gt;
&lt;td&gt;22.872s&lt;/td&gt;
&lt;td&gt;0.7vCPU&lt;/td&gt;
&lt;td&gt;1.03GB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Vegeta Result&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EaKTGGqt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcob1ugblw4qh9g9viwy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EaKTGGqt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcob1ugblw4qh9g9viwy.png" alt="Vegeta result golang" width="800" height="176"&gt;&lt;/a&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2DZTnFU4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0z4kz1a1muyqztv0x03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2DZTnFU4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0z4kz1a1muyqztv0x03.png" alt="Vegeta result nodejs" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Usage Resource&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c867wXT4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ty7i0ii7p4kecufhoxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c867wXT4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ty7i0ii7p4kecufhoxi.png" alt="Resource test golang" width="800" height="481"&gt;&lt;/a&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jlagPh-N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7k1t60snaee9wtp8b7y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jlagPh-N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7k1t60snaee9wtp8b7y.png" alt="Resource test nodejs" width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is evident that when testing concurrent requests, Golang outperforms Node.js.&lt;/p&gt;

</description>
      <category>go</category>
      <category>node</category>
      <category>php</category>
      <category>backend</category>
    </item>
    <item>
      <title>Cara mengubah format tanggal menjadi bahasa indonesia di Laravel</title>
      <dc:creator>rizkypujiraharja</dc:creator>
      <pubDate>Thu, 23 Jul 2020 04:09:14 +0000</pubDate>
      <link>https://dev.to/rizkypujiraharja/cara-mengubah-format-tanggal-menjadi-bahasa-indonesia-di-laravel-iim</link>
      <guid>https://dev.to/rizkypujiraharja/cara-mengubah-format-tanggal-menjadi-bahasa-indonesia-di-laravel-iim</guid>
      <description>&lt;p&gt;Di Laravel kita dapat dengan mudah mengubah format tanggal menjadi sesuai keinginan kita termasuk mengubah nama hari dan bulan ke bahasa indonesia dengan menggunakan package yang bernama &lt;strong&gt;Carbon&lt;/strong&gt;. Beruntungnya di laravel kita tidak perlu lagi menginstall Carbon secara manual karena sudah secara otomatsi terinstall ketika kita menginstall laravel.&lt;/p&gt;

&lt;p&gt;Ada beberapa cara untuk megubah &lt;a href="https://urangsunda.web.id/mengubah-format-tanggal-indonesia-laravel-dengan-carbon/"&gt;format tanggal&lt;/a&gt; menjadi bahasa yang kita inginkan seperti artikel di blog lain yang menunjukan cara menggunakan seperti berikut&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setlocale(LC_TIME, 'id_ID');
\Carbon\Carbon::setLocale('id');
\Carbon\Carbon::now()-&amp;gt;formatLocalized("%A, %d %B %Y");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;dengan cara diatas kita wajib menginstall locale id_ID. untuk melihat sudah terinstall atau belum&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;locale -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;nah cara yang lebih mudahnya adalah menggunakan method &lt;strong&gt;isoFormat()&lt;/strong&gt;, kita hanya perlu mengubah config pada folder &lt;em&gt;italics*config/app.php*italics&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'locale' =&amp;gt; 'id',
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Berikut adalah contoh kode untuk mengubah format tanggalnya&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$today = Carbon::now()-&amp;gt;isoFormat('D MMMM Y');
// "28 Juni 2020"

$today = Carbon::now()-&amp;gt;isoFormat('dddd, D MMMM Y');
// "Minggu, 28 Juni 2020"

$today = Carbon::now()-&amp;gt;isoFormat('dddd, D MMM Y');
// "Minggu, 28 Jun 2020"

$registeredAt = $user-&amp;gt;created_at-&amp;gt;isoFormat('dddd, D MMMM Y');
// "Minggu, 28 Juni 2020"

$lastUpdated = $post-&amp;gt;updated_at-&amp;gt;diffForHumans(); 
// "2 hari yang lalu"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;untuk membuat format yang lain bisa dilihat di dokumentasi resminya &lt;a href="https://carbon.nesbot.com/docs/#api-localization"&gt;disini&lt;/a&gt; &lt;br&gt;
Sekiat untuk postingan kali ini semoga bermanfaat. Terima kasih&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>carbon</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
