Comments (12)
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.
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 to512
. - 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 to2
. - So then you can pass
process.env.WEB_CONCURRENCY
to Forky directly, but we alsoMath.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.
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.
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.
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.
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.
Yes -- same thing happening to me. Any thoughts? Would it help to reduce the # of workers forky creates?
from node-forky.
@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.
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.
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.
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).
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.
A gentleman and a scholar, @aseemk ;)
from node-forky.
Related Issues (9)
- Add 0.8.x support HOT 9
- Does not respect `numWorkers` arg when using an object as first arg HOT 3
- How to detect error on startup? HOT 1
- Controlled shutdown HOT 1
- travis-ci support
- Is the project still alive ? It is still a good solution to control several node childs ? HOT 3
- Be able to set our own number of workers HOT 2
- Error: channel closed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-forky.