gbulmash
05-07-2005, 02:12 AM
I'm developing some sites to put on a dedicated server, but as I do so, I'm trying to come up with a framework that will allow me to scale to multiple servers with minimum effort and downtime as traffic/use grows (at least until I need more than 4 or 5 servers).
At the doc root of each domain, I'm planning to place thisfile.php with the following contents (or something similar).
<?php
$w1 = "tik.com"; // primary html server
$w2 = "/graphics/"; // graphics server alias
$w3 = "/cgi-bin/"; // remote script server alias
$w4 = "db.tik.com"; // database server alias
?>
(BTW - I do not own tik.com, it's just for demonstration purposes)
In the standard headers of every script or html page on my site, I will have "include_once('/thisfile.php');". When I want to refer to them in html I use: <a href="<?php echo $w1; ?>...">. If I need to refer to them in any scripts, the variables are available via include as well.
If I move graphics to a new server, I just change $w2 in thisfile.php to "graphics[dot]tik.com/" (the lack of the "http" and the use of [dot] are because the system says I'm too new to post a URL - sheesh).
Now My Questions:
1: Is there a more efficient way to do this? Is it possible to cache just those w1, w2, w3 strings so they're read from memory instead of requiring an extra disk read every time? Every caching module whose docs I've read seem to be for caching output itself rather than caching code.
2: Or would it be better to just hardcode the calls, then use Apache's mod_rewrite to send calls to /graphics/ to graphics[dot]tik.com?
Thanks,
Greg
At the doc root of each domain, I'm planning to place thisfile.php with the following contents (or something similar).
<?php
$w1 = "tik.com"; // primary html server
$w2 = "/graphics/"; // graphics server alias
$w3 = "/cgi-bin/"; // remote script server alias
$w4 = "db.tik.com"; // database server alias
?>
(BTW - I do not own tik.com, it's just for demonstration purposes)
In the standard headers of every script or html page on my site, I will have "include_once('/thisfile.php');". When I want to refer to them in html I use: <a href="<?php echo $w1; ?>...">. If I need to refer to them in any scripts, the variables are available via include as well.
If I move graphics to a new server, I just change $w2 in thisfile.php to "graphics[dot]tik.com/" (the lack of the "http" and the use of [dot] are because the system says I'm too new to post a URL - sheesh).
Now My Questions:
1: Is there a more efficient way to do this? Is it possible to cache just those w1, w2, w3 strings so they're read from memory instead of requiring an extra disk read every time? Every caching module whose docs I've read seem to be for caching output itself rather than caching code.
2: Or would it be better to just hardcode the calls, then use Apache's mod_rewrite to send calls to /graphics/ to graphics[dot]tik.com?
Thanks,
Greg
