So, in my eternal search for sub 100ms TTFB for all sites we work on, have been working on further improvements to our NGINX based load balancer/accelerator.
We front all of our web sites and applications and sites with NGINX, and it has served us very well so far. With a great deal of our sites powered by node.js, which tends to suck at file serving we have been looking beyond just caching, looking to further steps the eliminate even more calls to the web servers (not only for node, but for PHP sites as well.)
Getting nginx to pull files from memached is pretty straight forward, (more on that later), but the problem is how to get those assets into memcached in the first place.
The obvious solution is to modify the application's code to put their html output into memcache themselves... but this has not always been practical.
We front all of our web sites and applications and sites with NGINX, and it has served us very well so far. With a great deal of our sites powered by node.js, which tends to suck at file serving we have been looking beyond just caching, looking to further steps the eliminate even more calls to the web servers (not only for node, but for PHP sites as well.)
Getting nginx to pull files from memached is pretty straight forward, (more on that later), but the problem is how to get those assets into memcached in the first place.
The obvious solution is to modify the application's code to put their html output into memcache themselves... but this has not always been practical.
An elegant hack?
So to get the ball rolling without touching the app code, I put together a python app which pulls files down, and puts them into memcache itself. This is a rather quick solution for sites getting a large peak in traffic, and in general keeping static file access from impacting the application servers.
It still under construction but here it is at github.
Whats next...
- Integrate minificcation for js and css files (maybe html as well?)
- Build a flask web app, which can be used as the fall back, which would fill memcache as well as returning the file directly to the client, to enable self priming memcache.
Will post nginx config as well....
Comments
Post a Comment