8 Replies Latest reply: Apr 19, 2011 3:27 PM by Brian Oliver RSS

    Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?

    e.gherardini
      Hi,
      I am building an Event Driven Architecture with coherence 3.6.1, in whitch an event is implemented as a command (using Command pattern from coherence incubator).

      My question is simple:
      does Coherence automatically distribute load to the grid (in a grid-computing style) or do I need to implement some sort of load

      Thanks in advance.

      Edited by: GheParDo on Apr 19, 2011 10:40 PM

      Edited by: GheParDo on Apr 19, 2011 10:41 PM
        • 1. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
          Brian Oliver
          Hi,

          Have you looked at the Processing Pattern?

          http://coherence.oracle.com/display/INCUBATOR/Processing+Pattern

          I think it is something closer to what you're looking for. It's designed for "grid computing".

          Regards

          -- Brian
          -----
          Brian Oliver | Architect | Oracle Coherence 

          Edited by: Brian Oliver on Apr 16, 2011 2:16 PM
          • 2. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
            e.gherardini
            Hi Brian, thanks for answering me.

            I already had a look at it, but it seems to me that processing pattern misses the "Context" concept (work submitted inside a context is performed in FIFO order), while that Functor has it.

            Am I wrong ?
            • 3. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
              Brian Oliver
              Hi,

              To answer your original question. Yes. As the objects (contexts and commands) are placed into distributed caches they are thus load-balanced across the cluster.

              Hope this helps.

              -- Brian

              -----
              Brian Oliver | Architect | Oracle Coherence 

              • 4. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
                e.gherardini
                Hi again Brian, yes it helps, but it still leaves me with a doubt:

                suppose the grid has 10 nodes (all with local storage enabled), and suppose I submit concurrently 1 billion commands (lets say, in less than 100 distinct context).

                Will these 1 billion commands be load balanced between the nodes (~100 milion per node) ? If yes, is there a way to control load balancing?

                To my understanding, if 100 million commands are all related to the same context, they will not be load balanced but executed in the same node where the context is saved (primary node). Am I wrong?

                Thanks again for your patience and help.

                Edited by: GheParDo on Apr 19, 2011 8:25 AM
                • 5. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
                  Brian Oliver
                  Hi GheParDo,

                  When using the Command Pattern you have two choices on how it manages Commands that are submitted to individual Contexts. You can choose either a "DISTRIBUTED" or "COLOCATED" Management Strategy.

                  For example:
                      ContextIdentifier ci = DefaultContextManager.INSTANCE.registerContext("my-context", new GenericContext<String>("hello world"), new DefaultContextConfiguration(ManagementStrategy.DISTRIBUTED));
                  When using the "DISTRIBUTED" management strategy, commands for the context are balanced across the cluster. This allows the entire cluster to managed the commands, but they are executed as required by the specified context. It means you have large command capacity, but you pay the cost of some latency to retrieve them when required.

                  When using the "COLOCATED" management strategy, commands are kept "local" to the context. This allows for much higher-throughput (and lower latency), but reduces the number of commands you can "queue" for a context.

                  By default the Command Pattern uses the "DISTRIBUTED" strategy, so you should not need to do anything to achieve what you're looking for.

                  Hope this helps.

                  -- Brian
                  -----
                  Brian Oliver | Architect | Oracle Coherence 
                  • 6. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
                    e.gherardini
                    Hi Brian,
                    thanks a lot!

                    Yes it is really really helpful to me.

                    Just a couple of deeper questions:

                    Since the Functor pattern is based on the Command pattern, I suppose it inherits this "distributed" behaviour.

                    Also, what about the Processing Pattern ?
                    Does this pattern has this behaviour ?
                    How this pattern compares to the Command/Functor ?


                    Thanks a lot for your patience and your time.

                    Edited by: GheParDo on Apr 19, 2011 10:24 PM
                    • 7. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
                      Brian Oliver
                      Hi GheParDo,

                      Yes. As the Functor Pattern is built on the Command Pattern, the same configuration is possible.

                      For the Processing Pattern everything is always distributed. That is, there is no "COLOCATED" option, unless you use KeyAssociation for your submissions.

                      Hope this helps

                      -- Brian
                      -----
                      Brian Oliver | Architect | Oracle Coherence 

                      • 8. Re: Coherence Grid Computig with Command/Fuctor Pattern: how to load balance ?
                        e.gherardini
                        Hi Brian,
                        again thanks!

                        Well, definitely it really helps me a lot.

                        I watched all the coherence incubator screencasts, and I've read about all these 3 patterns (command/functor/processing).

                        While its clear the difference between command/functor (a nice table is also in the FAQ), the difference of these with the processing pattern is a little obscure.

                        It seems to me the processing pattern is different from the functor / command only because, through the "dispatcher" it gives the developer the
                        possibility to controll how "work" is dispatched between workers, enabling the construction of a different kind of architecture in terms of nodes responsibility:

                        with command/functor each grid node has the same responsibility, i.e. each node can perform the work submitted.
                        with processing you can have specialized nodes, so that work can be processed only on configured nodes, enabling to build a grid in which, for example, you have more "workers" for the most frequently submitted works.

                        Am I wrong ?

                        I am sorry if bothering you with all these questions,
                        but I am doing an evaluation for one of our customers, so its important for me to have a deep understanding. (anyway this discussion is really driving our product choice to coherence among all others available (grid gain, hazelcast, infinispan...)).

                        Thanks again for your help.