What are the pros and cons for using a database to store configuration information compared to a File System

configuration-files, java, relational-database, sql, xml

Solution

Here is a summary of pros and cons

Pros for file:

- Fast access to configuration data. (assuming no caching)

- Each server can be configured differently (in a load balancing situation)

- You already need a file for the database credentials so everything can be stored in one place.

Cons for file:

- Configuration in a load balanced environment is difficult.

- When adding settings under development, one most remember to move them into the files on every server in production.

- Configuration must be writable by the webserver if you want to write a control panel to change the settings at runtime. Manipulating files in a control panel is a hassle due to timing issues and or locking.

Pros for database:

- Load balancer can share configuration across the cluster

- It's very easy to check on settings remotely or change them such as in phpMyAdmin or a straight sql client.

- Control panel development becomes simple.

- Performance impact can be mitigated by caching configuration in memcached or in a hash in memory.

- Programmers are more likely to control settings rather than IT people or at least can be controlled through control panel.

Cons for database:

- Performance maybe slow if you're fetching the settings continuously.

- If you don't provide a tool, it might be more difficult for sysadmins to administer the product rather than a file. They might not be sql gurus.

- Clustering is more of a pain.

This comes down to personal preference and any current or possible future requirements for providing easy configuration.

Problem

Suppose you are tasked with writing a web application that must store configuration information in some format. What are the benefits and drawbacks for storing these configuration information in a relational database compared to storing the information in a file? Configuration options may include but not limited to data retention settings and settings for interfacing with external system (e.g. ip address, port, username, password).

Original source