<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="135662" data-post-id="135662">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jeremyjh" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jeremyjh/120/5995_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jeremyjh
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="frumos" data-post="31" data-topic="23815">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/f/e495f1/48.png" class="avatar"> frumos:</div>
<blockquote>
<p>How to orchestrate this work how to retry failed tasks, how lock tasks, how to partition and shard task to particular node?</p>
</blockquote>
</aside>
<p>If you want to build a system to do all this yourself, Elixir is a great system to build that orchestration layer with. I think Hadoop provides a lot of that orchestration for you in the context of batch processing, but maybe I do not understand your use case. Hadoop distributes tasks to where the data is and/or where compute resources are available. There are retry parameters, scheduling constraints, you name it. You need more processing power, you just bring more nodes up. I can understand not wanting to deal with the accidental complexity that system brings, and maybe your system doesn’t need it, but I think the statement “Java can’t scale batch processes” is indefensible. That is all I’m pointing out.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="135662" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/32">Post #31</a>
	                </div>
	            </div>
              <div id="likers-container-135662" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="135662"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #31"></div>
  </section>
</div>
    <div class="postbit" id="135741" data-post-id="135741">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Don’t forget that the BEAM is a <em>fantastic</em> glue.  It can orchestrate nodes running native code (like rust or C++ or python or whatever) with ease, handling failures, restarting, etc…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="135741" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/33">Post #32</a>
	                </div>
	            </div>
              <div id="likers-container-135741" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="135741"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #32"></div>
  </section>
</div>
    <div class="postbit" id="135893" data-post-id="135893">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="N0x90" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/N0x90/120/13463_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  N0x90
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If you need something really speedy use an FPGA</p>
<p><a href="https://www.miraclelinux.com/labs/pdf/fpga-en" class="onebox" target="_blank" rel="noopener nofollow ugc">https://www.miraclelinux.com/labs/pdf/fpga-en</a></p><aside class="onebox allowlistedgeneric" data-onebox-src="https://docs.amd.com/v/u/en-US/ug1655-ise-documentation">
  <header class="source">
      <img src="https://docs.amd.com/favicon.ico" class="site-icon" alt="" width="16" height="16">

      <a href="https://docs.amd.com/v/u/en-US/ug1655-ise-documentation" target="_blank" rel="noopener nofollow ugc">docs.amd.com</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://docs.amd.com/v/u/en-US/ug1655-ise-documentation" target="_blank" rel="noopener nofollow ugc">AMD Technical Information Portal</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="135893" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/34">Post #33</a>
	                </div>
	            </div>
              <div id="likers-container-135893" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="135893"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #33"></div>
  </section>
</div>
    <div class="postbit" id="135963" data-post-id="135963">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wanton7" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wanton7/120/14151_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wanton7
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>We use Microsoft Orleans a .NET C# distributed virtual actor framework at work. Maybe that’s something you want to checkout if it’s distributed model is something you can work with. C# performance is at least same as Java, maybe faster, plus C# has good async implementation built in using <code>async</code> and <code>await</code> keywords. You can also use F# functional language instead of C# if you use it through Orleankka.</p>
<p>I’ve read or maybe watched a video that Microsoft has used it to distribute IO and CPU bound work.</p>
<ul>
<li>Github <a href="https://github.com/dotnet/orleans" class="inline-onebox" rel="noopener nofollow ugc">GitHub - dotnet/orleans: Cloud Native application framework for .NET · GitHub</a></li>
<li>Gitter <a href="https://gitter.im/dotnet/orleans" rel="noopener nofollow ugc">https://gitter.im/dotnet/orleans</a></li>
<li>Orleankka <a href="https://github.com/OrleansContrib/Orleankka" class="inline-onebox" rel="noopener nofollow ugc">GitHub - OrleansContrib/Orleankka: Functional API for Microsoft Orleans http://orleanscontrib.github.io/Orleankka · GitHub</a></li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="135963" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/35">Post #34</a>
	                </div>
	            </div>
              <div id="likers-container-135963" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="135963"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #34"></div>
  </section>
</div>
    <div class="postbit" id="136012" data-post-id="136012">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="chulkilee" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/chulkilee/120/6207_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  chulkilee
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m curious which part is actually slow.</p>
<ul>
<li>file IO</li>
<li>string split / parsing</li>
<li>passing large map across functions (in reduce)</li>
<li>putting values into large map</li>
<li>overhead of stream</li>
<li>…</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="136012" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/36">Post #35</a>
	                </div>
	            </div>
              <div id="likers-container-136012" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="136012"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #35"></div>
  </section>
