Proxy Servers
The proxy servers would be the front line of our system. Our goal was to serve as many requests from them as possible without having to use any other resources. These servers would do three jobs.
Their first and primary job was to serve cached requests directly from memcached. Memcached is a caching daemon that uses memory to store cache. It is designed to be a distributed system that lives on multiple host machines. One of the benefits is that the cache is shared. This means only one copy of an item is in the cache at a time. This was very desirable to us. The proxy servers would first check the memcached cluster for the given request URI. If it was found, the data would be returned immediately to the client, and the connection would be closed (this makes for incredibly fast requests). If the cache was empty, the proxy server would contact an application server. The data the application server returned would then be stored in memcached for later use. The application servers use standard HTTP headers to tell the proxy servers how to cache the content. Using standard HTTP headers means that even applications that we did not handwrite could be cached with little work.
The servers' second job was to serve what we came to call our lightweight scripts. These are scripts that require little to no overhead from our custom framework and are often logging, tracking, or redirection scripts that have fewer than 100 lines of PHP code and don't do any intensive database work or serve ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access