Welcome Guest, Not a member yet? Register   Sign In
Best caching for high traffic website
#1

[eluser]fernandoch[/eluser]
What is the best caching method used with codeigniter? Is it memcache? Yes? Why not?

Thank you.
#2

[eluser]boltsabre[/eluser]
This is the vaguest of vague of questions. Have you even googled the topic and done ANY research, or just asked on here hoping for a golden answer???

If the second, sorry to disappoint you but there is no "Golden Answer", in short it will depend on a number of things...
- How much, and what type of, data you want to cache (HINT: You may want to run more than one caching option for different types of data!!!)
- How often you write/delete/update these cache files/resources
- How powerful is your server/s, and how many resources you can allocate/dedicate for caching purposes VS the first point
- Peak loads, and how much strain these peaks place on your server/s
- etc, etc, etc

Perhaps have a look at these two stackoverflow questions and get a bit of background information on the topic first
- http://stackoverflow.com/questions/71966...em-caching
- http://stackoverflow.com/questions/31480...-memcached

Then, if you have some specific questions, and are able to provide some specifics about your set-up/situation, someone may be able to help you a bit more.

But at the end of the day, you're more than likely going to have to do some benchmark testing to see what is best for you.
#3

[eluser]fernandoch[/eluser]
Thank you for the reply Smile

I have always seen that websites with high traffic usually use memcache... And in the Best Practices post I see many options

http://ellislab.com/forums/viewthread/125687/

This is why I was asking Smile
#4

[eluser]boltsabre[/eluser]
Yes, there are many options!

For example, if you were storing a lot of large static pages/blocks of data in cache, you would more than likely want to use a file based approach otherwise you are likely to fill your memcache up very quickly!

But for smaller DB queries/results, often memcache is a better option. BUT... implementing it can add another layer of complexity.

So it all comes down to what you are trying to achieve, how much time/resources you have to implement it, etc.

Phil Sturgeon wrote a nice simple library (forgotten the name, just google "Phil Sturgeon Cache library"), it's what I use. It's file based.

Unless the ONLY option (in regards to page load speeds) left to you is your caching option, I'd just implement Phils file based library, there are lot's of other things you can do to increase page load times. The difference between mem or file caching is quiet small. Things like:
- combining images into sprites
- optimising images
- setting height/width on all images
- optimising (PHP) code
- reducing http requests
- reducing file sizes (html, js, css)
- setting up gzip
- setting up expire headers
- setting up minify on JS/CSS files
- deferring the passing of JS (and/or) only loading it at the bottom of the file
- and other page speed options
- hosting assets on different servers
Can have much bigger impacts than your choice of cache library/option.

That's what I'd do, quickly set up a simple file based cache solution. Then concentrate on the above mentioned things. Once you've done that, and if you feel you still need to, then you can concentrate on turning parts/all of you file cache to memcache.

Hope that helps
#5

[eluser]fernandoch[/eluser]
Thank you very much @boltsabre
#6

[eluser]boltsabre[/eluser]
If you want to look at your page load speeds, try www.gtmetrix.com, it's very good for a starting point, gives you a break down from both googles and yahoos page speed testers and hints, tips, information about various options to you.

Oh, if you a really high traffic site with an international audience, also look into setting up a CDN, they have help greatly by hosting your asset files across the globe!
#7

[eluser]fernandoch[/eluser]
Try this other one from google

https://developers.google.com/speed/pagespeed/insights
#8

[eluser]solid9[/eluser]
The best way is to try all of them and run a stress test.
The best teacher is experience.
#9

[eluser]boltsabre[/eluser]
And one last thing, look at your DB queries, optimising them can also help greatly!

Stuff like:
Code:
SELECT *
//do you really need to select everything? Most tables have stuff like date created, edited, deleted, ip, etc
// If not, specify only what you need!
SELECT id, topic, user_id,...

Or using a LIMIT 1 where required. If your query should only return 1 item, then put a limit on it!
Forget it though if you are using a WHERE clause on a primary_key, by default they can only be unique, so as soon as it is found the query will exit, but if you are using something like WHERE user_id = $user_id, and the user can only have one record in that table, then yes, put the limit on it!!!

And benchmark your test your joins and stuff. Stuff like making sure you have an index on the "join" columns in both tables.

What about indexes? Do they need rebuilding? Or partitioning your DB/tables?

There is HEAPS you can do to speed up your DB queries, google the topic, it's quiet interesting.




Theme © iAndrew 2016 - Forum software by © MyBB