Categories
Programmer's Mindset

Mysql Master / Slave Thoughts

I have been thinking about a way to have isolated machines that I can almost take on and off line very easily.  Here are my thoughts and would love feedback on my “solution”.

I am almost thinking about “spinning” the traditional model.  I will have my Administrative DB(ADB) in a central place.  ADB will be where I pull all reporting, master updates of product and pricing, all orders, etc….

On each individual web server I will have a slave DB (SDB) that will replicate all data from ADB.  The individual web servers will pull information from SDB for pricing, dynamic web pages, etc…  It will also have its own database (ODB) for writes (order information mainly, maybe other statistics as well).  When an order is placed (instead of trying to reach ADB) it will put the information into ODB.

Now I can have a cron job that will pull the data off each ODB to update ADB for reporting purposes.

Why?

  1. Each web server should be able to run without relying on any other machine.
  2. Once the web server’s SDB is up to date, there should be very little delays in price/product changes.
  3. Scalability, simply launch a new server to be up and running.

Does this make sense?
Web servers write to ODB
Administrative server reads from ODB to update itself which replicates to all the SDB (Every slave/web server becomes a realtime backup of ADB)

Here is a diagram of my thoughts.

DB Proof of Concept
DB Proof of Concept
Reblog this post [with Zemanta]
Categories
Technology

PHP4 is Officially Dead

Today is the final day of support for PHP4. Luckily I have been using PHP5 for quite a long time and have been happy with it. I do not think I use all of the features that would make it a nasty upgrade, like some people do.

I try my hardest to keep all of my software (especially for bowlingball.com) up to date with the latest release. Knowing that support and upgrades will eventually be dropped, it is important for me to stay current.

This is often easier said than done…. 🙂

Categories
PHP Snippets

Calculating This Day Last Year in PHP

Have you ever wanted to know what the date was last year on this day?

Example: You want to compare sales from Wednesday of this year to the same Wednesday of last year. There is a very simple solution in PHP.

[code]
function ThisDateLastYear($date_in) {
// date_in = input date in form of YYYY-MM-DD
$days = 364;
return date(‘Y-m-d’, strtotime(“-364 days”, mktime(0,0,0,$m,$d,$y)));
}
[/code]