Archived

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

Order For Threads To Execute On Server?

Hi,

My question is if there is any particular order for threads to execute on the server.

Say I set Ice.ThreadPool.Server.SizeMax=1. I then have ten threads come in in order (threads 1-10). Thread 1 will execute immediately while threads 2-10 will have to wait. Is there any way to determine which order threads 2-10 will execute in? Is it guaranteed to be FIFO?

I looked for this in the documentation but couldn't find anything.

Thanks.

Comments

  • mes
    mes California
    Hi David,

    When you say "I then have 10 threads come in in order", do you really mean "10 client requests"?

    If the maximum size of your thread pool is one thread, all client requests will be serialized. Keep in mind however that a server can potentially have connections from any number of clients. So what this thread pool configuration really does is serialize requests from all clients, which may or may not be what you intended.

    Let's take a simple case of one client connection to the server, where the server's thread pool has a maximum size of one. In this situation, the client's requests would be executed in FIFO order. (Let's ignore for now the potential ordering issues in the client.)

    Assuming you'd like your server to support more than one simultaneous client connection, but still serialize the requests from each connection, then you can configure the thread pool with multiple threads but also set the Ice.ThreadPool.Server.Serialize=1 property.

    Let me know if I'm understanding your situation correctly.

    Take care,
    Mark
  • Ah. Yes. I meant client requests.

    Are client requests from different clients serialized in any order? If a client request from client A arrives before a request from client B, then will A be guaranteed to execute before B?
  • I'm pretty sure we're not setting Ice.ThreadPool.Server.Serialize today. Does that mean that serialization is not happening?
  • mes
    mes California
    Hi,

    No, there is no such guarantee. Ice uses system calls (such as epoll on Linux or async I/O on Windows) to detect activity on a set of connections. With one thread in the pool, that thread is essentially in a loop that asks the system for the next connection with input pending, reads the incoming message from that connection, and dispatches the request to the servant. The order in which the system reports activity on incoming connections can't be predicted.

    Mark
  • mes
    mes California
    I'm pretty sure we're not setting Ice.ThreadPool.Server.Serialize today. Does that mean that serialization is not happening?

    With SizeMax=1, all requests are serialized regardless of the setting of Serialize.

    Mark