Giter Club home page Giter Club logo

Comments (12)

aseemk avatar aseemk commented on June 9, 2024 4

Hello folks. I (@fiftythree) have also been running Forky in production for years now with no issue. I just wanted to chime in with one simple possible explanation:

Forky launches multiple Node processes on the same dyno. That means a single dyno will use more memory than it would without Forky. Specifically, if your Node process uses ~100 MB on its own, Forky running 10 workers will use ~1 GB.

So instead of a Forky memory leak, it's probably simply the case that you're just running more workers than your dyno's memory capacity. Reducing the number of workers, or bumping up your dyno size, will both probably fix it. And you can monitor your memory usage via Heroku Metrics.

If it helps, Heroku provides some helper configs to let you dynamically figure out the optimal number of workers to spawn based on your dyno size.

https://devcenter.heroku.com/articles/node-concurrency

Hope this helps!

from node-forky.

aseemk avatar aseemk commented on June 9, 2024 1

Here's some more specific things we do, if that helps:

  • We heroku config:set WEB_MEMORY to the MB we expect one instance of our app's process to typically take (or grow to). E.g. we set it to 512.
  • Then at runtime, Heroku sets WEB_CONCURRENCY to the number of processes we can safely run per dyno. So on a dyno with 1 GB of RAM, it'll set this to 2.
  • So then you can pass process.env.WEB_CONCURRENCY to Forky directly, but we also Math.max it to a reasonable number.
  • The "reasonable number" we use is os.cpus().length * 2, i.e. at most 2 processes per core.

Hope this helps also!

from node-forky.

brianc avatar brianc commented on June 9, 2024

Yikes - yes please lemme know if the memory leaks go away when you're not using the cluster. I've used this for a long time in production without problems, but there could still be memory leaks I suppose! I'll stay tuned...

from node-forky.

felipap avatar felipap commented on June 9, 2024

Hi, Brian.
Thanks for answering. I've been running without the cluster since then and
had no memory issues so far.
Does that mean it's a forky issue?
On 5 Sep 2014 12:19, "Brian C" [email protected] wrote:

Yikes - yes please lemme know if the memory leaks go away when you're not
using the cluster. I've used this for a long time in production without
problems, but there could still be memory leaks I suppose! I'll stay
tuned...


Reply to this email directly or view it on GitHub
#8 (comment).

from node-forky.

joshmosh avatar joshmosh commented on June 9, 2024

This is not a forky issue. Unless you're using the latest io.js you're most likely using an unstable version of cluster.

https://nodejs.org/api/cluster.html#cluster_cluster

from node-forky.

HeathNaylor avatar HeathNaylor commented on June 9, 2024

I am having forky max memory and swap as well, it just creates more and more threads that take a memory chunk until the server crashes.

from node-forky.

marclar avatar marclar commented on June 9, 2024

Yes -- same thing happening to me. Any thoughts? Would it help to reduce the # of workers forky creates?

from node-forky.

HeathNaylor avatar HeathNaylor commented on June 9, 2024

@marclar I just pulled out the Forky layer and spanned the application across multiple nodes with the database decoupled. Sorry it isn't a true solution but it solves the problem in some form.

from node-forky.

marclar avatar marclar commented on June 9, 2024

As in, you implemented your own solution with the cluster module? Not sure
what you mean by spanning across multiple nodes...
On Jan 2, 2016 11:54 PM, "Heath Naylor" [email protected] wrote:

@marclar https://github.com/marclar I just pulled out the Forky layer
and spanned the application across multiple nodes with the database
decoupled. Sorry it isn't a true solution but it solves the problem in some
form.


Reply to this email directly or view it on GitHub
#8 (comment).

from node-forky.

HeathNaylor avatar HeathNaylor commented on June 9, 2024

I just have the same application running on several servers with a load balancer distributing load across them. If I were writing a nodejs application from scratch I might look into forky more seriously but what I have is an inherited project with limited budget.

from node-forky.

marclar avatar marclar commented on June 9, 2024

Got it -- thank you.

On Tue, Jan 5, 2016 at 12:31 PM, Heath Naylor [email protected]
wrote:

I just have the same application running on several servers with a load
balancer distributing load across them. If I were writing a nodejs
application from scratch I might look into forky more seriously but what I
have is an inherited project with limited budget.


Reply to this email directly or view it on GitHub
#8 (comment).

HealthyHand.com
https://app.yesware.com/tl/be22915ea6afba7f2bd75a78e52bc161cc161ce2/5c092898a7393fb6b4f1b291b1a637a0/d2e0086445916db271e45834aabcbec0?ytl=http%3A%2F%2Fwww.HealthyHand.com

Michael Kane
Co-Founder & CTO
646-450-5263 | 225 Park Ave S, 16th FL, NYC
https://app.yesware.com/tl/be22915ea6afba7f2bd75a78e52bc161cc161ce2/5c092898a7393fb6b4f1b291b1a637a0/de709e6478ef78dac20c9d1738056133?ytl=http%3A%2F%2Fwww.facebook.com%2Fhealthyhand

https://app.yesware.com/tl/be22915ea6afba7f2bd75a78e52bc161cc161ce2/5c092898a7393fb6b4f1b291b1a637a0/40fa4fc2ed60e6126c745b313fffb674?ytl=https%3A%2F%2Ftwitter.com%2Fhealthyhnd
http://www.linkedin.com/in/marclar
https://app.yesware.com/tl/be22915ea6afba7f2bd75a78e52bc161cc161ce2/5c092898a7393fb6b4f1b291b1a637a0/c6b02c7657388051bc2eef339f63ee68?ytl=http%3A%2F%2Fwww.healthyhand.com%2Fblog

from node-forky.

marclar avatar marclar commented on June 9, 2024

A gentleman and a scholar, @aseemk ;)

from node-forky.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.