Infinispan运营模式 [英] Infinispan Operational modes

查看:185
本文介绍了Infinispan运营模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始将Infinispan作为我们的缓存层。在阅读Infinispan中的操作模式后,如下所述。


  1. 嵌入模式:这是在与应用程序相同的JVM中启动Infinispan的时候。

  2. 客户端 - 服务器模式:这是当您启动远程Infinispan实例并使用各种不同协议连接到它时。

首先,我现在很困惑,最适合我上述两种模式的申请。



我有一个非常简单的用例,我们有一个客户端代码,它将使用服务的主要VIP调用我们的REST服务,然后它将获得负载平衡到单个服务器我们已经部署了我们的服务,然后它将与Cassandra数据库交互以检索用户ID的数据基础。下图将使一切清晰。



假设例如,如果客户端正在寻找 userId = 123 的某些数据,那么它将使用主VIP调用我们的REST服务,然后它将负载平衡到我们的四个中的任何一个服务服务器,假设它对Service1进行负载平衡,然后service1将调用Cassandra数据库获取 userId = 123 的记录,然后返回给客户端。



现在我们计划使用Infinispan缓存数据,因为压缩会破坏我们的性能,因此我们的读取性能可以得到一些提升。所以我开始研究Infinispan并发现了两种模式,如下所述。我不确定在我们的案例中使用Infinispan的最佳方式是什么。



其次,从Infinispan缓存来看,我想要的是假设我使用嵌入式模式,那么它看起来应该是这样的。





如果是,那么Infinispan缓存将如何相互影响?有可能在某个时候,我们将寻找那些将在另一个Service Instance Infinispan缓存上的userId的数据?对?那么在那种情况下会发生什么? infinispan会不会照顾这些事情?如果是的话,那么我需要进行哪些配置设置以确保此功能正常。



如果我遗漏了任何内容,请原谅我的无知。任何明确的信息都会让我对上述两个问题更清楚。

解决方案

关于你的第二张图片,是的,架构将看起来像这样。


如果是,那么Infinispan缓存将如何相互影响?


请看一下: https://docs.jboss.org/author/display/ISPN/Getting+Started+Guide#GettingStartedGuide-UsingInfinispanasanembeddeddatagridinJavaSE
Infinispan将使用JGroups协议管理它并在节点之间发送消息。将形成集群并将节点集群化。之后,您可以体验特定节点上条目复制的预期行为。



这里我们转到您的下一个问题:


在某个时候,我们可能会在另一个Service Instance Infinispan缓存中寻找那些userId的数据?对?那么在那种情况下会发生什么? infinispan会不会照顾这些事情?


Infinispan是针对这种情况开发的,所以你根本不需要担心。如果您有4个节点并使用numberOfOwners = 2设置分发模式,则您的缓存数据将在每个时刻正好位于2个节点上。当您在 NON 所有者节点上发出GET命令时,条目将从所有者获取。



您还可以将群集模式设置为复制,其中所有节点都包含所有条目。请在此处阅读有关模式的更多信息: https://docs.jboss.org/author / display / ISPN / Clustering + modes 并选择最适合您用例的内容。



此外,当您向群集添加新节点时,将发生StateTransfer并在群集中同步/重新平衡条目。 NonBlockingStateTransfer已经实现,因此您的群集仍然能够在加入阶段提供响应。请参阅: https://community.jboss.org/wiki/Non-BlockingStateTransferV2
类似于删除/崩溃群集中的节点。将有自动重新平衡过程,例如,根据分发模式中的numberOfOwners属性,一些条目(numOwners = 2)仅在一个节点上实时崩溃后将分别复制到2个节点上。

总结一下,您的群集仍然是最新的,这与您要求特定条目的节点无关。如果它不包含它,将从所有者获取条目。


如果是,那么我需要进行哪些配置设置确定这个东西工作正常。


前面提到的入门指南充满了例子,你可以找到一些Infinispan发行版中的配置文件示例:ispn / etc / config-samples / *



我建议你也看看这个来源: http://refcardz.dzone.com/refcardz/getting-started-infinispan ,你甚至可以找到更基本和非常快速的配置示例。



