Design Database Connection Failure

Hi,

I was asked this in an interview..

1) how would you a design a app. when database connection is lot.

2) will you have a database replica in another machine, so that if the connection is lost, take the data from the secondary database.

I am not sure about this. But I strongly feel we never used to have database replica. If, the database is down then our app is donw. We can't do anything with that. am i right?

thanks

SJ

[473 byte] By [_AM__a] at [2007-11-27 9:55:47]
# 1
No rule to that. It all depends on business requirements, really. If the business demands that a local cache is held, do it.
georgemca at 2007-7-13 0:25:49 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
1) Show a clear error message.2) If the data is available anyhow, then just show it (only if the DB contents are 100% identical of course).After all, it depends on the project requirements. It's not a developer's decision whether to use a replica or not.
BalusCa at 2007-7-13 0:25:49 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

> I was asked this in an interview..

The best answer to any question about 'what is the best design ...' is always 'it depends on the Requirements'.

It might seem cliche A superb solution in one situation may be a complete unsuitable in another.

> 1) how would you a design a app. when database

> connection is lot.

Many 'failures' will be short term, network & connection time-outs, even machine reboots can cause connection loss, but should not halt the Application. It should auto-recover if possible. Therefore a mechanism to detect the connection loss and either pull another connection from the pool or rebuild the connection is nearly always prudent. This can be done silently for the user, though I typically log it.

> 2) will you have a database replica in another

> machine, so that if the connection is lost, take the

> data from the secondary database.

If high availability is a requirement for the project, this should be addressed with a proper Database Cluster. There is no point re-inventing the wheel.

> I am not sure about this. But I strongly feel we

> never used to have database replica. If, the

> database is down then our app is donw. We can't do

> anything with that. am i right?

Replica databases do indeed break a basic principle of database theory, however requirements and compromise override the perfect solution in practice.

MartinS.a at 2007-7-13 0:25:50 > top of Java-index,Other Topics,Patterns & OO Design...