Infinispan Operating Modes

I recently started to learn Infinispan as our caching layer. After reading the operating modes in Infinispan as follows.

  • Built-in mode: this is when you launch Infinispan within the same JVM as your applications.
  • Client-server mode: this is when you start a remote instance of Infinispan and connect to it using various protocols.

Firstly, I’m confused right now which is best for my application from the two above modes.

I have a very simple use case, we have a client-side code that will call our REST service using the main VIP service, and then it will balance the load on the individual Service Server , where we deployed ours and then it will interact with Cassandra database to get the database on the user ID. Below the snapshot will be clear. enter image description here

Suppose, for example, if the client is looking for some data for userId = 123 , then he will call our REST service using the main VIP, and then he will balance the load on any of our four service servers, suppose he balances the load of Service1, and then service1 will call Cassandra database to get an entry for userId = 123 , and then return to the client.

Now we plan to cache data using Infinispan, because compression kills our performance, so our read performance can get some momentum. So I started to learn Infinispan and stumble upon two modes, as I mentioned below. I'm not sure what would be the best way to use Infinispan in our case.

Secondly, as in the Infinispan cache, I expect that if I switch from Embedded Mode, then it should look something like this.

enter image description here

If so, how will the Infinispan cache interact with each other? It is possible that at some point we will look for data for those users who will be in another Infinispan Service Instance cache. Right? So what will happen in this scenario? Will infinispan take care of these things? if so, what kind of configuration setting do I need to make sure this thing works fine.

Forgive my ignorance if I do not miss anything. Any clear information will make things clearer for my two above questions.

+4
source share
2 answers

As for your second image, yes, the architecture will look like this.

If so, how will the Infinispan cache interact with each other?

Please look here: https://docs.jboss.org/author/display/ISPN/Getting+Started+Guide#GettingStartedGuide-UsingInfinispanasanembeddeddatagridinJavaSE Infinispan will manage it using the JGroups protocol and send messages between nodes. A cluster will be formed, and the nodes will be grouped. After that, you can experience the expected behavior of replicating records to specific nodes.

And here we go to the next question:

It is possible that at some point we will look for data for those users who will be on another Infinispan Service Instance cache. Right? So what will happen in this scenario? Will infinispan take care of these things?

Infinispan was designed for this scenario, so you don't need to worry about it at all. If you have, for example, 4 nodes and setting the distribution mode using numberOfOwners = 2, your cached data will be displayed exactly on 2 nodes at every moment. When you issue a GET command for the owner of a NON node, the record will be received from the owner .

You can also set clustering mode for replication, where all nodes contain all records. Please read more about the modes here: https://docs.jboss.org/author/display/ISPN/Clustering+modes and choose what works best for your use case.

In addition, when you add a new node to the cluster, StateTransfer will be executed and synchronize / rebalance records in the cluster. NonBlockingStateTransfer is already implemented, so your cluster will still be able to serve responses at this join stage. See: https://community.jboss.org/wiki/Non-BlockingStateTransferV2 Similarly for deleting / crashing nodes in your cluster. There will be an automatic rebalancing process , therefore, for example, some records (numOwners = 2), which after a failure live on only one node, will be replicated accordingly to live on 2 nodes in accordance with the numberOfOwners property in distribution mode.

To summarize, your cluster will still be updated, and it does not matter which node you request for a specific record . If it does not contain it, a record will be received from the owner.

if so, what kind of configuration setting do I need to make sure this thing works fine.

The above start guide is full of examples plus you can find examples of configuration files in the Infinispan distribution: ispn / etc / config-samples / *

I would also suggest you take a look at this source: http://refcardz.dzone.com/refcardz/getting-started-infinispan , where you can find even simpler and very quick configuration examples.

This source also contains information related to the solution for your first question: "Should I use the built-in mode or the remote client server mode?" From my point of view, using a remote cluster is a more ready-to-use solution (see http://howtojboss.com/2012/11/07/data-grid-why/ ). Your caching level scales very easily, is highly accessible and fault tolerant, and does not depend on the level of your database or the level of the application, because it is simply located between them.

And you may also be interested in this feature: https://docs.jboss.org/author/display/ISPN/Cache+Loaders+and+Stores

+6
source

I think that the newest version of Infinispan supports working in a special compatibility mode for those users who are interested in accessing Infinispan in several ways.

follow below to configure the cache environment to support built-in or remote access.

Interaction between embedded and remote server endpoints

0
source

Source: https://habr.com/ru/post/1491533/


All Articles