JVM Clustering in standalone java apps - java

How can we achieve JVM clustering in standalone Java apps? Is this a possiblity:
We create a JMS queue and deploy it on a server. Now we make all the Java apps connect remotely using weblogic jndi parameters to that queue. When a message is delivered to a queue, only one of the java apps (jms clients) will receive the message because of the very nature of a queue(as opposed to topic). Thus, load balancing a.k.a clustering can be achieved.
Is this a viable way of approaching the solution?

That approach sounds viable, and it does give you simple load balancing.
Nobody can say whether it is the best approach because you've given almost no details of what you are trying to do.
(I would not have said that "load balancing" and "clustering" are the same thing though. You can do load balancing using cluster computing, but there are other ways to do this and there are other uses for cluster computing. Refer to the linked articles for details.)

Related

Cloud Foundry for isolated environments

We have a quite large monolithic app (java/spring) and we are considering splitting it up to microservices and using spring-cloud to utilize existing solution for some common problems (discovery, redundancy etc.). Currently we run one instance (with different modules) per client.
Some of our clients are small and one VPS handles it and others are larger and might use multiple servers.
The problem is that this "pack" of microservices should be isolated for each environment - they might be slightly different.
As I am reading through resources about Cloud Foundry - which looks really great - it seems that it would be best to run an cloud foundry instance per client and I am afraid that that is overkill and quite a lot of work to get one client running (which I would like to automate as much as possible).
Ideal Solution
BEGIN
We provide servers with heterogenous OS, possible containers (VM/docker/jail/...) with restrictions where they may rur and finally services with restrictions in which containers they may run.
When creating new environment I just provide list of services to run in it and the Solution creates containers, deploys services in them and sets up communication channels (message broker) between them.
It should also handle upgrades, monitoring, etc.
END
What approach would you recommend? Or please could you share your experience from building similar thing?
Thanks
You could provide each customer with their own space in a single CF instance where all the microservices are deployed.

Is there any light weight Java Message Queue for Backend process communication?

I am developing a application , in which backend will be in java. In backend there are many processes. For communication I require message queue. I have searched for message queue in java , I got JMS. But as i know that is for Web applications and that will increase overhead in our project. so is there any basic light weight java message queue?
JMS is a standard and not a concrete implementation. Investigating the offer on JMS implementations is your best route. ActiveMQ is a well-known implementation. It is industrial-strength, but it is not of necessity heavyweight. There may be other offerings as well.
Any additional component will add some overhead, the question is how much. On production we use HornetQ, and when properly configured it can be fast. Or even faster
There are also many alternatives, among those considered 'light':
ActiveMQ
RabbitMQ

Java & the Different Types/Methods of Clustering

