[erlang-questions] handling crash on db connect

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Thu Jun 6 14:14:49 CEST 2013

On Jun 6, 2013, at 12:54 PM, Jachym Holecek <freza@REDACTED> wrote:

> Yes. Probably good to have 'redis:connect(...)' retry connect periodically and
> send you a message when it's up -- not only connect succeeded but ideally some
> heartbeat roundtrip completed with reasonable latency too. When connection
> goes down, send a message about it and go back to reconnect state. Keep doing
> heartbeats every now and then while connection is up so you spot failures
> proactively. Can additionally leverage user traffic for link monitoring (ex-
> cessive request timeouts -- probably not good, whether it's failing link
> or overloaded peer you probably want to go away for a while).

This is an interesting question in general. Do you want your API to be "connection" oriented and do a single db:connect, which is essentially a single-threaded way of working. Or do you provide an application handling a "service" which maintains an ongoing connection to the database, reconnecting if needed and so on.

I think i prefer both. In some situations, one over the other is preferred.

Jesper Louis Andersen
  Erlang Solutions Ltd., Copenhagen

More information about the erlang-questions mailing list