Results 1 to 8 of 8

Thread: Number of threads per ICE server/client

  1. #1
    kitovyj is offline Registered User
    Name: Alexander Ivanenko
    Organization: Auriga inc
    Project: Video Conferencing - RPC in video transcoding
    Join Date
    Aug 2011
    Posts
    7

    Number of threads per ICE server/client

    Hello!

    Our solution is supposed to have many ( > 1000) small Ice servers as separate processes working on the same machine. So we are interested in lowering system resource consuption as much as possible.

    I noticed what simple server with source code listed below spawns 6 threads.
    As far as I understand they are:

    1. main thread
    2. 1 thread in client thread pool
    3. 1 thread in server thread pool
    4. host resolver thread
    5. selector thread
    6. ?

    My question is: is it possible to lower the number of threads spawned? Is it possible to terminate resolver thread after the resolving is done? Is it possible to use "main" thread as selector thread? It would be ideal to have only one thread waiting on "epoll_wait"

    Best regards,
    Alexander Ivanenko

    Simple server code:

    communicator = Ice::initialize(argc, argv);
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("client", "tcp");
    WorkerPtr w = new WorkerI();
    WorkerPrx prx = WorkerPrx::checkedCast(adapter->add(w, communicator->stringToIdentity(lexical_cast<string>(getpid()))) );
    adapter->activate();
    HostPrx host = HostPrx::checkedCast(communicator->stringToProxy("xcoder:tcp -p 10000"));
    host->registerWorker(prx);
    communicator->waitForShutdown();
    communicator->destroy();
    Last edited by kitovyj; 08-23-2011 at 09:55 AM.

  2. #2
    kitovyj is offline Registered User
    Name: Alexander Ivanenko
    Organization: Auriga inc
    Project: Video Conferencing - RPC in video transcoding
    Join Date
    Aug 2011
    Posts
    7
    It seems like 3.4.2 spawns 5 threads, not 6.

  3. #3
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    No, you can't terminate the internal threads, other than by shutting down the Communicator as a whole. Why do you use so many small servers as separate processes? This doesn't seem to be a very efficient approach. Ice servers are designed to handle many clients, so it should not be necessary to create so many servers.

  4. #4
    kitovyj is offline Registered User
    Name: Alexander Ivanenko
    Organization: Auriga inc
    Project: Video Conferencing - RPC in video transcoding
    Join Date
    Aug 2011
    Posts
    7
    Strictly speaking they are not servers, just clients registering callback interfaces on the host.
    We are developing video transcoder, each transcoding job is isolated in a separate process, being an Ice client. When such a client starts, it register itself on an Ice server as "worker" with a callback interface, something like :

    interface worker {

    void start_transcoding(...
    void stop_transcoding(...
    ...
    etc

    The problem is what we will run thousands of such workers on the same machine and want to minimize their system resources usage.

    Quote Originally Posted by marc View Post
    No, you can't terminate the internal threads, other than by shutting down the Communicator as a whole. Why do you use so many small servers as separate processes? This doesn't seem to be a very efficient approach. Ice servers are designed to handle many clients, so it should not be necessary to create so many servers.

  5. #5
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    I would recommend to write a single process (or a few processes) that can handle multiple transcoding processes, utilizing a thread pool that you can configure to optimize performance depending on the number of physical CPUs you have. Using thousands of processes might be convenient, but it is not efficient, with or without Ice.

  6. #6
    kitovyj is offline Registered User
    Name: Alexander Ivanenko
    Organization: Auriga inc
    Project: Video Conferencing - RPC in video transcoding
    Join Date
    Aug 2011
    Posts
    7
    Quote Originally Posted by marc View Post
    I would recommend to write a single process (or a few processes) that can handle multiple transcoding processes, utilizing a thread pool that you can configure to optimize performance depending on the number of physical CPUs you have. Using thousands of processes might be convenient, but it is not efficient, with or without Ice.
    It would be much easier to use a thread-per-transcoder model instead of process-per-transcoder. But it is a question of fault-tolerance. Video encoders/decoders are too complex to be bug-free, and we don't want to let the seg. fault in one transcoding job crash the whole server. That is why we want to have each xcoding job in a separate process.
    Last edited by kitovyj; 08-24-2011 at 10:19 AM.

  7. #7
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Well, I guess you could choose some middle ground here, by using a few processes that each handle multiple transcoding jobs. You could also use IceGrid to manage these processes, so that they are activated on demand. And of course if the transcoding processes crash so often, then I would look into why this is the case and debug them. No application is too complex to make crashes acceptable

    Anyway, I'm afraid I can't offer you any advice beyond what I wrote already. I do not believe you will be able to have an efficient system with so many processes, regardless of whether you use Ice or not.

  8. #8
    kitovyj is offline Registered User
    Name: Alexander Ivanenko
    Organization: Auriga inc
    Project: Video Conferencing - RPC in video transcoding
    Join Date
    Aug 2011
    Posts
    7
    Quote Originally Posted by marc View Post
    Well, I guess you could choose some middle ground here, by using a few processes that each handle multiple transcoding jobs. You could also use IceGrid to manage these processes, so that they are activated on demand. And of course if the transcoding processes crash so often, then I would look into why this is the case and debug them. No application is too complex to make crashes acceptable

    Anyway, I'm afraid I can't offer you any advice beyond what I wrote already. I do not believe you will be able to have an efficient system with so many processes, regardless of whether you use Ice or not.
    Thank you for your answers! I think we will manage it one way or another.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 8
    Last Post: 06-05-2011, 05:08 PM
  2. Replies: 8
    Last Post: 04-01-2009, 11:56 PM
  3. Replies: 2
    Last Post: 07-15-2008, 12:00 AM
  4. Replies: 4
    Last Post: 03-10-2008, 03:45 PM
  5. Create C# threads as background threads?
    By bpolivka in forum Help Center
    Replies: 19
    Last Post: 01-31-2007, 05:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •