Archived

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

Asynchronous invocation

Hi there!

First I would like to mention that I tried to use AMI for the first time this weekend and would like to admit that I'm really impressed by the simpleness of your solution. Took me about 10 minutes to convert a synchronously called function into an asynchronous one.

What's remaining for me is the question what I should use: AMI or AMD. I read the manual and understood:
- AMI has the disadvantage of being able to be executed only a limited number of times (-> threadpool boundings)
- AMD has the disadvantage of possibly being delayed for later execution

My setup is that I'm distributing commands from a single server to a bunch of clients in order to make them execute certain things (to explain it simple).

To adress the disadvantages:
- I don't know about the number of clients
- Execution should start within a timeframe of ~ 2 seconds

Can you give me an advise on what method to use for this case or give me statements on how big the actual disadvantages are or if I forgot some?

regs,

Stephan

Comments

  • marc
    marc Florida
    AMI and AMD really don't have anything to do with each other. AMI is for asynchronous client calls, AMD is for asynchronous server dispatches. AMI is not an alternative to AMD and vice versa. They are two very different concepts, each serving a very different purpose.

    I'm not sure how you came to the conclusion about the disadvantages of AMI and AMD. Neither one of the two you listed is correct. Where does our manual list these as disadvantages?

    The case you provide, unknown number of clients, and executions time must start under two seconds, is very generic (i.e., applies to the vast majority of all applications), and is not sufficient to make a case for or against the use of AMI or AMD.

    The question is, why do you want to use AMI or AMD in the first place, i.e., what problems are you trying to solve that you cannot solve with synchronous calls on the client or server? With more information about the motivation, it will be easier for us to give advice.
  • Originally posted by marc
    Where does our manual list these as disadvantages?

    oops. Hope I didn't mis-interprete what I read but I have to re-check the chapter to find it...

    The question is, why do you want to use AMI or AMD in the first place, i.e., what problems are you trying to solve that you cannot solve with synchronous calls on the client or server?

    That's a good question, sure. The basic task is to get an arbitrary number of clients working on a certain problem without the necessity to react to their answer. That's why imho it would be clever to use asynchronous invocation.

    With more information about the motivation, it will be easier for us to give advice.

    The goal is to have - let's say - 1000 clients which should start processing within an amount of - let's say - 2 seconds without the mentioned necessity to wait for a result of the execution.

    Is this a case for synchronous calls or for asynchronous calls or, if the prior, what is a case for asynchronous calls at all?

    regs,

    Stephan
  • marc
    marc Florida
    I'm afraid I'm still confused. What exactly is the interaction of the client with the server?

    AMI allows a client to invoke a request on a server, but not to wait for the answer. Instead, you get a callback when the answer arrives from the server. If you do not need a response from the server at all, then you should use a oneway requests.

    AMD allows a server to either return an answer before processing on the server has finished, or it allows you to return an answer later, i.e., you first return the dispatch thread back to the server thread pool, and then send an answer later, for example, as the result of a callback from some worker thread, a database system, an AMI call, etc.
  • Hi again!
    I'm afraid I'm still confused. What exactly is the interaction of the client with the server?

    The client has basically no interaction with the server in this use case, but vice versa (server fires clients).

    The interface could look like this

    interface client
    {
    void runMe();
    };

    AMI allows a client to invoke a request on a server, but not to wait for the answer. [...]

    AMD allows a server to either return an answer before processing on the server has finished, [...].

    so, to summarize it, AMI is asynchronous execution and AMD is asynchronous replying. So my assumption in the first mail was correct but probably described somewhat fuzzy.

    My question in turn is why there are two models that are so similar (not only because the first two letters are the same :-) ). Sorry to ask such a religious question but it would be interesting to know more about your design decisions!

    I suppose in my use case, AMI is the way to go!

    regs,

    Stephan
  • marc
    marc Florida
    Originally posted by stephan

    The client has basically no interaction with the server in this use case, but vice versa (server fires clients).

    The interface could look like this

    interface client
    {
    void runMe();
    };

    OK, that's what confused me. In this case, your client is really the server, at least from the Ice point of view. Clients invoke requests, servers execute them.
    Originally posted by stephan

    so, to summarize it, AMI is asynchronous execution and AMD is asynchronous replying. So my assumption in the first mail was correct but probably described somewhat fuzzy.

    AMI is asynchronous invocation by an Ice client, meaning that the caller thread doesn't have to wait for the response from the server. Instead, the client receives a callback when the response arrives.

    AMD is asynchronous dispatch by an Ice server, meaning that you decide when to send the response. The response is not tied to the return of the operation that dispatches a request.
    Originally posted by stephan

    My question in turn is why there are two models that are so similar (not only because the first two letters are the same :-) ). Sorry to ask such a religious question but it would be interesting to know more about your design decisions!

    The two models are not similar at all. They serve completely different purposes. One is asynchronous invocations for Ice clients (AMI), and the other is asynchronous dispatch for Ice servers (AMD).

    For AMI, the client-side Ice core calls back your code when the response from an Ice server arrives. For AMD, you call the server-side Ice core when you want to send a response to an Ice client.