postgresqlembedded-database

postgresql as an embedded Database


Need a small help regarding the embedded version of PostgreSql. I see that we can create an embedded form of PostgreSql https://github.com/zonkyio/embedded-database-spring-test . But the page specifies mostly a test oriented library and it does not specify if this can be used in a production environment. The requirement is to store some JSON data that will be too large for memory and having a full fledged DB will be too slow. It is good to have a DB spun up for the duration of the function and kill it once the function is complete. So having an embedded version of DB seemed like a good trade off. PostgreSql also provides native JSON handling which provides a lot of advantages if it can be used. I also see that there is no official embedded version of postgresql. Can this be used in the production environment?


Solution

  • I wouldn't.

    If you need an embedded DB for a short duration I would recommend taking a look at sqlite (which supports json, but I don't know if it fits your requirements), or h2 using a file as the backing mechanism. You could also take a look at RocksDB, but that is a lot lower level.

    Sqlite and RocksDb are used by many products. I'm sure h2 is used here and there but probably to a far lower extent.

    You'll also need to think about the storage of your service to find out if the IOPS are good enough (running on mechanical drives will be very different from nvme).