I'm relatively new to Java EE and have already began to hear about the many different types of systems that can be clustered:
Virtual Machines (i.e. "that appliance is a cluster of VMs...")
Application servers, such as Tomcat, JBoss or GlassFish (i.e. "We're running clustered JBoss...")
Clustering APIs like Terracotta
Databases, like Oracle ("clustered database")
Cloud applications ("A cloud is basically a cluster...")
Wikipedia defines "clustering" as:
A computer cluster consists of a set of loosely connected computers that work together so that in many respects they can be viewed as a single system.
I'm wondering how clustering works for each of these "cluster types/methods" (mentioned above) and how they relate to one another.
For instance, if one could benefit from having a clustered application, he/she would probably put them on a clustered app server and then throw a cluster manager into the mix (again, like Terracotta).
But because the phrase "clustering" seems to be used in vague/ambiguous ways, I'm not seeing how each of these ties into the others ones, or if they even do. Thanks in advance to any brave StackOverflowers out there who can help me make sense of this interwoven terminology!
To me, clustering implies a number of qualities to a system but it boils down to fault tolerance -- server, networking, and data persistence. There are both loosely and tightly coupled systems and all flavors in between. Tightly coupled systems have the clustering performed at level close to the hardware. Many of the old clustering systems were more tightly coupled with the applications often not recognizing that they were clustered.
Loosely coupled systems are the norm these days with a large degree of the fault tolerance accomplished at a software level entirely. Systems in the cluster only share network connectivity to be able to accomplish fault tolerance. Usually there are some specialized load balancers which route requests to the various cluster servers using specialized hardware (sometimes just software) to accomplish this.
All of the examples you mentioned have some sort of "clustering". It is going to take a very long answer to describe the details about how each of the architectures accomplish this. For me, the differences are what comes "for free" when you use the architecture, and how much work you will have to do to get it to work optimally.
How you mix and match the solutions you've mentioned depends on what your architecture looks like and your requirements. You can have a Terracotta store for local high speed persistence and the cloud for the rest. You can use Glassfish as your application server and utilize Terracotta as your persistence layer.
Here are my thoughts about the technologies you listed:
Cloud applications ("A cloud is basically a cluster...")
Cloud applications are the easiest to work with obviously. Your only job from an architecture standpoint is to pick a good cluster provider. Certainly Amazon and Google will do it "right" in terms of fault tolerance and data integrity. There are many other players that probably do it "good enough" and are cheaper. You program to their APIs which come with their own set of limitations and expenses. One problem with cloud applications is that it most likely will be very hard to switch to a new one. Again, you might have some [large] portion of your application running on cloud servers and have some local systems for your higher latency requirements. The trend is to put most production functions in the cloud or at least start that way until you get too big or need some services they can't provide.
Clustering APIs like Terracotta
Databases, like Oracle ("clustered database")
JBoss
These 3 systems provide their own clustering capabilities. They may require you to do a lot of machine and service layer configurations to get the system running well in a production environment. I hear good things about Terracotta which is a distributed persistence layer. I've used Jgroups a lot which is under Jboss and it can be tricky to get running right but Jboss may also have some good default configurations/documentation. Oracle is most likely going to be hardest to cluster right. DBA's make a lot of money tweaking Oracle configurations.
Virtual Machines (i.e. "that appliance is a cluster of VMs...")
Application servers, such as Tomcat, GlassFish
These are the most amorphous to define in terms of clustering. Some VMs are considered "clustered" in that they share networking hardware and power backplanes but are really not clusters when compared to cloud computing certainly. As mentioned, there are some clustered hardware solutions that are very custom and will require a lot of specific domain knowledge to get running well.
I have very little experience with application servers such as Tomcat and Glassfish. We have our own clustering software on top of Jgroups and run Jetty entirely. Application servers are not, in themselves, "clustered" but packages such as Jboss and Terracotta run on top of them to provide clustering and they have internal projects which have clustering software written for them.
Hope some of this helps.
Here's a quick whack at it. How you cluster depends on what your goals are. Here are some thoughts that also tie in to GlassFish.
A cluster enables multiple instances to be managed as one since they share a common configuration. If you make a change to a configuration, such as defining a new resource, then all instances that belong to a cluster inherit that change. Deploying an application to a cluster deploys it to all instances of that cluster.
A cluster provides service availability. If one instance fails, deployed applications are still available on other instances.
A cluster can offer session availability. If an instance dies while a user has items in their shopping cart, then another instance can take ownership of handling that user's session such that the shopping cart contents are still there. The user never knows a backend server has failed.
With GlassFish, HTTP session state can be managed by GlassFish (built-in), delegated to a coherence grid, or the application can manage state itself (using terracotta, database, etc). The benefit of using the built-in capability is that it works out of the box and has gone through stress testing, QA, etc. The benefit of externalizing is that you can potentially get better scalability since you decouple session management and application logic. Externalizing lets the JVM focus on executing business logic, and uses less HEAP space since backup sessions exist elsewhere. Oracle has tested / QA'd externalizing to the Coherence Grid, and is a formal feature of the commercial Oracle GlassFish Server. If you roll your own via database, then you need to manage & QA itH yourself.

Java Applications Replicating State

