Darren
Darren

Reputation: 792

How to introduce High Availability to a simple JPA application?

I want to have two servers running, both with a small local database accessed via JPA. The 2nd server is a hot standby ready to take over.

How do I keep the databases in sync, and how do I handle caching etc at the JPA layer?

I am curious to know if anyone has tried this, and what technologies they used?

Upvotes: 2

Views: 911

Answers (1)

jbx
jbx

Reputation: 22148

For caching you can use Ehcache. It comes with Hibernate by default if you are using that JPA Persistence Provider. You will need to specify which entities are cacheable using annotations and you can also configure the caching policy for specific entities through XML.

For database replication I wouldn't go for a JPA/JDBC based solution apart from basic IP failover which could be supported by your driver depending on what the database is. Replication is something the database should be responsible for not the application. Most of the popular databases (Postgresql, Mysql, Ms-SQL, Oracle, etc.) nowadays support some kind of replication or clustering, so depends on what you're using.

Upvotes: 1

Related Questions