此来源还为您的第一个问题提供决策相关信息:我应该使用嵌入模式还是远程客户端 - 服务器模式?从我的角度来看,使用远程集群是更多企业就绪解决方案(参见: http://howtojboss.com/2012/11/07/data-grid-why/ )。您的缓存层非常容易扩展,高可用性和容错性,并且独立于数据库层和应用程序层,因为它只是位于它们之间。



您可能也对此功能感兴趣: https://docs.jboss.org/author/display/ISPN/Cache+Loaders+and+Stores


I have recently started taking a look into Infinispan as our caching layer. After reading through the operation modes in Infinispan as mentioned below.

  1. Embedded mode: This is when you start Infinispan within the same JVM as your applications.
  2. Client-server mode: This is when you start a remote Infinispan instance and connect to it using a variety of different protocols.

Firstly, I am confuse now which will be best suited to my application from the above two modes.

I have a very simple use case, we have a client side code that will make a call to our REST Service using the main VIP of the service and then it will get load balanced to individual Service Server where we have deployed our service and then it will interact with the Cassandra database to retrieve the data basis on the user id. Below picture will make everything clear.

Suppose for example, if client is looking for some data for userId = 123 then it will call our REST Service using the main VIP and then it will get load balanced to any of our four service server, suppose it gets load balanced to Service1, and then service1 will call Cassandra database to get the record for userId = 123 and then return back to Client.

Now we are planning to cache the data using Infinispan as compaction is killing our performance so that our read performance can get some boost. So I started taking a look into Infinispan and stumble upon two modes as I mentioned below. I am not sure what will be the best way to use Infinispan in our case.

Secondly, As from the Infinispan cache what I will be expecting is suppose if I am going with Embedded Mode, then it should look like something like this.

If yes, then how Infinispan cache will interact with each other? It might be possible that at some time, we will be looking for data for those userId's that will be on another Service Instance Infinispan cache? Right? So what will happen in that scenario? Will infinispan take care of those things as well? if yes, then what configuration setup I need to have to make sure this thing is working fine.

Pardon my ignorance if I am missing anything. Any clear information will make things more clear to me to my above two questions.

解决方案

With regards to your second image, yes, architecture will exactly look like this.

If yes, then how Infinispan cache will interact with each other?

Please, take a look here: https://docs.jboss.org/author/display/ISPN/Getting+Started+Guide#GettingStartedGuide-UsingInfinispanasanembeddeddatagridinJavaSE Infinispan will manage it using JGroups protocol and sending messages between nodes. The cluster will be formed and nodes will be clustered. After that you can experience expected behaviour of entries replication across particular nodes.

And here we go to your next question:

It might be possible that at some time, we will be looking for data for those userId's that will be on another Service Instance Infinispan cache? Right? So what will happen in that scenario? Will infinispan take care of those things as well?

Infinispan was developed for this scenario so you don't need to worry about it at all. If you have for example 4 nodes and setting distribution mode with numberOfOwners=2, your cached data will live on exactly 2 nodes in every moment. When you issue GET command on NON owner node, entry will be fetched from the owner.

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

Additionally, when you add new node to the cluster there will StateTransfer take place and synchronize/rebalance entries across cluster. NonBlockingStateTransfer is implemented already so your cluster will be still capable of serving responses during that joining phase. See: https://community.jboss.org/wiki/Non-BlockingStateTransferV2 Similarly for removing/crashing nodes in your cluster. There will be automatic rebalancing process so for example some entries (numOwners=2) which after crash live only at one node will be replicated respectively to live on 2 nodes according to numberOfOwners property in distribution mode.

To sum it up, your cluster will be still up to date and this does not matter which node you are asking for particular entry. If it does not contain it, entry will be fetched from the owner.

if yes, then what configuration setup I need to have to make sure this thing is working fine.

Aforementioned getting started guide is full of examples plus you can find some configuration file examples in the Infinispan distribution: ispn/etc/config-samples/*

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

This source also provides decision related information for your first question: "Should I use embedded mode or remote client-server mode?" From my point of view, using remote cluster is more enterprise-ready solution (see: http://howtojboss.com/2012/11/07/data-grid-why/). Your caching layer is very easily scalable, high-available and fault tolerant then and is independent of your database layer and application layer because it simply sits between them.

And you could be interested about this feature as well: https://docs.jboss.org/author/display/ISPN/Cache+Loaders+and+Stores

这篇关于Infinispan运营模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