I was thinking about an effective caching system to reduce server load and DB connections and eventually makes the server traffic bandwidth bigger + faster response. I will be using an easy way to explain my idea.
Such system can be applied only on heavy traffic websites that have hundreds and thousands of page views every minute and same output to all clients not personalized or dynamic.
Blogs and news websites are the most to benefit from such system.
We will make easy calculations to compare before & after and how much this could reduce the load on the server and increase its traffic bandwidth and eventually servers that could cost thousands of dollars.
We will be using PHP script + MySQL + Apache
-------------------------
Before:
Pageviews: 100/minute
Average DB queries / page: 5
--------------------------------
DB queries on 100 visit: 5 x 100 =
500
How does the system work:
The system functionality is very simple, its main functionality is to create static pages (html) that were already compiled and don't require any PHP rendering nor SQL connections anymore, now every time a client request a page the HTML page will load.
Okay that's great but what if i needed to edit or delete a page... and applying this system on all my website plug ins could take ages to finish.
I already thought about this and the system is global, in a meaning it will cache the whole page (from top to bottom) and not part of it so you don't have to make it internal but global and add it to your page headers.
Editing the pages is very easy also you will understand it below:
Steps:
- Client-1 request a page
- System creates static copy of that page store it then load it to the client.
- Client-2 request a page
- The system checks the life_date of the static page, if it's < than 1 minute load it else go to step 2
So if any changes are made, it doesn't take longer than a minute to display. Of course you are free to set the time you wish and customize the system according to your needs in a way it caches parts of the website and not everything (hint: URL based)
After:
Pageviews: 100/minute
Average DB queries / page: 5
--------------------------------
So all SQL queries in 1 minute are simply 5
SQL connections reduced by 100 times, PHP rendering by almost 50% (since we are still loading the caching system on each request) and the response time has greatly increased especially on peak times.
The response time has greatly increased since the system has nothing to compile anymore.
This can seriously speed up your website like hell + reduce expenses + increase traffic bandwidth.
Of course it's not as simple as that and lot of things should be taken into consideration but this is the base idea of the system.
This is one of the things I'd like to develop.
=)