View Single Post
Old 12-02-2011, 06:26 PM  
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by miguel7 View Post
Thank you for your comprehensive answer.
I think I have to say from the beginning. About 2 months ago my server started to have problems due to higher traffic. When reaching the top traffic hours, Server very often fell. (last moth stats: uptime 99.05%, downtime 6h 48m 29s, number of downtimes 117).

After reading this Stop throwing hardware at your problems. Tune your server! I sent request support I reached my patience. I requested a final solution I required Nginx on my serer. They recommend me Varnish....

It seems that it helped, no any serverdown yet, but it's only 3 days.
But according to what you wrote caching without caching PHP does not make any sense ??
What happened with the server down time? I'm guessing maybe it hit MaxClients? If that were it, adding another server process (Varnish or otherwise) could
cover for that problem until it gets busier but adjusting Apache to match the load would work a lot better. Anyway I'd start by looking at what the problem was in order to prescribe a correct solution. I'd certainly want to DIAGNOSE the problem, not hide it behind a proxy.

One thing that's common to any high traffic traffic site is that you should turn on noatime, though. Noatime makes a huge difference, as much as citing disk io in half for small files and even more if you're using RAID 5. That's actually what's mainly responsible for the apparent speed of nginx - it skips atime updates even if the server admin has the system set to do them. (Is that a bug or a feature?)

The idea of cache generally, whether it's a CPU cache, HD cache, or web cache is that the cache resides on fast (but small) storage. For example the 32 MB of RAM cache in a hard drive is also several million times FASTER than the drive spindles. If the data can be retrieved from cache that's great because the cache is on storage that's so much faster.

In your case, the "cache" is on the hard drive, I assume, the exact same storage as the main copy. Your Varnish cache will run at the speed of the drive, if the file is already cached. Without Varnish, the file would be served from the same drive at the same speed! Does that make sense? The CPU, the RAM, all of that is a million times faster than the drive. So it's the drive that determined the speed of static files, which are just read from the drive. So the cache can be faster only if a) it uses a faster drive or b) the main server is configured to do disk updates that the proxy doesn't do (noatime).

Since reading from either spot on the drive is the same, the only difference is the extra overhead of looking in the cache when it's not there, then having to request it from the main server, update the cache, then finally write it through.

So anyway all that to say:
Diagnose the problem, don't just hide it.
Use noatime on all busy servers that don't have a specific need for atime.

Last edited by raymor; 12-02-2011 at 06:39 PM..
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote