Caching an object across app servers

C

Chris

What's the simplest way to cache an object and make it available across
multiple app servers?

Here's the problem. We have a central database which contains customer
information. When a customer logs in, we'll hit the database once to get the
info. After that, though, we'd like the info cached in memory.

We have multiple app servers, and when a request comes in from a customer,
it can hit any server. If it hits a server which is different from the one
it previously hit, we'd like the system to query the other app servers for
the info before it hits the central database. The amount of customer info
could be as much as 1 mb.

My understanding is that this is the problem that EJBs are designed to
solve, but EJBs are really complex to implement. I'd like something really
simple.
 
C

Chris Smith

What's the simplest way to cache an object and make it available across
multiple app servers?

Here's the problem. We have a central database which contains customer
information. When a customer logs in, we'll hit the database once to get the
info. After that, though, we'd like the info cached in memory.

We have multiple app servers, and when a request comes in from a customer,
it can hit any server. If it hits a server which is different from the one
it previously hit, we'd like the system to query the other app servers for
the info before it hits the central database. The amount of customer info
could be as much as 1 mb.

If the data in the customer object is immutable, then just cache it once
per container. The extra overhead is nothing compared to the cost of a
remote procedure call to retrieve the information from a common source.

If the information you want to cache is mutable, then you're really
stirring up a hornets nest here. What you're asking for is a
fundamentally difficult problem. Unless you already know all of the
issues (in which case you wouldn't be asking here), you should not try
to write this on your own. You will mess things up badly. Perhaps look
into JBoss TreeCache, which can provide a cache architecture across
multiple transactions. You'll also need to familiarize yourself with
JTA.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
I

iksrazal

Chris said:
What's the simplest way to cache an object and make it available across
multiple app servers?

Here's the problem. We have a central database which contains customer
information. When a customer logs in, we'll hit the database once to get the
info. After that, though, we'd like the info cached in memory.

We have multiple app servers, and when a request comes in from a customer,
it can hit any server. If it hits a server which is different from the one
it previously hit, we'd like the system to query the other app servers for
the info before it hits the central database. The amount of customer info
could be as much as 1 mb.

My understanding is that this is the problem that EJBs are designed to
solve, but EJBs are really complex to implement. I'd like something really
simple.

It may be a bit off the wall, but you could cache the object in LDAP -
typically pretty fast for read operations - using java.schema . Its a
simple solution - as opposed to caching an object across app servers.
Setting up OpenLDAP and 10 lines of java is pretty simple and may be
'good enough' .

Also, worth looking into would be the ehcache project used by both
Hibernate and Spring/acegi. Doing a quick look there is also JCACHE
(JSR 107) and a tubine/JCS implementation.

HTH,
iksrazal
http://www.braziloutsource.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top