• Post Reply Bookmark Topic Watch Topic
  • New Topic

Design a J2EE app for a clustered environment  RSS feed

 
shivang sarawagi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have developed a J2EE app in my local system on a single tomcat, rabbitMQ messaging server & a MYSQL server. Now if I want to scale my app I have to certainly deploy my WAR in a clustered cloud environment.

I went through this resource http://archive.oreilly.com/pub/a/onjava/2004/07/14/clustering.html, http://stackoverflow.com/questions/21537600/java-concurrent-locks-failing-in-spring-web-app-deployed-in-clustered-environmen, http://stackoverflow.com/questions/92452/distributed-concurrency-control

Because of multiple JVMs involved in a cluster some of the things would definitely fail like concurrent locks, storing global state in a static variable, serialized objects, Singleton etc.

I have two questions

Right from the beginning when writing the first line of code for the app do I keep in mind that the code is to be deployed in a clustered environent & design accordingly using Hazelcast, ZooKeeper etc. to maintain a global state?. Or write regular code using synchronized blocks, statics, singletons etc. Deploy the app on the cluster, test & then make changes accordingly?.
Is there any resource/book which would help on how to write J2EE code to be deployed on a distributed environment?.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Writing distributed applications that should run on a cluster is not easy; there are a lot of things you need to think about. To answer your question: It will be easier when you keep the requirements for clustering in mind from the beginning. There are some things which don't work well or don't work at all when you have a distributed, clustered environment - and if you used those things in your single server application, you might need to make major architectural changes to your application to make it suitable for running on a cluster.

By the way, "J2EE" hasn't been called "J2EE" anymore for a long time. It's "Java EE", not "J2EE". The first article that you link to is from 2004, which is an eternity ago in the software development world. I haven't read it so it might still be relevant, but things have also massively changed in the past 12 years, so keep that in mind when you read such old articles.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!