• Post Reply Bookmark Topic Watch Topic
  • New Topic

Offline tasks in Java Web application

 
Bala Gangadhar
Ranch Hand
Posts: 113
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am on developing a web application (using struts). So most of my web application use cases are reading and presenting data to the users.

But i need to write the another set of programs to keep on reading the data from another data bases and update my database. I have list of timings at which i should read the data from each of other sites (i.e. i know when the other databases gets updated information). Its almost every 20 mins..

Now i want your help in design the app.
1. Should i include the data read programs as part of my Web application ( means runs in same server JVM) and make the threads as daemon threads..?
2. Should i write another application (offline application) runs out of server in another JVM ?


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. No
2. Yes
 
Bala Gangadhar
Ranch Hand
Posts: 113
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the quick reply.

But can you please explain why ? By running another JVM dont we loose system resource (memory, CPU) instead of running the offline programs in same server JVM, as the classes that we load are similar for both the programs...

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "lose"? To the contrary, you are using them. Any decent server will have no problem running multiple JVMs, and architecturally it's far better to separate background tasks from web apps.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only possible excuse for running this task in the server JVM would be if it had to be managed remotely using a HTML interface.

Try some measurements - I bet you will find it takes surprisingly small amount of memory to start a separate JVM.

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the same reason that modularity in programming is good -- keeping them independent has all the advantages of modularity.

Worrying about resources and performance is a sign of premature optimization, just as it is with coding.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!