<div dir="ltr">In my experience, it&#39;s usually a few naughty requests that gobble up a lot of memory. We found it useful to record process vsize and rss at the beginning and end of the request cycle to generate warnings like this:<div><br></div><div>Warning: PID 28710 grew rss by 20% from 42 MiB to 51 MiB serving GET /api/search?q=foo</div><div><br></div><div>One of the common mistakes in our app was inflating all row objects in a result set at the same time when it wasn&#39;t needed. We prefetch a lot so row objects and their related objects get big. In those cases, this:</div><div><br></div><div><div><span class="" style="white-space:pre">        </span>foreach my $row ($rs-&gt;all)</div><div><span class="" style="white-space:pre">        </span>{</div><div><span class="" style="white-space:pre">                </span>push @results, $row-&gt;to_json,</div><div><span class="" style="white-space:pre">        </span>}</div><div><br></div><div>Will use a lot more memory than this:</div><div><br></div><div><span class="" style="white-space:pre">        </span>while (my $row = $rs-&gt;next)</div><div><span class="" style="white-space:pre">        </span>{</div><div><span class="" style="white-space:pre">                </span>push @results, $row-&gt;to_json,</div><div><span class="" style="white-space:pre">        </span>}</div></div><div><br></div><div>DBIx::Class&#39;s HashRefInflator is often touted for its speed but it&#39;s also a lot lighter on memory...</div><div><br></div><div>Another thing you could consider is using Plack to run all your Perl apps in the same server/process. Memory for all common dependencies would be shared among the apps in that case which might get you a decent gain...</div><div><br></div><div>There&#39;s also a bunch of Plack::MiddleWare&#39;s on CPAN to help with debugging/profiling of apps...</div><div><br></div><div>/L<br></div><div><br></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 11, 2015 at 3:03 PM, Denny <span dir="ltr">&lt;<a href="mailto:2015@denny.me" target="_blank">2015@denny.me</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>I run a server with 18 separate installs of ShinyCMS running, with at least 3 and sometimes 20 processes per install.  122 perl-fcgi processes in total.  They look a bit bigger than most of your processes. I&#39;ve got 8GB of RAM, and I&#39;m pushing up against the edges of it a bit, but I don&#39;t usually have any problems.<br>
<br>
Hope that&#39;s useful info!<br>
<br>
<br><br><div class="gmail_quote"><div><div>On 11 June 2015 13:31:16 BST, Jesse Sheidlower &lt;<a href="mailto:jester@panix.com" target="_blank">jester@panix.com</a>&gt; wrote:</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<pre><div><div><br>Sysadmin-fu needed: I have a personal server in the cloud that has 1 GB<br>of RAM. It&#39;s running Debian, and the usual server basics--MySQL, nginx,<br>etc. No X, of course.<br><br>There are three Catalyst apps running, all of them fairly small, using<br>nginx and FCGI (I run the MyApp_<a href="http://fastcgi.pl" target="_blank">fastcgi.pl</a> script to a socket, that<br>nginx then responds to). But they&#39;re taking up all the memory on the<br>system, and I can&#39;t run another Cat app (and sometimes even system<br>commands hang for lack of memory). I tried reducing --nproc to 1 for two<br>of the three apps that I&#39;m the only one using (the other has --nproc 3).<br>The output of &quot;top&quot; with &quot;M&quot; (sorting by RES) looks like (I removed a<br>few columns for spacing):<br><br>  PID USER     VIRT  RES  SHR S  %MEM    TIME+  COMMAND <br><br>23766 www-data 440m 230m 2584 S  23.0   0:13.40 perl-fcgi         <br>16958 mysql    428m 188m    0 S  18.8 118:14.98
mysqld            <br>25992 www-data 375m 158m 2608 S  15.9   0:06.80 perl-fcgi         <br>26884 www-data 238m  80m 2616 S  8.0   0:01.61  perl-fcgi         <br> 2513 www-data 282m  76m    0 S  7.7   0:06.01  perl-fcgi         <br> 2512 www-data 182m  66m    0 S  6.6   0:00.00  perl-fcgi-pm [Library]<br> 1825 www-data 172m  61m    0 S  6.1   0:03.44  perl              <br> 2487 www-data 163m  46m   60 S  4.6   0:00.18  perl-fcgi-pm [CatSF]<br> 1692 root     119m 5128  140 S  0.5   0:56.32  rsyslogd          <br>19998 www-data 79452 3296 1136 S 0.3   6:10.61  nginx             <br> 2265 www-data 79768 3148  504 S 0.3  15:57.81  nginx <br>[...]<br><br>Is this an expected or appropriate amount of memory usage? I appreciate<br>that 1GB isn&#39;t all that much memory nowadays, but this is a very lightly<br>loaded machine, and I don&#39;t want to pay a lot more for a larger cloud<br>server to handle this if it&#39;s not necessary.<br><br>Thanks.<br><br><hr><br></div></div><span>List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk</a>/<br>Dev site: <a href="http://dev.catalyst.perl.org" target="_blank">http://dev.catalyst.perl.org</a>/<br></span></pre></blockquote></div><span><font color="#888888"><br>
-- <br>
Sent from my phone. Please excuse typos, terseness, and top-posting.</font></span></div><br>_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" rel="noreferrer" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" rel="noreferrer" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" rel="noreferrer" target="_blank">http://dev.catalyst.perl.org/</a><br>
<br></blockquote></div><br></div></div></div>