Search code examples
mysqlpostgresqlgoembedded-database

How to detemine if database server or embedded database is appropriate


Bolt is a pure Go key/value store inspired by Howard Chu's and the LMDB project. The goal of the project is to provide a simple, fast, and reliable database for projects that don't require a full database server such as Postgres or MySQL.

Bolt readme

How does one determine if an application requires a full database server? I assume it has to do with number of concurrent writers?

I'm planning on writing a simple distributed social networking application as a fun project.


Solution

    1. An embedded database resides within the application. It doesn't need to be relational.

      For instance, the media manager on your computer has a database embedded within it to store audio/video metadata and file location. This database could be relational, in which case, the database could be something like sqlite or mysql. (i don't think postgres can be deployed embedded in an application). Embedded databases are great if you want to cache local information, or you're sure that information within the application does not need to be communicated externally for the application's functionality. A core design goal for embedded databases is having a low footprint, so in many cases embedded databases omit features found in dedicated databases.

    2. A dedicated database server supports one or many clients' read and write operations, and usually provides more features than the embedded versions. Postgres and Mysql are both dedicated databases and are used widely in networked applications. They are also both relational databases, and not key-value stores, which Bolt seems to be.

    3. A key value store is a non-relational database. Think redis (or dicts in python), where

      • retrieval: the client gives the database the key, and the database responds with the value.
      • assigning: the client provides the database a key & value, and the database assigns a new key with given value, or updates the existing key's value.

      Note: postgres has hstore, which is a key value store.

    Just like relational databases, key-value databases can be embedded within or reside separately on dedicated hardware. Here are some example questions one must ask while making these architecture decisions.

    1. Does my application depend on data that need to be communicated, and do I want to communicate the data by writing to a central database, or does each chat client connect to the other client on a peer to peer model and stores its own data?

    2. Do I need a relational model in my application, or a key-value store, or some other exotic data model?

    Just my personal opinion, the relational model has been successful at satisfying a wide variety of persistent requirements over the last 30 odd years. Has very mature solutions for both embedded or dedicated deployment. It is a good place to start.