views:

405

answers:

3

I am looking to set up a central point of control for settings that exist across several web servers, server applications, and possibly even internal desktop tools.

The current situation is that I have a settings file on each webserver or within each application, with Global Variables defined: Admin Email, Where to store uploaded files, etc. Some settings (such as a global admin email to send error reports to) are pretty much Company wide. Other settings may be client or site specific.

I also want this this central DB to be able to keep tabs on who/what is accessing each setting. For example say I have a "ProcessedImageUploadFolder" setting, with a value of "\\ImageServer\cache\" that is used by 5 differnt web sites, but I want to change this setting, but looking at my central system, I see that theres a 6th server that I didnt think of that has also been requesting this setting (the calling app needs to identify itself to get a setting, so the DB can log it), just in case changing this setting for the 6th server would have an side effects.

Before rolling my own DB with a service to dish out and log the settings, I'm wondering if there are any libraries/apps that handle something like this already. Does anyone have any ideas if something like this has been done? What is this type of system called?

Perferably the solution would be in C#/SQL but if the only option was something like php or Java, I would probably use that as a base and port it.

Or am I going about this all wrong?

EDIT: This is not mult-tenancy. Some of the apps that would use this service are already in a multi-tenant set up. Others are one-off apps... others are desktop apps used on the local network or the VPN.

If anyone can tag this question better, be my guest.

A: 

I think the best term to describe your question Neil would is called "Multi Tenancy". Devlicious posted an interesting article on Multi Tenancy here: http://devlicio.us/blogs/anne_epstein/archive/2009/04/24/the-case-for-multiple-dbs-in-multi-tenancy-situations.aspx.

If I was coding a sshared configuration service I would try to implement using a pattern similar to the Service Locator Pattern http://martinfowler.com/articles/injection.html#UsingAServiceLocator and develop a web service that is easily extendible and easy to interop with. The service would abstract your design regardless of whether it is 1 database, 2 databases or multiple xml configuration files.

Does anyone else have any suggestions?

Kane
Thanks for the reply but this isn't multi-tenancy. See my edit.
Neil N
+1  A: 

A central database with a service seems like the way to go. Make sure that your applications cache the configuration, so that they won't hit the database on every request, and also so that they will be able to keep going if the central database is temporarily unavailable.

If Java is an option, you could take a look at Commons Configuration. You could also have a look at Profile Options in Oracle Applications (page 2-21) for some ideas. Profile Options have an interesting configuration hierarchy, where preferences may be set at the site, application, responsibility, and user level, with the highest level preference taking precedence.

markusk
Ya I think the caching for web apps will probably be 12 or 24 hours, and maybe once per startup for the desktop apps. I will probably make a dll that can both retrieve and cache the settings, then use that in all my apps. But I also want the apps to be able to default to the last setting without interuption if it cant connect to the settings service.
Neil N
A: 

Sounds like a simple dictionary reading from (say, an INI file) that listened on a socket would be ideal for you.

For instance, you could have a format like this:

;; Settings that everyone inherits
[*.domain.com]
ImageUploadLocation = /path/to/foo
AdminEmail = [email protected]

;; Over-ride for other specific hosts
[larry.domain.com]
ImageUploadLocation = /other/path/to/foo

[curly.domain.com]
AdminEmail = [email protected]

You can use the CCAN Iniparser (which ships with a very simple dictionary) to accomplish this, you'll just have to make a simple program to make the data available over a socket. If you want more examples, I'm using it in this tree.

Interestingly, I'm using it in pretty much the same way you described, just locally (no sockets) .. its managing globals for virtual machines (Xen).

Hope this helps! :)

Tim Post
But does this do logging? I want to keep track of who's calling in for what data? And that format looks a little archaic. Id much rather have the data in SQL, or even XML, than in a ini file.
Neil N
@Neil NYou have it relationally in memory .. the format is up to you. get(dict, "%s:foo" , struct->val) ?From that .. xml, json, php arrays, python arrays or (hell) even bash associative arrays are easy. Not sure why you said archaic? Dictionaries and doubly linked lists are a cornerstone to any lower level programmer.
Tim Post
@Neil N, perhaps you are used to higher level creature comforts.
Tim Post
@Neil N, "but does this do logging" , you can't write a logging class, function or subroutine? Perhaps this should be re-tagged as beginner, or perhaps lazy.
Tim Post
Perhaps you missed the part where I was checking to see if there was already an app like this. I could easily write the whole thing from scratch...
Neil N
And how is XML a higher level comfort? Would you call me lazy if I used a higher level IDE than notepad?
Neil N