Daniel,<br>I see this as a good compromise for your situation.<br><br><div class="gmail_quote">On Thu, Mar 5, 2009 at 9:36 PM, Daniel Rhoden <span dir="ltr">&lt;<a href="mailto:drhoden@gmail.com">drhoden@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="">There has been a growing trend in using VPS like Xen to host sites.  What I&#39;m seeing is that memory is guaranteed, but the I/O to the hard drive is competing with the other customers on the same physical server.<div>
<br></div><div>I&#39;ve given up on the idea of using Perl to populate memcached on the fly for anything, static html or dynamic.  I agree that the best place for memory caching of static content is right with nginx.</div>
<div><br></div><div>Did some analysis and found that about 1% of our pages get 40% of the traffic.  Since these are static pages it is unlikely that they will change in popularity from day to day.  So I&#39;ve decided that a cron job can populate the cache for these few pages (and then some) with very little overhead, very little memory, with the biggest payoff.</div>
<div><br></div><div>Thank you all for your feedback on this idea. </div><div><br></div><div>By the way: I am seeing a boost in performance by caching static files.  Small, but every ms counts.</div><div><div></div><div class="h5">
<div><br><div><div>On Mar 5, 2009, at 1:09 PM, Marcus Clyne wrote:</div><br><blockquote type="cite"> <div bgcolor="#ffffff" text="#000000"> Atif,<br> <br> I understood it the same way you did, and was saying that serving files from memcached as opposed to the filesystem has negligible benefits, and sometimes actually performs worse.<br>
 <br> The reference to error_page (not error_file as I said before - memory slip) was just as a means to populate memcache when there&#39;s no data in the cache - you could easily use this method to put the file into memcache from the filesystem.  You wouldn&#39;t need to use an Nginx module to put the file into memcache (at least not with the current Perl module - it&#39;s blocking, so would slow everything down too much, though with a non-blocking version it could be ok) - though I understand that that&#39;s what he&#39;s talking about and where he&#39;s talking about hooking it in.<br>
 <br> Another method would be to use the try_files directive.<br> <br> Overall, though, I can only see populating memcache with a file to serve through Nginx as being overall slower than serving the file from the filesystem.  In my tests, memcache vs filesystem is pretty similar, and adding any kind of overhead to put a file in memcache will mean just serving the file statically will be more efficient (and won&#39;t waste memory unnecessarily).  I could see storing static files in an internal memory cache being a bit quicker than serving files statically, but actually not all that much, and would only possibly be of real benefit for files that are under very high demand (e.g. a homepage or a logo on a high-traffic site).<br>
 <br> Cheers,<br> <br> Marcus.<br> <br> <br> Given that the<br> <br> Atif Ghaffar wrote: <blockquote type="cite"><br>  <br>  <div class="gmail_quote">On Thu, Mar 5, 2009 at 12:34 PM, Marcus Clyne <span dir="ltr">&lt;<a href="mailto:eugaia@gmail.com" target="_blank">eugaia@gmail.com</a>&gt;</span> wrote:<br>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">    <div bgcolor="#ffffff" text="#000000"><br> For populating the cache, have you looked at the error_file directive.  You can set the error file to script which could be passed to an FCGI process, so that on a cache-miss the script is called to generate the page, which could in the process put the file into the memcached cache.  </div>
  </blockquote>  <div><br> Marcus, <br>  <br> I believe Daniel  was talking about the opposite. He want to populate the cache if nginx hits the file instead of when it does not find it.<br>  <br> So something like this (this is how nginx would do it<br>
  <br> request comes from /files/1.txt<br> 1. Check if memcache exists and serve from there.<br> 2. Check if file exist and serve from here.  &lt;---- This is where he wants to hook it :-)<br> 3. If file does not exists, handle error.<br>
  <br> What Daniel wants (if I understood correctly)<br> request comes from /files/1.txt<br> 1. Check if memcache exists and serve from there.<br> 2. if(-f file ) call the perl/fcgi process that populates the memcache cache and returns the file. (so this would be done only where there is no cache in memcache)<br>
 3. If file does not exists, handle error.<br>  <br>  <br> Still I dont see whats the point of this but yes it is doable.<br>  <br> best regards<br>  <br>  <br>  <br>  <br>  <br>  </div>  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div bgcolor="#ffffff" text="#000000">This of course only really makes sense for dynamically-generate content.<br>    <font color="#888888"><br> Marcus.</font>    <div>    <div><br>  <br>    <br> Atif Ghaffar wrote:    <blockquote type="cite">
Daniel, <br>      <br> I see now your other posts, <br>      <br> I do not think that you will get any benifit of using memcached with static files.<br> Nginx is already very optimized at serving static files.<br>      <br>
      <br>      <div class="gmail_quote">On Wed, Mar 4, 2009 at 11:17 PM, Daniel Rhoden <span dir="ltr">&lt;<a href="mailto:drhoden@iiwinc.com" target="_blank">drhoden@iiwinc.com</a>&gt;</span> wrote:<br>      <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This is purely speculative, so please don&#39;t think I know how to do this.  I&#39;m throwing this out so hopefully, if a good idea, the right people can create the example.<br>        <br> Memcached has a good assortment of Perl clients.<br>
        <br> Nginx has a means of embedding Perl into the configuration.<br>        <br> Couldn&#39;t there be a way of combining these to immediately populate the cache when the cache returns missing?<br>        <br> By the way, I&#39;m looking at this as a means of improving I/O for static pages (on SliceHost).  Ideally nginx&#39;s Memcached Module would have the ability to do this when the requested filename exists on the hard drive:<br>
 (-f $request_filename/index.html)<br>        <font color="#888888"><br>        <br> Daniel Rhoden<br> Director of Information Technology<br> Interactive Internet Websites, Inc.<br> 3854 - 2 Killearn Court<br> Tallahassee, Florida 32309<br>
 Voice: (256) 878-5554<br> E-Mail: <a href="mailto:drhoden@iiwinc.com" target="_blank">drhoden@iiwinc.com</a><br> Website: <a href="http://iiwinc.com" target="_blank">iiwinc.com</a><br>        <br>        <br>        </font></blockquote>
      </div>      <br>      <br clear="all">      <br> -- <br> best regards<br> Atif Ghaffar<br>    </blockquote>    <br>    </div>    </div>    </div>  </blockquote>  </div>  <br>  <br clear="all">  <br> -- <br> best regards<br>
 Atif Ghaffar<br> </blockquote> <br> </div> </blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br>best regards<br>Atif Ghaffar<br>