I want to start using multiple front-end Apache servers for my website.
At the moment I store various HTML files in a caching directory, e.g. "/htmlcache/homepage.html"
Obviously I don't want to re-cache these files on a per-server basis, I'd rather have one central store. How is this usually done?
The options as I see it are:
- Database (MySQL) - extra load - should I be storing larrge .html files?
- Memcache - should this be used for large .html files?
- Some kind of accessible shared disk - no idea how this would work
Latency is key for me. The disk read opperation is working very nicely for me at the moment.
As an additional complication, I'll also need to keep my PHP session data in a central location too.
This thread: https://stackoverflow.com/questions/580671/configure-session-to-work-on-applications-that-are-deployed-over-multiple-server recommends using session_set_save_handler to store the session data in a shared database.
How are you overcoming this issue?
memcached can store "large" HTML files (for suitably small values of large) - Varnish (as Michael Mior mentioned) or Squid are other options. Out of those three I would lean toward Varnish (Squid is overkill for most small environments, and I believe Varnish scales better through medium/large environments: Last time I checked Squid wasn't capable of distributed cacheing).
You will need to test any of these solutions before you deploy them, obviously.
Re: the PHP session part - session_mysql is one solution here. Writing your own custom session handler in PHP is another. I would suggest one of the PECL extensions personally as they tend to be marginally more efficient/faster than PHP code.