Git Product home page Git Product logo

Comments (6)

sandfox avatar sandfox commented on July 24, 2024

Hi @priyabagus

I'm not sure I understand exactly. Do you want to be able to dynamically change the min/max pool size after the pool has been created? (or at least would that satisfy your use case?)

from node-pool.

priyabagus avatar priyabagus commented on July 24, 2024

Hi @sandfox. We could separate that into 2 parts.
The first one is the main objective. That is to invoke createResource function whenever we want it to, manually..Something like create() or createResource() (these two are just the matter of function name in the act of invoking the resource creation).
I don't know if it's already possible or not in the current version, since the documentation doesn't mention anything about invoking the creation of a resource.
I mean, it's not the function definition about what to do when this module creates function, but more like 'how we invoke the createResource function?', Should we wait until there is no more resource in the pool and some process want to acquire a resource, then the createResource function invoked automatically? Can we just invoke create() / createResource() anytime, whenever and wherever we want it to, manually?
For example, we can call create() or createResource() function to invoke the creation of a resource when a custom event via event emitter occurs.

And the second one is about the min pool size. Forgive me if I'm wrong, but from what I thought about min pool size in this module. The definition of minimum is the minimum pool size both when they're available and not (still in used). For example if the min pool size is set to 5, then when we run the script, there will be 5 newly resources generated, they're all available since there is no process acquiring the resources yet.
And then when there are some process start acquiring them, let say there are 2 processes acquiring the resources. Then the current number of available resources in the pool becoming 3, the used resource is 2, the total is 5. And the module is not invoking to create new resources because the total resources in the pool is still 5, regardless they're available or in used.
Am I right about that? if it so, then is it possible for some way to make the definition of 'minimum' in the min pool size is always the minimum available resource?
I'm thinking about doing something like :

pool.acquire(function(err, client) {
    if (!err) {
        createResource();
        //do something
    }
});

So it will create new process when a resource in the pool is used. But again, I don't know if invoking createResource() manually is supported here.

Thank you.

P.S : Sorry if it's too verbose and if I got some mistakes here in some way.

from node-pool.

sandfox avatar sandfox commented on July 24, 2024

Thanks for taking the time to write that, verbosity is always welcome! I'll have a proper read throug + think tonight and come back with something.

from node-pool.

t3hmrman avatar t3hmrman commented on July 24, 2024

Reading through the info above, I think this issue is about two things:

  1. Being able to allocate more resources dynamically (in effect adding some delta to the minimum)

  2. The in-use resources being represented in the minimum count -- so if the minimum is 5, and 2 are in use (acquired), the pool does not create 2 new ones to replace the 2 being used so there are 5 completely unused resources at the same time -- in reality only 3 resources are actually able to be acquired.

It's been ~5 years but @priyabagus it seems like you were trying to solve issue #2 by doing #1 -- is that accurate?

from node-pool.

priyabagus avatar priyabagus commented on July 24, 2024

Yes, I was @t3hmrman .

from node-pool.

t3hmrman avatar t3hmrman commented on July 24, 2024

from node-pool.

Related Issues (20)

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.