<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Two shots in the dark:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">// Your graph shows a memory spike close to the left area</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">One possibility is that you have some incoming data, which occurs rarely. And when the processing of said data happens, you shoot through your 8Gb limit. If this is the case, then it's often that you have smaller spikes as well in the code. Your tools for dealing with this is erlang:system_monitor/2, which allows you to monitor if the heap of a process becomes very large. And also the process flag max_heap_size. It allows you to narrow down where you are using excessive amounts of memory and rewrite that part of the program to avoid using as much memory.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">// You have lots of binary_alloc data</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">This is possibly because you have sub-binaries which are keeping the underlying binary alive. If the underlying binary is large, and the sub-binaries small, you can get into trouble. Nowadays, the VM is better at handling these problems, and you might want to upgrade the VM from OTP21, though I can't remember which older version improved the binary handling. Your active mitigation tool in this case is binary:copy/1, which can force a subbinary to be reallocated, freeing up the need to thread a 1-4megabyte block around in the system. It's especially important if you have certain binary keys in the system, which are large enough that they point to the underlying binary.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The key idea is to figure out where the memory usage is, and why it's spiking. Then think about a solution. One possible solution is to outright reject incoming data that's too big, forcing the client to split work into smaller units. Another possible solution is to look at streaming data flow, rather than large up-front packets.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 23, 2021 at 8:13 AM Hitesh Kishorbhai Vaghani <<a href="mailto:hitesh.v@redbus.com">hitesh.v@redbus.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">Hi,<br></p></div></div></div></div></div></div><div class="gmail_quote"><div dir="ltr"><div><br></div><div>We are eCommerce company and we use Erlang heavy in our production system. We are facing one issue which we are not able to figure out. </div><div>My Erlang virtual machine shows 2.5GB memory usage but OS occupies 8GB plus RAM and the application getting restarted from time to time after RAM exhaust. We tried checking remote debugging no process is utilizing more memory in the erlang application. Process memory is also showing 2.56 GB.</div><div>We are using ubuntu 20.04 and OTP 21. </div><div><br></div><div>VM</div><div><img src="cid:ii_ks8uu7bk0" alt="VM.png" width="452" height="100"><br></div><div><br></div><div>Service Status</div><div><img src="cid:ii_ks8uvwal1" alt="Service status.png" width="452" height="168"><br></div><div><br></div><div>OS Memory.png<br></div><div><img src="cid:ii_ks8uy0xh3" alt="OS Memory.png" width="452" height="35"><br></div><div><br></div><div>Erlang Memory</div><div><img src="cid:ii_ks8v0fzm4" alt="erlang_memory_snap.png" width="268" height="165"><br></div><div><br></div><div>Also Attaching Pmap screenshot.</div><div><br></div><div>Is there anything we should be checking? How can we fix it? Any direction will help.<br></div><div><br clear="all"><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><b>Regards,</b><br></p><p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><b><span style="font-size:12pt;font-family:"Times New Roman",serif">Hitesh Vaghani</span></b><span style="font-size:12pt;font-family:"Times New Roman",serif"> | </span><font color="#262626" face="Times New Roman, serif"><span style="font-size:16px">Engineering</span></font></p><p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><b><span style="font-size:12pt;font-family:"Times New Roman",serif">E-Mail </span></b><span style="font-size:12pt;font-family:"Times New Roman",serif">| </span><span style="font-size:12pt;font-family:"Times New Roman",serif"> </span><span style="font-size:12pt;font-family:"Times New Roman",serif;color:rgb(64,109,190)"><a href="mailto:email@go-mmt.com" style="color:rgb(17,85,204)" target="_blank">hitesh.v@</a><a href="http://redbus.com/" style="color:rgb(17,85,204)" target="_blank">redbus.com</a></span><span style="font-size:12pt;font-family:"Times New Roman",serif;color:rgb(68,114,196)"> </span><span style="font-size:12pt;font-family:"Times New Roman",serif">| </span><span style="font-size:12pt;font-family:"Times New Roman",serif;color:rgb(68,114,196)">+91 9558476850</span></p></div></div></div></div></div></div></div></div></div></div></div>
</div></div>
<br>
<font size="3"><b style="color:rgb(0,0,0);font-family:"Times New Roman";font-style:normal;font-variant:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium;font-weight:normal"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">::DISCLAIMER::</span><br><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">----------------------------------------------------------------------------------------------------------------------------------------------------</span><br><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">The contents of this e-mail and any attachments are confidential and intended for the named recipient(s) only.E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents(with or without referred errors) shall therefore not</span><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> attach any liability on the originator or redBus.com. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of redBus.com. Any form of reproduction, dissemination, copying, disclosure, modification,distribution and / or publication of this message without the prior written consent of authorized representative of</span><span style="font-size:15px;font-family:Arial;color:rgb(17,85,204);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"><a href="http://redbus.in/" target="_blank"> redbus.</a>com</span><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.Before opening any email and/or attachments, please check them for viruses and other defects.</span></b></font></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">J.</div>