</div>
    <div class="postbit" id="136027" data-post-id="136027">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jola" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jola/120/18010_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jola
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Based on my experience optimizing a similar code snippet (spent lots of hours on it, measuring each part).</p>
<ul>
<li>Streaming into lines is very slow compared to reading the entire string directly. Writing a stream is also slower than writing a complete string. Keeping unicode support is slower than not.</li>
<li>Splitting is fast when you can split 1 big thing, but slow when you split many small things.</li>
<li>Passing a large map across functions is not something that takes time. As long as it stays within the process nothing gets moved.</li>
<li>Putting values in large map is very slow (depending on your definition of large). The time it takes grows with the size of the map (unlike ETS which is constant time).</li>
<li>Overhead of stream is small, but noticeable with a large number of items (like this case). Memory is the deciding factor. If you can spare it, don’t use Stream.</li>
</ul>
<p>Another thing, causing lots of GC by constantly growing the heap. With a similar use case script I was able to speed it up considerably by setting the initial process heap size to a very large number, which avoids growing the heap a bunch of times. GC in general is costly, if you can avoid it, do. But that’s up to your memory limits.</p>
<p>ps come to my talk at CodeElixir LDN or ElixirConf US where I will be talking about this thing exactly</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="136027" data-batch-url="/posts/batch_likers">
                        13
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/37">Post #36</a>
	                </div>
	            </div>
              <div id="likers-container-136027" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="136027"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #36"></div>
  </section>
</div>
    <div class="postbit" id="136029" data-post-id="136029">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In case it wasn’t mentioned (I just took a passing glance at this thread), replacing Enum/Stream functions with plain recursion can sometime improve performance significantly (at the expense of having a more complicated code). Not sure if it would help here, because you seem to be doing a lot in each step, but you can give it a try.</p>
<p>In general , I wouldn’t be surprised if in some scenarios a sequential Java program is about 10x faster than Elixir. BEAM languages are definitely not famous for their speed <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> That said, IME, in many cases it is possible to get close enough to the speed of faster languages with a combination of proper algorithms and BEAM specific technical tricks.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="136029" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/38">Post #37</a>
	                </div>
	            </div>
              <div id="likers-container-136029" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="136029"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #37"></div>
  </section>
</div>
    <div class="postbit" id="136960" data-post-id="136960">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="frumos" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  frumos
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Good evening everybody, sorry for delayed update, I had extra hectic working week so put my POC on hold, but today I finally competed first part and got more or less working version.<br>
In short results are just tremendous - I did not expect such a great outcome. And outcome is as following:</p>
<p>In Elixir app:</p>
<ul>
<li>each hour, I download ~400 CSV-like files from S3, total size ~70-75Gb. Total # of records to aggregate is ~0.55-0,7 billions. Files are in different size from 0.5Mb to 2,2Gb</li>
<li>after downloading each files is processed with aggregation function what we discussed here already</li>
</ul>
<p>the average latency is ~17-18 minutes for the whole work, which is almost 2 times better than I did with Java prototype 1 year ago!!!</p>
<p>The CPU usage is ~50%, the memory usage ~50% which is slightly higher than in Java but totally acceptable (please see screenshot bellow).</p>
<p>I performed 3 test runs for different hours. The test platform is my cloud devbox C5.9XL (36 cores, 25Gb net, 72Gb RAM)</p>
<p>This is first functional step in the POC (and I still need to work a lot) but first results exceed all my expectation!</p>
<p>Thanks to everybody who helped to reach me such results.</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/f/b/fbf2acf13465401ee88e5ed3b5dd97ffd795ca89.png" data-download-href="https://forum.elixirforum.com/uploads/default/fbf2acf13465401ee88e5ed3b5dd97ffd795ca89" title="kona-elixir-middle" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/f/b/fbf2acf13465401ee88e5ed3b5dd97ffd795ca89_2_689x391.png" alt="kona-elixir-middle" data-base62-sha1="zWPM3l5lb3fLp0GUijMXb8s8Ipb" width="689" height="391" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/f/b/fbf2acf13465401ee88e5ed3b5dd97ffd795ca89_2_689x391.png, https://forum.elixirforum.com/uploads/default/optimized/3X/f/b/fbf2acf13465401ee88e5ed3b5dd97ffd795ca89_2_1033x586.png 1.5x, https://forum.elixirforum.com/uploads/default/original/3X/f/b/fbf2acf13465401ee88e5ed3b5dd97ffd795ca89.png 2x" data-dominant-color="EBEAEA"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">kona-elixir-middle</span><span class="informations">1195×678 133 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="136960" data-batch-url="/posts/batch_likers">
                        28
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/elixir-language-performance-tuning-for-1-quadrillion-records-per-month/23815/39">Post #38</a>
	                </div>
	            </div>
              <div id="likers-container-136960" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="136960"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>