[erlang-questions] atomicity when using more than one database
vim
ofer.affias@REDACTED
Fri Apr 3 10:40:13 CEST 2009
i am looking for some advice on how to implement an application which
use a mnesia database.
the app i am working on, is relying on a central database. the app
issue synchronous commands into this database, which preform all kinds
of tasks. the access to this database should be optimal, since i need
it to have real time performance on the average scenario.
on the other hand, the app need to supply more information (services)
which some of it is sitting on the central database, this extra
information have no real time demands, and can be requested
asynchronously.
i fear that the need for those services will hurt the app
requirements, if i will implement it by accessing the central database
directly.
i thought of several solutions, at first i thought that each write to
the central database can send a message to another process with all
the info to be written. this way i can actually duplicate the info i
need on another mirror database, and i can access it for my services.
the problem with this solution is that the action above is not atomic.
there can be a scenario in which those database can get out of sync.
another solution i thought of, is to wrap all the mnesia transaction
to the core database with more writes to the mirror database for the
services. this way i can guaranty atomicity. the problem here is that
if i need more mirror databases with all kinds of information, it is
kind of ugly to recode those transaction each time and add more code
each time. not to mention a bigger issue: i can get into speed problem
in my core, if the mirror writes (which are wrapped on the same mnesia
transaction to ensure atomicity) will slow the main process down,
causing my app to preform bad and failing to supply the real time
demands i have.
any ideas?
thanks, vim.
More information about the erlang-questions
mailing list