I have the same server side application running on multiple machines.
I would like to provide a way to push changes to all the applications. I'm more interested in state/property changes to the objects themselves, and not so much replication of files, etc.
So I'm envisioning an admin console, where I would change some property, and have the change affect each applications state.
I am currently looking into JGroups, which is a toolkit for reliable multicast communication. In this case, each application would listen in on the same multicast group, and the admin console would send changes to the group.
Are there any other solutions/techniques available?
There exist alot of techniques, corba, rmi etc etc. However if you want a fully distributed system with no central server, I would personally recommend JGroups.
If you have a central server you can either
Let the server push the changes to all clients. The server must be aware of all clients, either directly or by having the clients register themselves.
Let clients poll the server.
Other simple solutions might including, polling a central database or a central file.
A quick Google search turns up: http://www.hazelcast.com/product.jsp. Which looks promising but I have no experience with it.
For the more complex scenarios I can't recommend terracotta enough.
Essentially terracotta distributes parts of your heap to the network, meaning that your applications share parts of the heap. Changes made by one app in the shared heap will be visible to the other applications sharing the heap. The main drawback is that terracotta needs a dedicated server since it's a hub and spoke design.
Apache ZooKeeper from the Hadoop project may also be interesting. I have no experience with it, but from the webpage I conlude it offers a hierarchical datamodel. Each application interested in changes can watch for changes in a specific node and act upon the changes.
http://zookeeper.apache.org/doc/trunk/index.html

clustering and loadbalancing through Java EE

I want to develop clustering and load balancing by using Java EE, I want to use two Tomcats in back-end,If any request arrives to my application it should send request to the tomcats based on the load factor.I want to add fail over and session replication to my application. Please suggest..
The API for load balncing and clustering that i have to use and where it should be down loaded from?
What are the books that i can make reference to make my application programming?
Is Apache web server is useful to my application or not?
what are the sites that i have to use for developing my application?
The API for load balancing and clustering that I have to use and where it should be down loaded from?
Clustering is actually part of the Java EE specification and containers should thus offer support for this (understand here: clustering shouldn't involve programming on your side, you just have to follow some rules when developing your Java EE applications).
In the case of Tomcat, have a look at Tomcat's Load Balancer HOW-TO and more precisely the Tomcat Connectors documentation to implement for software load balancing. Note that many companies prefer and use hardware load-balancing solutions (with products like F5 BIG-IP or Nortel Alteon). This will be a bit more expensive though.
For the load-balancing algorithm, simple round-robin is usually used (this would be my recommendation).
For the session fail-over part, you'll need to use a Persistent Manager, very likely the JDBC Based Store implementation. Just don't forget to make the objects you'll put in session Serializable.
What are the books that I can make reference to make my application programming?
Not sure what you mean by application programming but the simple fact that you are asking this question makes me think that you shouldn't implement your own solution but rather use an existing one (software or hardware).
Is Apache web server is useful to my application or not?
For software load-balancing, Apache (+ mod_jk) would be my choice for the web server. Refer to the Tomcat Connectors documentation previously mentioned.
What are the sites that I have to use for developing my application
Again, I'm not sure what you mean by "developing my application" but the links provided so far are good starting point IMO. If you want to go a bit further, maybe check Under the Hood of J2EE Clustering (this is still a good article, even if not really new). For a more specific answer, ask a more specific question :)
I believe Tomcat and Apache already have this capability:
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html
The API for load balancing and clustering that I have to use and where it should be down loaded from? In my experience, load balancing is best done using hardware like F5 or Cisco ACE routers, not in software.
What are the books that I can make reference to make my application programming? See answer to 1.
Is Apache web server is useful to my application or not? Yes, it's common to put a web server in a DMZ and let it proxy requests into the app server inside the second firewall.
What are the sites that I have to use for developing my application? Can't tell based on the info you provided. It's probably not possible to get an answer to such a broad question here.
There is a good product (open source) called Terracota wich allows you clustering and balance.
http://www.terracotta.org/
For download:
http://www.terracotta.org/dl/

Categories

Resources