CodeIgniter Forums
Where to keep "instance" id ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Where to keep "instance" id ? (/showthread.php?tid=46922)



Where to keep "instance" id ? - El Forum - 11-20-2011

[eluser]Andy Fraley[/eluser]
I have created a large CMS application that has been designed as a stand alone application with its own set of users. I now need to scale this application to multiple instances. At first I just setup some scripts to provision a symlinked copy of the application and separate databases when a new instance needed to be deployed. I don't think this is scalable to upwards of 1000 instances and it's become too much of a hassle to manage code and schema changes with only about 20 instances.

I'm preparing to refactor the entire application so that all instances are stored in a single database. This means that somewhere the application needs to know what instance the user is working on as this instance id number is needed for every SQL query. Every table will have an instance_id column added to it.

I'm going to run a function during autoload that will set a global variable with the instance_id. Where is the best place to handle this? Should the instance_id be part of the URI for all post and get requests, or is there a better approach? Maybe in the session data?