Archived

This forum has been archived. Please start a new discussion on GitHub.

Simple using threads

Hi again,
Since i sucesfulled integrated Client with postgreSQL function i can make query and postgreSQL is connecting to server, but i would like to make that serwer will create another thread for each new query, because if i make select someFunction(generate_series(1, 10000))

it will cost a lot of time. How can i do that on the serwer? In the simple way of course.

Thanks for any help!

Comments

  • xdm
    xdm La Coruña, Spain
    You can configure the server thread pool to have more threads available for dispatch requests, the default is 1, add this properties to your server configuration:
    [PHP]
    Ice.ThreadPool.Server.Size=1
    Ice.ThreadPool.Server.SizeMax=10
    [/PHP]

    See:

    Thread Pools - Ice 3.4 - ZeroC
    Thread Pool Design Considerations - Ice 3.4 - ZeroC

    If you plan to have many long running operations you can also consider using AMD (Asynchronous Method Dispatch) on the server.

    See:

    Asynchronous Method Dispatch (AMD) in C++ - Ice 3.4 - ZeroC

    There is an AMD demo in demo/Ice/async directory.
  • Thanks Jose,
    I set properties like you've wrote but results wasn't great, i mean one that kind of query was treated like one thread, and that is quite good, but i'm wonderng can it could working faster. I'm trying to implement it with AMD based on demo, but i get error about creating an abstract class. I attach my testing project. If someone could look on that and check what i did wrong i would be grateful.

    FILE
  • xdm
    xdm La Coruña, Spain
    Hi Stanislaw,

    About your AMD problem , the definition of you operation doesn't match the generated code, it should be:
    [PHP]
    virtual void CalculateSqrt_async(const SqrtModule::AMD_ISqrt_CalculateSqrtPtr& cb, Ice::Double, const Ice::Current&);
    [/PHP]

    The AMD version of the operation, has as first argument a generated CB, and then one argument for each in-argument defined in Slice , plus Ice::Current argument.

    About thread pool configuration, you can also try to set Ice.ThreadPool.Server.Size to a greater value, this will avoid the overhead of create/destroy threads.

    If you set Ice.ThreadPool.Server.Size=10, there will be always 10 threads in the server thread pool and you will be able to dispatch 10 concurrent request each one in a different thread.

    With the previous configuration i posted, there is always 1 thread, but thread pool is allowed to grow until 10 threads.

    If you go the AMD route, the async demo is just an example, the WorkQueue adds a delay to simulate long running operations, and also serialize the operations, you probably don't want to do that but instead have some kind of thread pool dedicated to execute these long running operations.
  • Thanks Jose, you're fast!
    Of course you're right about my AMD problem.

    This Ice.ThreadPool.Server.SizeMax=10 is great but new threads are created when i make, i.e. two query in the same time - then server creating two treads but one query calling i.e. 10000 postgreSQL function and i'm wondering if i can make faster one query, but it is not so important... at least now.

    Thanks for your help and patient.

    Best regards